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(trino): Fix Trino timestamp conversion #21737

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

mdesmet
Copy link
Contributor

@mdesmet mdesmet commented Oct 7, 2022

SUMMARY

Remove timestamp precision for custom python dttm conversion.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

Copy link
Contributor

@github-actions github-actions bot left a 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!

@hovaesco
Copy link

@john-bodley could you please take a look and approve CI?

Comment on lines 190 to 193
self.assertEqual(
TrinoEngineSpec.convert_dttm("TIMESTAMP WITH TIME ZONE", dttm),
"TIMESTAMP '2019-01-02 03:04:05.678900'",
)
Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, my mistake!

@georgewfisher
Copy link

I have tested this change and it addresses the timestamp filtering issue.

@mdesmet mdesmet force-pushed the bug/trino-convert_dttm branch from 2a07157 to 54236d3 Compare October 13, 2022 13:15
@mayurnewase
Copy link
Contributor

thanks for the fix, approving CI.

@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #21737 (08f2c9b) into master (60a617e) will increase coverage by 1.29%.
The diff coverage is n/a.

❗ Current head 08f2c9b differs from pull request most recent head cef7a1e. Consider uploading reports for the commit cef7a1e to get more accurate results

@@            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              
Flag Coverage Δ
hive 52.53% <ø> (ø)
javascript 53.83% <ø> (ø)
mysql 77.95% <ø> (ø)
postgres 78.02% <ø> (ø)
presto 52.42% <ø> (ø)
python 81.23% <ø> (+2.73%) ⬆️
sqlite 76.48% <ø> (ø)
unit 50.91% <ø> (?)

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

Impacted Files Coverage Δ
...rontend/src/views/CRUD/dashboard/DashboardList.tsx 56.60% <ø> (ø)
superset/databases/api.py 93.53% <0.00%> (+0.30%) ⬆️
superset/sql_lab.py 82.12% <0.00%> (+0.38%) ⬆️
superset/views/base_api.py 98.44% <0.00%> (+0.38%) ⬆️
superset/db_engine_specs/presto.py 88.22% <0.00%> (+0.41%) ⬆️
superset/db_engine_specs/__init__.py 85.71% <0.00%> (+1.19%) ⬆️
superset/datasets/schemas.py 97.40% <0.00%> (+1.29%) ⬆️
superset/commands/exceptions.py 93.84% <0.00%> (+1.53%) ⬆️
superset/initialization/__init__.py 90.96% <0.00%> (+2.00%) ⬆️
superset/utils/log.py 93.91% <0.00%> (+2.02%) ⬆️
... and 54 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mdesmet mdesmet force-pushed the bug/trino-convert_dttm branch from 54236d3 to 91e04c5 Compare November 14, 2022 14:30
@georgewfisher
Copy link

@mayurnewase who needs to review this PR in order for it to be committed?

def test_convert_dttm(self):
dttm = self.get_dttm()

self.assertEqual(
Copy link
Member

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 (
Copy link
Member

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?

Copy link
Contributor Author

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(
Copy link
Member

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.

Copy link
Contributor Author

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.

@EugeneTorap
Copy link
Contributor

EugeneTorap commented Dec 8, 2022

@mdesmet Thank you so much for this PR!
Can update the description and use Fix before the ticket link in order to auto close these two tickets after PR merging

@rusackas rusackas merged commit 90d79c7 into apache:master Dec 14, 2022
@mdesmet mdesmet deleted the bug/trino-convert_dttm branch December 14, 2022 18:33
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Jan 18, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.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/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants