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): support for date adhoc filter #16634

Merged
merged 1 commit into from
Sep 9, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 8, 2021

SUMMARY

When sending a temporal Native Value Filter to a chart with a DATE column, the query errors out. This is due all temporal filters being encoded as datetime.datetime objects, irrespective of the target column being DATE, DATETIME or TIMESTAMP (we handle formatting of the temporal value in BaseEngineSpec.convert_dttm). This error is due to the SqlAlchemy Date and Datetime column types not being able to handle datetime and date objects respectively.

This PR replaces the SqlAlchemy Date type with DateTime, making it compatible with the logic in sqla/models.py.

AFTER

image

BEFORE

image
image

TESTING INSTRUCTIONS

  1. create a chart from a datasource that has a temporal column with DATE type
  2. Add it to a dashboard and create a Value Filter referencing the DATE column
  3. Emit a filter
  4. See error

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 Sep 8, 2021

Codecov Report

Merging #16634 (f6b47a5) into master (519baa6) will decrease coverage by 0.26%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16634      +/-   ##
==========================================
- Coverage   76.77%   76.51%   -0.27%     
==========================================
  Files        1003     1003              
  Lines       53959    53959              
  Branches     7330     7330              
==========================================
- Hits        41427    41286     -141     
- Misses      12293    12434     +141     
  Partials      239      239              
Flag Coverage Δ
hive ?
mysql ?
postgres 81.56% <ø> (-0.04%) ⬇️
presto ?
python 81.60% <ø> (-0.51%) ⬇️
sqlite 81.21% <ø> (ø)

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

Impacted Files Coverage Δ
superset/db_engine_specs/base.py 88.00% <ø> (-0.39%) ⬇️
superset/db_engine_specs/presto.py 83.47% <ø> (-6.91%) ⬇️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
superset/db_engine_specs/mysql.py 94.04% <0.00%> (-3.58%) ⬇️
superset/utils/date_parser.py 93.17% <0.00%> (-3.42%) ⬇️
superset/common/query_context.py 88.88% <0.00%> (-1.86%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/connectors/sqla/models.py 88.04% <0.00%> (-1.66%) ⬇️
... and 5 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 519baa6...f6b47a5. Read the comment docs.

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

LGTM

@villebro villebro merged commit 6465ee7 into apache:master Sep 9, 2021
@villebro villebro deleted the villebro/dttm-type branch September 9, 2021 03:41
villebro added a commit that referenced this pull request Sep 22, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
@mistercrunch mistercrunch added 🍒 1.3.1 🍒 1.3.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.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-io size/XS v1.3 🍒 1.3.1 🍒 1.3.2 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants