john-bodley commented on a change in pull request #13082:
URL: https://github.com/apache/superset/pull/13082#discussion_r582423692
##########
File path: superset/models/sql_types/presto_sql_types.py
##########
@@ -91,3 +95,35 @@ def python_type(self) -> Optional[Type[Any]]:
@classmethod
def _compiler_dispatch(cls, _visitor: Visitable, **_kw: Any) -> str:
return "ROW"
+
+
+class TimeStamp(TypeDecorator):
+ """
+ A type to extend functionality of timestamp data type.
+ """
+
+ impl = TIMESTAMP
+
+ @classmethod
+ def process_bind_param(cls, value: str, dialect: Dialect) -> str:
+ """
+ Used for in-line rendering of TIMESTAMP data type
+ as Presto does not support automatic casting.
+ """
+ return "TIMESTAMP '%s'" % value
Review comment:
Sorry for not picking this up sooner (and surprised `pylint` didn't).
This type of string formatting is dated could we use the suggestion instead?
```suggestion
return f"TIMESTAMP '{value}'"
```
##########
File path: superset/models/sql_types/presto_sql_types.py
##########
@@ -91,3 +95,35 @@ def python_type(self) -> Optional[Type[Any]]:
@classmethod
def _compiler_dispatch(cls, _visitor: Visitable, **_kw: Any) -> str:
return "ROW"
+
+
+class TimeStamp(TypeDecorator):
+ """
+ A type to extend functionality of timestamp data type.
+ """
+
+ impl = TIMESTAMP
+
+ @classmethod
+ def process_bind_param(cls, value: str, dialect: Dialect) -> str:
+ """
+ Used for in-line rendering of TIMESTAMP data type
+ as Presto does not support automatic casting.
+ """
+ return "TIMESTAMP '%s'" % value
+
+
+class Date(TypeDecorator):
+ """
+ A type to extend functionality of date data type.
+ """
+
+ impl = DATE
+
+ @classmethod
+ def process_bind_param(cls, value: str, dialect: Dialect) -> str:
+ """
+ Used for in-line rendering of DATE data type
+ as Presto does not support automatic casting.
+ """
+ return "DATE '%s'" % value
Review comment:
```suggestion
return f"DATE '{value}'"
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]