-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect SELECT * statement previewing tables with timestamp partitions #13009
Comments
Hi, I ran into this same issue yesterday and after digging around the code I landed on a fix. In my case, the fields were coming back marked as I insert two lines to cover the if tt == utils.TemporalType.TIME:
return f"""from_iso8601_timestamp('{dttm.isoformat(timespec="microseconds")}')""" # pylint: disable=line-too-long As part of digging into this, I ran across the recently landed PR #12861 which might help here as well. |
Hey @tritonrc. I also fixed the issue but had a slightly different fix for my scenario. Issue 1 was our Presto Even this didn't fix our issue with previewing tables however. I believe Presto/Trino doesn't do automatic casting in
In order to do this, I implemented a TypeDecorator class which overrode existing functionality of the SQLA timestamp type and instantiated that class here when the column type is timestamp https://github.com/apache/superset/blob/master/superset/db_engine_specs/presto.py#L917 |
@kekwan can u share the code for the fix? |
@tooptoop4 Yup. I filed a PR #13082 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
Sounds like this was fixed, but never closed! |
When previewing a table in SQL Lab, a SELECT * statement is generated based on table data and table metadata if it contains partitions. When generating the SELECT * statement on a table with partitions, the table data, 'TIMESTAMP' in my case is not casted in the WHERE block.
Expected results
Previewing tables with data partitions should work. The WHERE block of the generated SELECT * statement should talk into account casting of data types, particularly TIMESTAMP.
Actual results
select_star
method callswhere_latest_partition
to generate WHERE block when partition exists.where_latest_partition
is failing to CAST data types needed for WHERE block causing syntax error when it runs the select * statement.SQL Statement generated by
get_table_metadata
callingselect_star
. Columnsdatetimepartition
andetl_ts
should be casted to TIMESTAMP, not VARCHAR.Syntax error from Presto due to the incorrect SQL statement
Presto error: Cannot apply operator: timestamp(3) = varchar(23)
Screenshots
How to reproduce the bug
Environment
0.37.2
python 3.6
Checklist
Make sure to follow these steps before submitting your issue - thank you!
The text was updated successfully, but these errors were encountered: