zhaoyongjie commented on code in PR #24942:
URL: https://github.com/apache/superset/pull/24942#discussion_r1290668187
##########
superset/connectors/sqla/models.py:
##########
@@ -1011,7 +1013,7 @@ def adhoc_column_to_sqla( # pylint:
disable=too-many-locals
if is_dttm and has_timegrain:
sqla_column = self.db_engine_spec.get_timestamp_expr(
col=sqla_column,
- pdf=None,
+ pdf=pdf,
Review Comment:
@ege-st
The design of current Pinot DB spec is completely incorrect. Maintaining our
own Pinot driver and db_spec should solve your issue.
```python
class PinotEngineSpec(BaseEngineSpec): # pylint: disable=abstract-method
engine = "pinot"
engine_name = "Apache Pinot"
allows_subqueries = False
allows_joins = False
allows_alias_in_select = True
allows_alias_in_orderby = False
#
https://docs.pinot.apache.org/users/user-guide-query/supported-transformations#datetime-functions
_time_grain_expressions = {
None: "{col}",
"PT1S": "CAST(DATE_TRUNC('second', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"PT1M": "CAST(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"PT5M": "CAST(ROUND(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)),
300000) as TIMESTAMP)",
"PT10M": "CAST(ROUND(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)),
600000) as TIMESTAMP)",
"PT15M": "CAST(ROUND(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)),
900000) as TIMESTAMP)",
"PT30M": "CAST(ROUND(DATE_TRUNC('minute', CAST({col} AS TIMESTAMP)),
1800000) as TIMESTAMP)",
"PT1H": "CAST(DATE_TRUNC('hour', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"P1D": "CAST(DATE_TRUNC('day', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"P1W": "CAST(DATE_TRUNC('week', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"P1M": "CAST(DATE_TRUNC('month', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"P3M": "CAST(DATE_TRUNC('quarter', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
"P1Y": "CAST(DATE_TRUNC('year', CAST({col} AS TIMESTAMP)) AS
TIMESTAMP)",
}
@classmethod
def column_datatype_to_string(
cls, sqla_column_type: TypeEngine, dialect: Dialect
) -> str:
# Pinot driver infers TIMESTAMP column as LONG, so make the quick
fix.
# When the Pinot driver fix this bug, current method could be
removed.
if isinstance(sqla_column_type, types.TIMESTAMP):
return sqla_column_type.compile().upper()
else:
return super().column_datatype_to_string(sqla_column_type,
dialect)
```
driver at: https://github.com/BurdaForward/pinot-dbapi/tree/bf_release
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]