kekwan commented on a change in pull request #13082:
URL: https://github.com/apache/superset/pull/13082#discussion_r574956996
##########
File path: superset/db_engine_specs/presto.py
##########
@@ -911,10 +912,14 @@ def where_latest_partition( # pylint:
disable=too-many-arguments
if values is None:
return None
- column_names = {column.get("name") for column in columns or []}
+ column_names = {column.get("name") : column.get('type') for column in
columns or []}
for col_name, value in zip(col_names, values):
if col_name in column_names:
- query = query.where(Column(col_name) == value)
+ col_type = column_names.get(col_name)
+ if col_type == 'TIMESTAMP':
Review comment:
Yeah, that would be ideal solution or getting Presto/Trino to support
auto-casting.
I've looked into it a bit and tried a few things but couldn't get any
auto-casting. I've tried to pass in the default SQLAlchemy data types e.g.
`types.TIMESTAMP` to the Column object as well as using a
[literal](https://docs.sqlalchemy.org/en/14/core/sqlelement.html#sqlalchemy.sql.expression.literal)
clause but the default data types doesn't seem to know how to auto-cast the
type of value. I'm guessing because each DB dialect casts types differently so
its up to the user to cast it yourself using one of these
[approaches](https://docs.sqlalchemy.org/en/13/core/custom_types.html#types-sql-value-processing)
to apply SQL-level binding
I have only done this casting for 2 Trino data types `TIMESTAMP` and `DATE`
in this PR since these are the most popular partition column data types for our
use case. But [all of these data types
](https://trino.io/docs/current/language/types.html) besides the basic string,
integer, boolean types require explicit casting so this is still an issue for
other data types.
----------------------------------------------------------------
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]