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

Force quotes on non-expression time grains on Postgres #6897

Merged
merged 5 commits into from
Feb 21, 2019
Merged

Force quotes on non-expression time grains on Postgres #6897

merged 5 commits into from
Feb 21, 2019

Conversation

villebro
Copy link
Member

@villebro villebro commented Feb 16, 2019

Due to time grains being rendered as literal columns in sqla/models.py, engine-specific quoting logic is not applied. This causes mixed-case columns to fail on Postgres in timeseries graphs if a time grain is applied. There have been attempts to fix this by forcing quotes in the time grain; however, this caused time grains on expressions to stop working (see #3844 for context). This PR introduces a function in db_engine_specs.py to handle rendering of the expression being passed to the time grain, which for Postgres forces quotes around MixedCase column names, but not lower_case. This has been tested to work in all scenarios:

  • expression with time grain
  • expression without time grain
  • column with time grain
  • column without time grain

Fixes #5886

Before:
screenshot 2019-02-16 at 8 48 41
After:
screenshot 2019-02-16 at 8 49 55

@codecov-io
Copy link

codecov-io commented Feb 16, 2019

Codecov Report

Merging #6897 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6897      +/-   ##
==========================================
+ Coverage   63.96%   63.97%   +0.01%     
==========================================
  Files         422      422              
  Lines       20524    20533       +9     
  Branches     2230     2230              
==========================================
+ Hits        13128    13137       +9     
  Misses       7264     7264              
  Partials      132      132
Impacted Files Coverage Δ
superset/db_engine_specs.py 56.75% <100%> (+0.44%) ⬆️
superset/connectors/sqla/models.py 81.73% <100%> (+0.03%) ⬆️

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 f5277fe...95e9011. Read the comment docs.

@mistercrunch
Copy link
Member

Unit tests please!

@villebro villebro changed the title Force quotes on non-expression time grains on Postgres [WIP] Force quotes on non-expression time grains on Postgres Feb 18, 2019
@villebro villebro changed the title [WIP] Force quotes on non-expression time grains on Postgres Force quotes on non-expression time grains on Postgres Feb 18, 2019
@villebro
Copy link
Member Author

Added test cases for expression, lower_case and MixedCase column names that mimic what's going on in get_timestamp_expression()in sqla/models.py.

@rumbin
Copy link
Contributor

rumbin commented Feb 18, 2019

@villebro, thanks a lot for sorting this quoting issue out comprehensively

@villebro
Copy link
Member Author

FYI @mistercrunch rebased to resolve conflicts

@mistercrunch mistercrunch merged commit ea9d22b into apache:master Feb 21, 2019
@villebro villebro deleted the postgres_timegrain branch February 24, 2019 19:15
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 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 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Superset ignore case-sensitivity of time column names with Postgresql
4 participants