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/09/16 06:27:56 UTC

[GitHub] [superset] zhaoyongjie opened a new pull request, #21489: fix: BigQuery cannot accept Time Grain

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

   ### SUMMARY
   This PR fixes Time Grain in the BigQuery as datasource and FF `GENERIC_CHART_AXES` is enabled.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   #### After
   <img width="1322" alt="image" src="https://user-images.githubusercontent.com/2016594/190571129-2b6d229d-8af3-4bc2-a12d-390b3654284c.png">
   
   
   #### Before
   <img width="1323" alt="image" src="https://user-images.githubusercontent.com/2016594/190571274-e22dd401-7687-4dde-9988-2b15837bbfa6.png">
   
   
   
   ### 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 pull request #21489: fix: BigQuery cannot accept Time Grain

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on PR #21489:
URL: https://github.com/apache/superset/pull/21489#issuecomment-1249003950

   > LGTM, but curious to hear your thoughts on the proposed simplification.
   
   Let me check where the whole codebase calls this argument.


-- 
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 #21489: fix: BigQuery cannot accept Time Grain

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


-- 
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 #21489: fix: BigQuery cannot accept Time Grain

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


##########
superset/connectors/sqla/models.py:
##########
@@ -1144,9 +1144,10 @@ def adhoc_column_to_sqla(
             and (time_grain := col.get("timeGrain"))
         ):
             sqla_column = self.db_engine_spec.get_timestamp_expr(
-                sqla_column,
-                None,
-                time_grain,
+                col=sqla_column,
+                pdf=None,
+                time_grain=time_grain,
+                type_=str(getattr(sqla_column, "type", "")),

Review Comment:
   `_date_trunc_functions` expects to get string object as `_type`.



-- 
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 #21489: fix: BigQuery cannot accept Time Grain

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

   # [Codecov](https://codecov.io/gh/apache/superset/pull/21489?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 [#21489](https://codecov.io/gh/apache/superset/pull/21489?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f89ab10) into [master](https://codecov.io/gh/apache/superset/commit/324e9979fa968b07d0be2628cac9119c492dc9b6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (324e997) will **decrease** coverage by `11.46%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #21489       +/-   ##
   ===========================================
   - Coverage   66.69%   55.22%   -11.47%     
   ===========================================
     Files        1791     1791               
     Lines       68476    68476               
     Branches     7270     7270               
   ===========================================
   - Hits        45671    37817     -7854     
   - Misses      20938    28792     +7854     
     Partials     1867     1867               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | postgres | `?` | |
   | presto | `52.98% <ø> (ø)` | |
   | python | `57.71% <ø> (-23.69%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `51.05% <ø> (ø)` | |
   
   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/21489?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...et-ui-chart-controls/src/shared-controls/index.tsx](https://codecov.io/gh/apache/superset/pull/21489/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-c3VwZXJzZXQtZnJvbnRlbmQvcGFja2FnZXMvc3VwZXJzZXQtdWktY2hhcnQtY29udHJvbHMvc3JjL3NoYXJlZC1jb250cm9scy9pbmRleC50c3g=) | `60.78% <0.00%> (ø)` | |
   | [superset/connectors/sqla/models.py](https://codecov.io/gh/apache/superset/pull/21489/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-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL21vZGVscy5weQ==) | `77.37% <ø> (-13.23%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/21489/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/21489/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/21489/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/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/21489/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-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
   | [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/21489/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/21489/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/21489/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.00% <0.00%> (-69.05%)` | :arrow_down: |
   | [superset/datasets/commands/create.py](https://codecov.io/gh/apache/superset/pull/21489/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) | `31.25% <0.00%> (-68.75%)` | :arrow_down: |
   | ... and [284 more](https://codecov.io/gh/apache/superset/pull/21489/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) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?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 pull request #21489: fix: BigQuery cannot accept Time Grain

Posted by GitBox <gi...@apache.org>.
zhaoyongjie commented on PR #21489:
URL: https://github.com/apache/superset/pull/21489#issuecomment-1249009311

   I will refactor `BaseEngineSpec.get_timestamp_expr` in a separate PR.


-- 
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] codyml commented on a diff in pull request #21489: fix: BigQuery cannot accept Time Grain

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


##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx:
##########
@@ -197,12 +197,10 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
     if (isAdhocColumn(xAxisValue)) {
       return true;
     }
-    if (isPhysicalColumn(xAxisValue) && Array.isArray(xAxis?.options)) {
-      for (let i = 0; i < xAxis.options.length; i += 1) {
-        if (xAxis.options[i].column_name === xAxisValue) {
-          return !!xAxis.options[i].is_dttm;
-        }
-      }
+    if (isPhysicalColumn(xAxisValue)) {
+      return !!(xAxis?.options ?? []).find(
+        (col: ColumnMeta) => col?.column_name === xAxisValue,
+      )?.is_dttm;

Review Comment:
   Looks good, thanks!



-- 
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 #21489: fix: BigQuery cannot accept Time Grain

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


##########
superset/connectors/sqla/models.py:
##########
@@ -1144,9 +1144,10 @@ def adhoc_column_to_sqla(
             and (time_grain := col.get("timeGrain"))
         ):
             sqla_column = self.db_engine_spec.get_timestamp_expr(
-                sqla_column,
-                None,
-                time_grain,
+                col=sqla_column,
+                pdf=None,
+                time_grain=time_grain,
+                type_=str(getattr(sqla_column, "type", "")),

Review Comment:
   `_date_trunc_functions` expects to get string object as `_type` argument.



-- 
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] villebro commented on a diff in pull request #21489: fix: BigQuery cannot accept Time Grain

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


##########
superset/connectors/sqla/models.py:
##########
@@ -1144,9 +1144,10 @@ def adhoc_column_to_sqla(
             and (time_grain := col.get("timeGrain"))
         ):
             sqla_column = self.db_engine_spec.get_timestamp_expr(
-                sqla_column,
-                None,
-                time_grain,
+                col=sqla_column,
+                pdf=None,
+                time_grain=time_grain,
+                type_=str(getattr(sqla_column, "type", "")),

Review Comment:
   Could we refactor this so that `type_` is removed from the `BaseEngineSpec.get_timestamp_expr` sig and we then use `sqla_column.type` inside the method for `type_`? Or is the explicit `type_` needed somewhere else? I looked here, and I think we can infer the type from `ColumnClause.type` here, too.



-- 
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 #21489: fix: BigQuery cannot accept Time Grain

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


##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/index.tsx:
##########
@@ -197,12 +197,10 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
     if (isAdhocColumn(xAxisValue)) {
       return true;
     }
-    if (isPhysicalColumn(xAxisValue) && Array.isArray(xAxis?.options)) {
-      for (let i = 0; i < xAxis.options.length; i += 1) {
-        if (xAxis.options[i].column_name === xAxisValue) {
-          return !!xAxis.options[i].is_dttm;
-        }
-      }
+    if (isPhysicalColumn(xAxisValue)) {
+      return !!(xAxis?.options ?? []).find(
+        (col: ColumnMeta) => col?.column_name === xAxisValue,
+      )?.is_dttm;

Review Comment:
   bycatch: improve code smell



-- 
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