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

feat: 10/15/30 min grain to Pinot #19724

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions superset/db_engine_specs/pinot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
_time_grain_expressions: Dict[Optional[str], str] = {
"PT1S": "1:SECONDS",
"PT1M": "1:MINUTES",
"PT5M": "5:MINUTES",
"PT10M": "10:MINUTES",
"PT15M": "15:MINUTES",
"PT30M": "30:MINUTES",
"PT1H": "1:HOURS",
"P1D": "1:DAYS",
"P1W": "week",
Expand All @@ -53,6 +57,10 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
_use_date_trunc_function: Dict[str, bool] = {
"PT1S": False,
"PT1M": False,
"PT5M": False,
"PT10M": False,
"PT15M": False,
"PT30M": False,
"PT1H": False,
"P1D": False,
"P1W": True,
Expand Down
13 changes: 13 additions & 0 deletions tests/integration_tests/db_engine_specs/pinot_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ def test_pinot_time_expression_simple_date_format_1d_grain(self):
),
)

def test_pinot_time_expression_simple_date_format_10m_grain(self):
col = column("tstamp")
expr = PinotEngineSpec.get_timestamp_expr(col, "%Y-%m-%d %H:%M:%S", "PT10M")
result = str(expr.compile())
self.assertEqual(
result,
(
"DATETIMECONVERT(tstamp, "
+ "'1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss', "
+ "'1:SECONDS:SIMPLE_DATE_FORMAT:yyyy-MM-dd HH:mm:ss', '10:MINUTES')"
),
)

def test_pinot_time_expression_simple_date_format_1w_grain(self):
col = column("tstamp")
expr = PinotEngineSpec.get_timestamp_expr(col, "%Y-%m-%d %H:%M:%S", "P1W")
Expand Down