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

* add new grains to pinot

* update test
This commit is contained in:
Hugh A. Miles II 2022-04-19 11:16:48 -07:00 committed by GitHub
parent 7e92340c70
commit a6f46013d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -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",
@ -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,

View File

@ -45,6 +45,19 @@ class TestPinotDbEngineSpec(TestDbEngineSpec):
),
)
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")