-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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): replace custom dttm type with literal_column #19917
fix(sqla): replace custom dttm type with literal_column #19917
Conversation
1d34e59
to
c77c5aa
Compare
Codecov Report
@@ Coverage Diff @@
## master #19917 +/- ##
==========================================
- Coverage 66.52% 66.34% -0.19%
==========================================
Files 1714 1713 -1
Lines 65052 65035 -17
Branches 6722 6722
==========================================
- Hits 43279 43148 -131
- Misses 20061 20175 +114
Partials 1712 1712
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
c77c5aa
to
b8c4c7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed fix works using a presto connection, date column is correctly identified as Date
type and time filters work now.
(cherry picked from commit 99f1f9e)
(cherry picked from commit 99f1f9e)
SUMMARY
Some time ago #13622 introduced support for emitting temporal filters from native/cross filters. This caused a regression that was fixed in #16634, which itself caused another regression #17143. The original feature, which relied on creating a custom temporal type that can be used to compile temporal expressions in SQLAlchemy queries proved to be problematic, in part due to the fact that it required using the
DATETIME
type which isn't natvely supported by Presto.For these types of use cases, the documentation recommends creating a custom class that extends
TypeDecorator
and implementingprocess_bind_param
and/orprocess_literal_value
: https://docs.sqlalchemy.org/en/14/core/custom_types.html#typedecorator-recipes. However, during testing this was shown to not work universally, as some dialects expected the return value to be adate
/datetime
, while others expected it to always be astr
.A simpler and universally supported solution is to just use
literal_column
. This simplifies the codebase and should ensure that temporal adhoc filters always work. The temporal conversion functions for Presto, Trino and Athena are also updated to use the recommended casts from the docs (note howfrom_iso8601_*
is no longer recommended):Note that this change might be seen as making the
filter_values_handler
helper function slightly messy with the added arguments. However, the function can be streamlined once the native Druid connector is removed and the helper can be made more specific to the SQLAlchemy model.This PR doesn't add new tests, as this test covers these changes:
superset/tests/integration_tests/charts/data/api_tests.py
Lines 359 to 397 in aff10a7
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION