hughhhh commented on code in PR #20793:
URL: https://github.com/apache/superset/pull/20793#discussion_r946349601
##########
superset/advanced_data_type/api.py:
##########
@@ -146,3 +150,72 @@ def get_types(self) -> Response:
"""
return self.response(200, result=list(ADVANCED_DATA_TYPES.keys()))
+
+ @protect()
+ @safe
+ @expose("/datasets", methods=["GET"])
+ @permission_name("read")
+ @event_logger.log_this_with_context(
+ action=lambda self, *args, **kwargs: f"{self.__class__.__name__}.get",
+ log_to_statsd=False, # pylint: disable-arguments-renamed
+ )
+ @rison(advanced_data_type_datasets_schema)
+ def get_datasets(self, **kwargs: Any) -> Response:
+ """Get all datasets with a column of the specified advanced type
+ ---
+ get:
+ description:
+ Get all datasets with a column of the specified advanced type
+ parameters:
+ - in: query
+ name: q
+ content:
+ application/json:
+ schema:
+ $ref:
'#/components/schemas/advanced_data_type_datasets_schema'
+ responses:
+ 200:
+ description: Query result
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ result:
+ type: object
+ properties:
+ table_id:
+ type: array
+ items:
+ type: integer
+ 401:
+ $ref: '#/components/responses/401'
+ 404:
+ $ref: '#/components/responses/404'
+ 500:
+ $ref: '#/components/responses/500'
+ """
+ item = kwargs["rison"]
+ advanced_data_type = item["type"]
+ columns = (
+ db.session.query(TableColumn.table_id, TableColumn.id)
Review Comment:
couldn't we just do a join here
```
db.session.query(SqlaTable).join(TableColumn, TableColumn.table_id ==
SqlaTable.id).filter(TableColumn.advanced_data_type ==
advanced_data_type).distinct()
```
This should return the list of all the `SqlaTable`s with the filter
`advanced_data_type`
--
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]