-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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(trino): Fix Trino timestamp conversion #21737
Conversation
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.
Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️
We hope to see you in our Slack community too!
@john-bodley could you please take a look and approve CI? |
self.assertEqual( | ||
TrinoEngineSpec.convert_dttm("TIMESTAMP WITH TIME ZONE", dttm), | ||
"TIMESTAMP '2019-01-02 03:04:05.678900'", | ||
) |
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.
did you mean to use TIMESTAMP(3) WITH TIME ZONE
here instead?
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.
Indeed, my mistake!
I have tested this change and it addresses the timestamp filtering issue. |
2a07157
to
54236d3
Compare
thanks for the fix, approving CI. |
Codecov Report
@@ Coverage Diff @@
## master #21737 +/- ##
==========================================
+ Coverage 65.56% 66.86% +1.29%
==========================================
Files 1847 1847
Lines 70558 70558
Branches 7735 7735
==========================================
+ Hits 46264 47181 +917
+ Misses 22294 21377 -917
Partials 2000 2000
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 |
54236d3
to
91e04c5
Compare
@mayurnewase who needs to review this PR in order for it to be committed? |
91e04c5
to
cef7a1e
Compare
def test_convert_dttm(self): | ||
dttm = self.get_dttm() | ||
|
||
self.assertEqual( |
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.
Using assert
rather than self.assertEqual
is preferred in our pytest
/unittest
hybrid world.
tt = target_type.upper() | ||
if tt == utils.TemporalType.DATE: | ||
return f"DATE '{dttm.date().isoformat()}'" | ||
if re.sub(r"\(\d\)", "", tt) in ( |
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.
is there a reason this needs to be handled differently than the method already defined in PrestoBaseEngineSpec?
superset/superset/db_engine_specs/presto.py
Line 206 in 08f2c9b
if tt in ( |
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.
Trino exposes the precision in the temporal types, this is not covered in the Presto code (this is what's the bug was about)
@@ -47,6 +49,29 @@ class TrinoEngineSpec(PrestoBaseEngineSpec): | |||
engine = "trino" | |||
engine_name = "Trino" | |||
|
|||
@classmethod | |||
def convert_dttm( |
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.
Given that Presto and Trino have diverged in therms of their TIMESTAMP
functions I wonder if the PrestoBaseEngineSpec.convert_dttm
method should be moved to the PrestoEngineSpec
class.
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.
Makes sense. I'll take care of that.
@mdesmet Thank you so much for this PR! |
(cherry picked from commit 90d79c7)
SUMMARY
Remove timestamp precision for custom python dttm conversion.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION