You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/07/27 04:46:45 UTC

[GitHub] [superset] zhaoyongjie opened a new pull request, #20882: fix: invalid metric should raise an exception

zhaoyongjie opened a new pull request, #20882:
URL: https://github.com/apache/superset/pull/20882

   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   In some `unknown cases`(may be database migration?) the ad-hoc metric may be missing `expressionType` field, then an exception should be raised to let the user handle the abnormal metrics.
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r931196437


##########
superset/dashboards/api.py:
##########
@@ -383,8 +383,10 @@ def get_datasets(self, id_or_slug: str) -> Response:
                 self.dashboard_dataset_schema.dump(dataset) for dataset in datasets
             ]
             return self.response(200, result=result)
-        except TypeError:
-            return self.response_400(message=gettext("Dataset schema is invalid."))
+        except (TypeError, ValueError) as err:
+            return self.response_400(
+                message=gettext(f"Dataset schema is invalid, caused by: {str(err)}")

Review Comment:
   sorry, forgot again.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #20882:
URL: https://github.com/apache/superset/pull/20882#issuecomment-1196269885

   # [Codecov](https://codecov.io/gh/apache/superset/pull/20882?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#20882](https://codecov.io/gh/apache/superset/pull/20882?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f674ec0) into [master](https://codecov.io/gh/apache/superset/commit/35184b299478edd44ee1c9d970f0d53ddc93ac86?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (35184b2) will **decrease** coverage by `11.48%`.
   > The diff coverage is `50.00%`.
   
   > :exclamation: Current head f674ec0 differs from pull request most recent head c35364b. Consider uploading reports for the commit c35364b to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #20882       +/-   ##
   ===========================================
   - Coverage   66.26%   54.78%   -11.49%     
   ===========================================
     Files        1758     1758               
     Lines       66995    67049       +54     
     Branches     7117     7117               
   ===========================================
   - Hits        44392    36730     -7662     
   - Misses      20786    28502     +7716     
     Partials     1817     1817               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `53.24% <50.00%> (-0.04%)` | :arrow_down: |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `53.14% <50.00%> (+<0.01%)` | :arrow_up: |
   | python | `57.83% <50.00%> (-23.76%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `50.25% <50.00%> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/20882?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/dashboards/api.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9hcGkucHk=) | `51.15% <0.00%> (-41.33%)` | :arrow_down: |
   | [superset/utils/core.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvY29yZS5weQ==) | `62.81% <75.00%> (-27.42%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-88.89%)` | :arrow_down: |
   | [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-85.30%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-80.77%)` | :arrow_down: |
   | [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
   | [superset/datasets/commands/update.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvdXBkYXRlLnB5) | `25.30% <0.00%> (-68.68%)` | :arrow_down: |
   | [superset/datasets/commands/create.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvY3JlYXRlLnB5) | `29.41% <0.00%> (-68.63%)` | :arrow_down: |
   | [superset/datasets/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvaW1wb3J0ZXJzL3YwLnB5) | `24.03% <0.00%> (-67.45%)` | :arrow_down: |
   | ... and [280 more](https://codecov.io/gh/apache/superset/pull/20882/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r930678558


##########
tests/integration_tests/viz_tests.py:
##########
@@ -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]}

Review Comment:
   The metric must be a `string` or `AdhocMetric`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r931274711


##########
tests/integration_tests/viz_tests.py:
##########
@@ -739,19 +739,13 @@ def test_get_data_empty_null_keys(self):
                     "group": "All",
                 }
             ],
-            "NULL": [
-                {
-                    "values": [
-                        {"x": 100, "y": 10},
-                        {"x": 200, "y": 20},
-                        {"x": 300, "y": 30},
-                    ],
-                    "group": "All",
-                }
-            ],
         }
         self.assertEqual(data, expected)
 
+        form_data = {"groupby": [], "metrics": [None]}

Review Comment:
   the more unit test at [here](https://github.com/apache/superset/blob/5572f3f42442e617d55759e7203d590102adc58b/tests/unit_tests/core_tests.py#L89). I added some invalid metric case as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r930701777


##########
tests/integration_tests/fixtures/deck_geojson_form_data.json:
##########
@@ -43,5 +43,5 @@
   "granularity_sqla": null,
   "autozoom": true,
   "url_params": {},
-  "size": 100
+  "size": "100"

Review Comment:
   the metric must be `string`



##########
tests/integration_tests/fixtures/deck_path_form_data.json:
##########
@@ -45,5 +45,5 @@
   "granularity_sqla": null,
   "autozoom": true,
   "url_params": {},
-  "size": 100
+  "size": "100"

Review Comment:
   the metric must be `string`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r930678558


##########
tests/integration_tests/viz_tests.py:
##########
@@ -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]}

Review Comment:
   the metrics must be a `string` or `AdhocMetric`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] ktmud commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
ktmud commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r931189352


##########
tests/integration_tests/viz_tests.py:
##########
@@ -739,19 +739,13 @@ def test_get_data_empty_null_keys(self):
                     "group": "All",
                 }
             ],
-            "NULL": [
-                {
-                    "values": [
-                        {"x": 100, "y": 10},
-                        {"x": 200, "y": 20},
-                        {"x": 300, "y": 30},
-                    ],
-                    "group": "All",
-                }
-            ],
         }
         self.assertEqual(data, expected)
 
+        form_data = {"groupby": [], "metrics": [None]}

Review Comment:
   Should we add a test case where metric is a dict, too?



##########
superset/dashboards/api.py:
##########
@@ -383,8 +383,10 @@ def get_datasets(self, id_or_slug: str) -> Response:
                 self.dashboard_dataset_schema.dump(dataset) for dataset in datasets
             ]
             return self.response(200, result=result)
-        except TypeError:
-            return self.response_400(message=gettext("Dataset schema is invalid."))
+        except (TypeError, ValueError) as err:
+            return self.response_400(
+                message=gettext(f"Dataset schema is invalid, caused by: {str(err)}")

Review Comment:
   Use `%s` for translatable text



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie commented on a diff in pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on code in PR #20882:
URL: https://github.com/apache/superset/pull/20882#discussion_r930705455


##########
superset/models/sql_lab.py:
##########
@@ -61,7 +61,9 @@
 logger = logging.getLogger(__name__)
 
 
-class Query(Model, ExtraJSONMixin, ExploreMixin):  # pylint: disable=abstract-method
+class Query(
+    Model, ExtraJSONMixin, ExploreMixin
+):  # pylint: disable=abstract-method,too-many-public-methods

Review Comment:
   bycatch: CI was failed by pylint error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zhaoyongjie merged pull request #20882: fix: invalid metric should raise an exception

Posted by GitBox <gi...@apache.org>.
zhaoyongjie merged PR #20882:
URL: https://github.com/apache/superset/pull/20882


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org