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(sqla): Normalize prequery result type #17312

Merged

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Nov 1, 2021

SUMMARY

This PR fixes a regression introduced in #16795 as not all temporal columns are of type TIMESTAMP. The solution (as outlined in #16795 (comment)) uses the SQLA connector to convert the date time appropriately.

TESTING INSTRUCTIONS

Added unit tests and tested locally.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@codecov
Copy link

codecov bot commented Nov 1, 2021

Codecov Report

Merging #17312 (734de96) into master (79ed0ae) will increase coverage by 0.00%.
The diff coverage is 91.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #17312   +/-   ##
=======================================
  Coverage   77.09%   77.09%           
=======================================
  Files        1037     1037           
  Lines       55646    55650    +4     
  Branches     7607     7607           
=======================================
+ Hits        42900    42905    +5     
+ Misses      12496    12495    -1     
  Partials      250      250           
Flag Coverage Δ
hive 81.56% <91.66%> (+0.01%) ⬆️
mysql 81.98% <91.66%> (+0.01%) ⬆️
postgres 81.99% <91.66%> (+0.01%) ⬆️
presto 81.86% <91.66%> (+<0.01%) ⬆️
python 82.49% <91.66%> (+<0.01%) ⬆️
sqlite 81.67% <91.66%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/utils/core.py 90.09% <ø> (-0.05%) ⬇️
superset/connectors/sqla/models.py 87.86% <91.66%> (+0.46%) ⬆️
superset/db_engine_specs/presto.py 89.95% <0.00%> (-0.42%) ⬇️
superset/db_engine_specs/druid.py 86.27% <0.00%> (ø)

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 79ed0ae...734de96. Read the comment docs.

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.

I agree with the functional change of using the native column type as the basis of the conversion, thanks for the improvement. However, AFAIK the walrus operator will break Python 3.7 compatibility, so we should not use it before we remove explicit support for that version from setup.py.

column_ = columns_by_name[dimension]

if column_.type and column_.is_temporal and isinstance(value, str):
if result := self.db_engine_spec.convert_dttm(
Copy link
Member

Choose a reason for hiding this comment

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

As we still support Python 3.7, I don't think we can start using the walrus operator quite yet

@john-bodley john-bodley force-pushed the john-bodley--fix-_get_top_groups branch from 02eb304 to 734de96 Compare November 2, 2021 17:27
@john-bodley
Copy link
Member Author

@villebro thanks for the review. I've addressed your comments.

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.

LGTM 👍

@john-bodley john-bodley merged commit 36f489e into apache:master Nov 3, 2021
@john-bodley john-bodley deleted the john-bodley--fix-_get_top_groups branch November 3, 2021 20:59
AAfghahi pushed a commit that referenced this pull request Jan 10, 2022
Co-authored-by: John Bodley <john.bodley@airbnb.com>
@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 size/L 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants