mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
fix: pinot select query logic (#9954)
* Update how pinot handles selection logic * Change DATETIMECONVERT argument to use single quote for literals
This commit is contained in:
@@ -79,24 +79,18 @@ class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
|
||||
else:
|
||||
seconds_or_ms = "MILLISECONDS" if pdf == "epoch_ms" else "SECONDS"
|
||||
tf = f"1:{seconds_or_ms}:EPOCH"
|
||||
granularity = cls.get_time_grain_expressions().get(time_grain)
|
||||
if not granularity:
|
||||
raise NotImplementedError("No pinot grain spec for " + str(time_grain))
|
||||
if time_grain:
|
||||
granularity = cls.get_time_grain_expressions().get(time_grain)
|
||||
if not granularity:
|
||||
raise NotImplementedError("No pinot grain spec for " + str(time_grain))
|
||||
else:
|
||||
return TimestampExpression(f"{{col}}", col)
|
||||
# In pinot the output is a string since there is no timestamp column like pg
|
||||
time_expr = f'DATETIMECONVERT({{col}}, "{tf}", "{tf}", "{granularity}")'
|
||||
time_expr = f"DATETIMECONVERT({{col}}, '{tf}', '{tf}', '{granularity}')"
|
||||
return TimestampExpression(time_expr, col)
|
||||
|
||||
@classmethod
|
||||
def make_select_compatible(
|
||||
cls, groupby_exprs: Dict[str, ColumnElement], select_exprs: List[ColumnElement]
|
||||
) -> List[ColumnElement]:
|
||||
# Pinot does not want the group by expr's to appear in the select clause
|
||||
select_sans_groupby = []
|
||||
# We want identity and not equality, so doing the filtering manually
|
||||
for sel in select_exprs:
|
||||
for gr in groupby_exprs:
|
||||
if sel is gr:
|
||||
break
|
||||
else:
|
||||
select_sans_groupby.append(sel)
|
||||
return select_sans_groupby
|
||||
return select_exprs
|
||||
|
||||
Reference in New Issue
Block a user