hughhhh commented on code in PR #20793:
URL: https://github.com/apache/superset/pull/20793#discussion_r951586521
##########
superset/datasets/dao.py:
##########
@@ -367,6 +371,59 @@ def bulk_delete(models: Optional[List[SqlaTable]], commit:
bool = True) -> None:
db.session.rollback()
raise ex
+ @classmethod
+ def find_with_advanced_data_type(
+ cls, advanced_data_type: str
+ ) -> Dict[str, Dict[str, str]]:
+ query = None
+ if get_main_database().backend == "mysql":
+ query = (
+ db.session.query(
+ SqlaTable.id,
+ func.json_arrayagg(TableColumn.id),
+ func.json_arrayagg(TableColumn.verbose_name),
+ func.json_arrayagg(TableColumn.column_name),
+ )
+ .join(TableColumn, TableColumn.table_id == SqlaTable.id)
+ .filter(TableColumn.advanced_data_type == advanced_data_type)
+ .group_by(SqlaTable.id)
+ )
+ else:
+ query = (
+ db.session.query(
+ SqlaTable.id,
+ func.array_agg(TableColumn.id),
+ func.array_agg(TableColumn.verbose_name),
+ func.array_agg(TableColumn.column_name),
+ )
+ .join(TableColumn, TableColumn.table_id == SqlaTable.id)
+ .filter(TableColumn.advanced_data_type == advanced_data_type)
+ .group_by(SqlaTable.id)
+ )
+ query = cls.base_filter(
+ cls.id_column_name, SQLAInterface(cls.model_cls, db.session)
+ ).apply(query, None)
+ datasets = query.all()
+ print(datasets)
+ result = {}
+ for dataset in datasets:
+ column_id = dataset[1]
Review Comment:
instead of using idx to reference the values in the object can you annotate
with that actually columns values?
`dataset.column_id`
--
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]