eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r904095207
##########
superset/utils/core.py:
##########
@@ -1648,21 +1648,35 @@ def extract_dataframe_dtypes(
"date": GenericDataType.TEMPORAL,
}
- columns_by_name = (
- {column.column_name: column for column in datasource.columns}
- if datasource
- else {}
- )
+ # todo(hughhhh): can we make the column_object a Union
+ if datasource and datasource.type == "query":
+ columns_by_name = {
+ column.get("column_name"): column for column in datasource.columns
+ }
+ else:
+ columns_by_name = (
+ {column.column_name: column for column in datasource.columns}
+ if datasource
+ else {}
+ )
+
generic_types: List[GenericDataType] = []
for column in df.columns:
column_object = columns_by_name.get(column)
series = df[column]
inferred_type = infer_dtype(series)
- generic_type = (
- GenericDataType.TEMPORAL
- if column_object and column_object.is_dttm
- else inferred_type_map.get(inferred_type, GenericDataType.STRING)
- )
+ if datasource and datasource.type == "query": # type: ignore
Review Comment:
same re: duck typing
--
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]