-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: Handle python_date_format in ExploreMixin #24068
Conversation
Snap @betodealmeida this is the same logic as #24062. I've rebased my logic on your PR. I also added some unit tests as I realized these were missing. |
8012cf7
to
bd074d4
Compare
c4db792
to
6498420
Compare
superset/models/helpers.py
Outdated
"""Convert datetime object to a SQL expression string""" | ||
|
||
sql = ( | ||
self.db_engine_spec.convert_dttm(col_type, dttm, db_extra=None) | ||
if col_type | ||
self.db_engine_spec.convert_dttm(col.type, dttm, db_extra=col.db_extra) |
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.
In the TableColumn.dttm_sql_literal
method this the db_extra
is set. I gather it might have been set to None
previously for connivence/ease.
Sorry for not adding tests, this was blocking a release and we needed a quick fix. |
Codecov Report
@@ Coverage Diff @@
## master #24068 +/- ##
==========================================
+ Coverage 68.22% 68.25% +0.02%
==========================================
Files 1942 1942
Lines 75215 75192 -23
Branches 8145 8145
==========================================
+ Hits 51318 51322 +4
+ Misses 21812 21785 -27
Partials 2085 2085
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
6498420
to
cd38854
Compare
cd38854
to
3e36553
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.
LGTM
SUMMARY
This PR fixes an issue introduced in #20938 however it didn't surface until #22853 which resulted in a somewhat bad correctness regression as the resulting generated SQL was incorrect when filtering the temporal column, i.e., rather than queries being generated of the form,
they were being generated as:
which due to lexicographical ordering would wrongfully exclude any records where
ds
=2023-01-01
.The TL;DR is #20938 replicated logic from the
TableColumn
class however it did not include the logic which adhered to the Python date/time format meaning that columns which weren't handled by the DB engine specconvert_dttm
method were cast to an ISO 8601 formatted string adhering to theY-%m-%d %H:%M:%S.%f
format.This PR adds the missing logic and removes the now unused (per #22853)
TableColumn
methods to help improve the code hygiene and readability—having two or more instances of the same function makes the code very difficult to grok. @hughhhh I would suggest you perform a second pass to make sure all the legacy logic which was ported to theExploreMixin
has been removed.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Added unit tests which would have hopefully helped discovered the issue.
ADDITIONAL INFORMATION