-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use expected label in metrics map #15707
Conversation
@@ -1086,7 +1086,7 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma | |||
|
|||
# To ensure correct handling of the ORDER BY labeling we need to reference the | |||
# metric instance if defined in the SELECT clause. | |||
metrics_exprs_by_label = {m.name: m for m in metrics_exprs} | |||
metrics_exprs_by_label = {m.key: m for m in metrics_exprs} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refer to:
superset/superset/connectors/sqla/models.py
Lines 938 to 943 in b489cff
if db_engine_spec.allows_alias_in_select: | |
label = db_engine_spec.make_label_compatible(label_expected) | |
sqla_col = sqla_col.label(label) | |
sqla_col.key = label_expected | |
return sqla_col |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to have more documentation in this code. It's a critical piece of Superset that is currently quite cryptic for the un-initiated. Would you mind adding a comment at line 942 describing what the purpose is of key
, and also here specifying why we use the key
attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I have added comments here. db_engine_spec
of Bigquery changed metric_label
.
superset/superset/db_engine_specs/bigquery.py
Line 208 in 0ed97eb
def _mutate_label(label: str) -> str: |
Codecov Report
@@ Coverage Diff @@
## master #15707 +/- ##
==========================================
+ Coverage 76.82% 76.91% +0.08%
==========================================
Files 983 983
Lines 51585 51600 +15
Branches 6974 6974
==========================================
+ Hits 39632 39686 +54
+ Misses 11729 11690 -39
Partials 224 224
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/testenv up |
@suddjian Ephemeral environment spinning up at http://54.149.175.38:8080. Credentials are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, and investigated the code. All looks good as far as I can tell, but my experience in this part of the codebase is limited.
Ephemeral environment shutdown and build artifacts deleted. |
🏷 2021.27 |
* fix: use expected label in metrics map * added comments * fix type (cherry picked from commit 0721f54)
* fix: use expected label in metrics map * added comments * fix type
* fix: use expected label in metrics map * added comments * fix type
* fix: use expected label in metrics map * added comments * fix type
SUMMARY
ensure the
key
of metrics expression hashmap and the expected key are consistentcloses: #15693
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION