Skip to content
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(bigquery): calculated column cannot orderby in BigQuery #17196

Merged
merged 4 commits into from
Oct 22, 2021

Conversation

zhaoyongjie
Copy link
Member

@zhaoyongjie zhaoyongjie commented Oct 22, 2021

SUMMARY

closed: #17178

Calculated column cannot use in native filter when using Google BigQuery. This is due to the column in ORDER BY must be in SELECT clause or GROUP BY clause.

added a new class property allows_hidden_cc_in_orderby in BaseEngineSpec to fix this error.

a calculated column in orderby

image

TESTING INSTRUCTIONS

Test this PR follow this issue: #17178

ADDITIONAL INFORMATION

@codecov
Copy link

codecov bot commented Oct 22, 2021

Codecov Report

Merging #17196 (78fce8b) into master (824e62b) will decrease coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17196      +/-   ##
==========================================
- Coverage   76.93%   76.72%   -0.21%     
==========================================
  Files        1039     1039              
  Lines       55585    55592       +7     
  Branches     7578     7578              
==========================================
- Hits        42766    42655     -111     
- Misses      12569    12687     +118     
  Partials      250      250              
Flag Coverage Δ
hive ?
mysql 81.92% <100.00%> (+<0.01%) ⬆️
postgres 81.93% <100.00%> (+<0.01%) ⬆️
presto ?
python 82.01% <100.00%> (-0.41%) ⬇️
sqlite 81.60% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/connectors/sqla/models.py 85.84% <100.00%> (-1.51%) ⬇️
superset/db_engine_specs/base.py 88.20% <100.00%> (-0.37%) ⬇️
superset/db_engine_specs/bigquery.py 84.84% <100.00%> (+0.09%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-85.19%) ⬇️
superset/db_engine_specs/hive.py 69.76% <0.00%> (-17.06%) ⬇️
superset/db_engine_specs/presto.py 83.47% <0.00%> (-6.49%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/models/core.py 89.26% <0.00%> (-0.74%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 824e62b...78fce8b. Read the comment docs.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 22, 2021
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, this is definitely a bug in the BQ query engine 🤦 This workaround should IMO preferably be placed in the BQ SQLA dialect. I wonder if we should open a ticket there to get this fixed upstream, i.e. have the dialect ensure that the alias is used instead of the full expression? In the meantime this is a great workaround, thanks for fixing! Tested to work as expected, LGTM!

@zhaoyongjie zhaoyongjie merged commit bedb8f4 into apache:master Oct 22, 2021
@rosemarie-chiu
Copy link
Contributor

This is awesome! Thank you!

rosemarie-chiu pushed a commit to preset-io/superset that referenced this pull request Oct 22, 2021
…7196)

* fix(bigquery): calculated column cannot orderby in BigQuery

* typo

* add ut

* fix lint

(cherry picked from commit bedb8f4)
@sadpandajoe
Copy link
Contributor

🏷️ 2021.42

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.5.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset:2021.42 size/M 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Native Filter] Not able to create dashboard native filter with calculated column
5 participants