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

refactor(pinot): The python_date_format for a temporal column was not being passed to get_timestamp_expr #24942

Merged
merged 27 commits into from
Aug 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix linting errors
ege-st committed Aug 17, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6e51f0422176e74da8e177195bb6d2501af4d18b
12 changes: 8 additions & 4 deletions superset/db_engine_specs/pinot.py
Original file line number Diff line number Diff line change
@@ -33,8 +33,10 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
# https://docs.pinot.apache.org/users/user-guide-query/supported-transformations#datetime-functions
_time_grain_expressions = {
None: "{col}",
TimeGrain.SECOND: "CAST(DATE_TRUNC('second', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.MINUTE: "CAST(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.SECOND: "CAST(DATE_TRUNC('second', "
+ "CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.MINUTE: "CAST(DATE_TRUNC('minute', "
+ "CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.FIVE_MINUTES: "CAST(ROUND(DATE_TRUNC('minute', "
+ "CAST({col} AS TIMESTAMP)), 300000) AS TIMESTAMP)",
TimeGrain.TEN_MINUTES: "CAST(ROUND(DATE_TRUNC('minute', "
@@ -46,8 +48,10 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
TimeGrain.HOUR: "CAST(DATE_TRUNC('hour', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.DAY: "CAST(DATE_TRUNC('day', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.WEEK: "CAST(DATE_TRUNC('week', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.MONTH: "CAST(DATE_TRUNC('month', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.QUARTER: "CAST(DATE_TRUNC('quarter', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.MONTH: "CAST(DATE_TRUNC('month', "
+ "CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.QUARTER: "CAST(DATE_TRUNC('quarter', "
+ "CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
TimeGrain.YEAR: "CAST(DATE_TRUNC('year', CAST({col} AS TIMESTAMP)) AS TIMESTAMP)",
}