-
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: Fixing pinot query generation for date format conversion from python datetime format to java simple date format #13163
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13163 +/- ##
===========================================
+ Coverage 53.06% 67.45% +14.39%
===========================================
Files 489 492 +3
Lines 17314 29041 +11727
Branches 4482 0 -4482
===========================================
+ Hits 9187 19590 +10403
- Misses 8127 9451 +1324
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
0dfc4ab
to
d230927
Compare
dcb7a85
to
386b9e9
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.
Thanks for fixing again! Quick bycatch comment
@fx19880617 btw you may want to cherry pick this into your installation, as I believe this fix also affects Pinot: #13138 |
9f713ad
to
19766f5
Compare
Sure, is it on the latest docker image? |
a65185a
to
b5c011b
Compare
…datetime format to java simple date format
b5c011b
to
43732c3
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.
For completeness, could we also add an assertion for missing pdf
and invalid time grain spec?
it's already there on line 72 for pdf check and line 99 for time_grain check. |
Yes, I meant a simple unit test to test for those lines (sorry for being unclear). The reason I'm asking is Pinot is a fairly different connector compared to others, so I'd like to make sure we have good coverage for it to guard against regressions. |
890f147
to
892f67d
Compare
892f67d
to
851aa5d
Compare
tests/db_engine_specs/pinot_tests.py
Outdated
def test_invalid_get_time_expression_arguments(self): | ||
with self.assertRaises(NotImplementedError) as context: | ||
PinotEngineSpec.get_timestamp_expr(column("tstamp"), None, "P1M") | ||
self.assertEqual("Empty date format for 'tstamp'", str(context.exception)) |
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 this indented correctly? I'm fine removing the string comparison, testing for the raise is adequate IMO.
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.
I tried to use VS Code pylint plugin and black to format the python file, but both don't pass the python lint check here :(
The black cmd I'm running is
black -t py37 tests/db_engine_specs/pinot_tests.py
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.
I also tried:
NotImplementedError,
PinotEngineSpec.get_timestamp_expr(column("tstamp"), None, "P1M"),
)
but the test doesn't pass for this, hence I capture the exception and compare the string:
================================================================================================= FAILURES ==================================================================================================
_____________________________________________________________________ TestPinotDbEngineSpec.test_invalid_get_time_expression_arguments ______________________________________________________________________
self = <tests.db_engine_specs.pinot_tests.TestPinotDbEngineSpec testMethod=test_invalid_get_time_expression_arguments>
def test_invalid_get_time_expression_arguments(self):
self.assertRaises(
NotImplementedError,
> PinotEngineSpec.get_timestamp_expr(column("tstamp"), None, "P1M"),
)
tests/db_engine_specs/pinot_tests.py:71:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'superset.db_engine_specs.pinot.PinotEngineSpec'>, col = <sqlalchemy.sql.elements.ColumnClause at 0x11f54a5e0; tstamp>, pdf = None, time_grain = 'P1M', type_ = None
@classmethod
def get_timestamp_expr(
cls,
col: ColumnClause,
pdf: Optional[str],
time_grain: Optional[str],
type_: Optional[str] = None,
) -> TimestampExpression:
if not pdf:
> raise NotImplementedError(f"Empty date format for '{col}'")
E NotImplementedError: Empty date format for 'tstamp'
superset/db_engine_specs/pinot.py:72: NotImplementedError
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.
I tweaked the tests slightly and pushed to the branch, I hope you don't mind (if you don't agree with the changes please feel free to git reset --hard HEAD~1
!)
tests/db_engine_specs/pinot_tests.py
Outdated
self.assertEqual( | ||
"No pinot grain spec for 'invalid_grain'", str(context.exception) | ||
) |
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.
Same here
@fx19880617 let me know if my last change is ok by you - if so I can merge |
LGTM, thanks for fixing it @villebro |
SUMMARY
Fixing Pinot query generation converting DateTime format from python DateTime format to Java SimpleDate Format.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After:
Generated query and chart:
TEST PLAN
Adding unit test for query generation.
ADDITIONAL INFORMATION