-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: invalid metric should raise an exception #20882
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20882 +/- ##
===========================================
- Coverage 66.25% 54.78% -11.48%
===========================================
Files 1758 1758
Lines 67048 67049 +1
Branches 7118 7118
===========================================
- Hits 44423 36730 -7693
- Misses 20808 28502 +7694
Partials 1817 1817
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. |
599e1ba
to
5e90682
Compare
@@ -716,7 +716,7 @@ def test_get_data_transforms_dataframe(self): | |||
self.assertEqual(data, expected) | |||
|
|||
def test_get_data_empty_null_keys(self): | |||
form_data = {"groupby": [], "metrics": ["", None]} |
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.
The metric must be a string
or AdhocMetric
.
@@ -43,5 +43,5 @@ | |||
"granularity_sqla": null, | |||
"autozoom": true, | |||
"url_params": {}, | |||
"size": 100 | |||
"size": "100" |
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.
the metric must be string
@@ -45,5 +45,5 @@ | |||
"granularity_sqla": null, | |||
"autozoom": true, | |||
"url_params": {}, | |||
"size": 100 | |||
"size": "100" |
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.
the metric must be string
class Query(Model, ExtraJSONMixin, ExploreMixin): # pylint: disable=abstract-method | ||
class Query( | ||
Model, ExtraJSONMixin, ExploreMixin | ||
): # pylint: disable=abstract-method,too-many-public-methods |
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.
bycatch: CI was failed by pylint error.
} | ||
self.assertEqual(data, expected) | ||
|
||
form_data = {"groupby": [], "metrics": [None]} |
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.
Should we add a test case where metric is a dict, too?
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.
the more unit test at here. I added some invalid metric case as well.
SUMMARY
In some
unknown cases
(may be database migration?) the ad-hoc metric may be missingexpressionType
field, then an exception should be raised to let the user handle the incorrect metrics.the original issue was reported from shortcut.
Just judging from this error, the first
metric
is not ahashable
type. e.g.TESTING INSTRUCTIONS
before fix
birth_name
as datasource,table
as vizslices
table and find out the newest record.params
column and remove"expressionType":"SQL",
in it.7. go to `/api/v1/dashboard/{$DashboardID}}/datasets` will look at the error, responded status code is 500
after fix
/api/v1/dashboard/{$DashboardID}}/datasets
will look at the error, the status code is 400, and error message will point out specific errors and failed the metric.ADDITIONAL INFORMATION