Open rikirolly opened 1 year ago
I'm getting the same error with the same stack. Superset + Trino + Datetime partitions
Just in case someone googles this bug, I was able to fix it. It is not pretty but it works. The bug is in the file superset/db_engine_specs/presto.py
in the definition of the method latest_partition()
. In my case, my datetime partition column is named dl_date
so when I receive this column I change the type from datetime.date to string and recreate the dataframe.
def latest_partition(
cls,
table_name: str,
schema: Optional[str],
database: Database,
show_first: bool = False,
) -> Tuple[List[str], Optional[List[str]]]:
.
.
.
.
column_names = indexes[0]["column_names"]
part_fields = [(column_name, True) for column_name in column_names]
sql = cls._partition_query(table_name, database, 1, part_fields)
df = database.get_df(sql, schema)
#========== MY UGLY FIX ==========#
if "dl_date" in column_names:
lat_df = cls._latest_partition_from_df(df)
dl_date: date = lat_df[2]
return column_names, [lat_df[0], lat_df[1], dl_date.strftime("%Y-%m-%d")]
else:
return column_names, cls._latest_partition_from_df(df)
#========== MY UGLY FIX ==========#
@davinavarro do you think there's a more generalized way to fix this that would work as a PR? Tempted to close this as stale and somewhat-solved, but wondering if there's a better solution here. CC @nytai @john-bodley since it's Trino-tastic.
Curious if @dosu-bot can provide a suggestion for a permanent/generalized fix, or even a diff for a PR.
Creating a dataset from a Trino table I get this error:
How to reproduce the bug
Probably just creating a dataset starting from a Trino table with a datetime.date column. In my case this column is also a partition.
Expected results
Correctly create the dataset.
Actual results
Superset report the error: Unable to load columns for the selected table. Please select a different table.
Screenshots
Environment
111.0.5563.146 (Official Build) (64-bit)
2.1.0
https://apache.github.io/superset
0.9.2
416
Checklist
Make sure to follow these steps before submitting your issue - thank you!
Additional context
I have already created different dataset in the same format and always worked correctly, I do not know if this could be a new bug of the latest release.