-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
feat: handle temporal columns in group bys #16795
Conversation
d6fe1eb
to
696b971
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 - just needs a rebase
@classmethod | ||
def epoch_to_dttm(cls) -> str: | ||
""" | ||
Convert from number of seconds since the epoch to a timestamp. | ||
""" | ||
return "MILLIS_TO_TIMESTAMP({col} * 1000)" | ||
|
||
@classmethod | ||
def epoch_ms_to_dttm(cls) -> str: | ||
""" | ||
Convert from number of milliseconds since the epoch to a timestamp. | ||
""" | ||
return "MILLIS_TO_TIMESTAMP({col})" |
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.
Oh wow, I didn't know these weren't defined yet for Druid!
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.
Yeah, I implemented epoch_to_dttm
while working on a solution, and decided to leave it there even if I wasn't using it, and add epoch_ms_to_dttm
for completeness.
696b971
to
6bc4df0
Compare
@betodealmeida and @villebro I don't believe this logic works for all cases. You could have a temporal field which is encoded as a string per the Python date format which shouldn't be converted to a Isn't the correct logic to use the type of the column rather than assuming it's a if column_map[dimension].is_temporal and and isinstance(value, str):
if result := self.db_engine_spec.convert_dttm(
column_map[dimension].type,
dateutil.parser.parse(value),
):
value = text(result) |
@betodealmeida I have proposed a fix in #17312. |
* feat: handle temporal columns in group bys * Rebase
* feat: handle temporal columns in group bys * Rebase
SUMMARY
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Query before was invalid:
Query after:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION