zhaoyongjie commented on code in PR #24942:
URL: https://github.com/apache/superset/pull/24942#discussion_r1293810653


##########
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 It might be a potential bug in Apache Calcite that was the SQL 
parser in Pinot. It was not too hard to fix it in Pinot codebase, I remember 
this issue was existing some DB which is used Calcite as parser.
   
   Another option is add changes in Superset codes.
   
   ```python
   diff --git a/superset/connectors/sqla/models.py 
b/superset/connectors/sqla/models.py
   index 5c5f66853..1fcdff8e5 100644
   --- a/superset/connectors/sqla/models.py
   +++ b/superset/connectors/sqla/models.py
   @@ -1081,7 +1081,7 @@ class SqlaTable(Model, BaseDatasource):  # pylint: 
disable=too-many-public-metho
            # add quotes to tables
            if db_engine_spec.allows_alias_in_select:
                label = db_engine_spec.make_label_compatible(label_expected)
   -            sqla_col = sqla_col.label(label)
   +            sqla_col = 
sqla_col.label(db_engine_spec.alias_in_select_mutator(label))
            sqla_col.key = label_expected
            return sqla_col
   
   diff --git a/superset/db_engine_specs/base.py 
b/superset/db_engine_specs/base.py
   index df0552e8a..1d8e91482 100644
   --- a/superset/db_engine_specs/base.py
   +++ b/superset/db_engine_specs/base.py
   @@ -644,6 +644,10 @@ class BaseEngineSpec:  # pylint: 
disable=too-many-public-methods
                )
            )
   
   +    @staticmethod
   +    def alias_in_select_mutator(label: str) -> str:
   +        return label
   +
        @classmethod
        def fetch_data(
            cls, cursor: Any, limit: Optional[int] = None
   diff --git a/superset/db_engine_specs/pinot.py 
b/superset/db_engine_specs/pinot.py
   index d88fdf36f..d82bf8604 100644
   --- a/superset/db_engine_specs/pinot.py
   +++ b/superset/db_engine_specs/pinot.py
   @@ -26,7 +26,7 @@ class PinotEngineSpec(BaseEngineSpec):  # pylint: 
disable=abstract-method
        engine_name = "Apache Pinot"
        allows_subqueries = False
        allows_joins = False
   -    allows_alias_in_select = False
   +    allows_alias_in_select = True
        allows_alias_in_orderby = False
   
        # 
https://docs.pinot.apache.org/users/user-guide-query/supported-transformations#datetime-functions
   @@ -56,3 +56,7 @@ class PinotEngineSpec(BaseEngineSpec):  # pylint: 
disable=abstract-method
                return sqla_column_type.compile().upper()
            else:
                return super().column_datatype_to_string(sqla_column_type, 
dialect)
   +
   +    @staticmethod
   +    def alias_in_select_mutator(label: str) -> str:
   +        return f"{label}__"
   
   ```



-- 
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]

Reply via email to