You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/12/09 11:01:19 UTC
[GitHub] [superset] dpgaspar commented on a diff in pull request #22332: chore(datasets): Add /api/v1/dataset/{pk}/[column|metric] endpoints
dpgaspar commented on code in PR #22332:
URL: https://github.com/apache/superset/pull/22332#discussion_r1044335731
##########
superset/datasets/columns/api.py:
##########
@@ -36,14 +38,99 @@
class DatasetColumnsRestApi(BaseSupersetModelRestApi):
datamodel = SQLAInterface(TableColumn)
- include_route_methods = {"delete"}
+ allow_browser_login = True
class_permission_name = "Dataset"
+ include_route_methods = {RouteMethod.DELETE, RouteMethod.GET, RouteMethod.GET_LIST}
method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
-
+ list_columns = [ # See DatasetRestApi.show_select_columns.
+ "advanced_data_type",
+ "changed_on",
+ "column_name",
+ "created_on",
+ "description",
+ "expression",
+ "filterable",
+ "groupby",
+ "id",
+ "is_active",
+ "extra",
+ "is_dttm",
+ "python_date_format",
+ "type",
+ "uuid",
+ "verbose_name",
+ ]
+ search_columns = ["table_id"]
+ max_page_size = -1
+ openapi_spec_tag = "Datasets"
resource_name = "dataset"
- allow_browser_login = True
- openapi_spec_tag = "Datasets"
+ @expose("/<int:pk>/column", methods=["GET"])
+ @protect()
+ @safe
+ @permission_name("get")
+ @rison(get_list_schema)
+ def get_list( # pylint: disable=arguments-differ
+ self,
+ pk: int,
+ **kwargs: Any,
+ ) -> Response:
+ """Get a list of dataset columns
+ ---
+ get:
+ description: >-
+ Get a list of dataset columns
+ parameters:
+ - in: path
+ schema:
+ type: integer
+ description: The dataset id for these columns
+ name: pk
+ - in: query
+ name: q
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/get_list_schema'
+ responses:
+ 200:
+ description: Columns from dataset
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ ids:
+ description: >-
+ A list of column ids
+ type: array
+ items:
+ type: string
+ count:
+ description: >-
+ The total record count on the backend
+ type: number
+ result:
+ description: >-
+ The result from the get list query
+ type: array
+ items:
+ $ref: '#/components/schemas/{{self.__class__.__name__}}.get_list' # pylint: disable=line-too-long
+ 400:
+ $ref: '#/components/responses/400'
+ 401:
+ $ref: '#/components/responses/401'
+ 422:
+ $ref: '#/components/responses/422'
+ 500:
+ $ref: '#/components/responses/500'
+ """
+
+ rison_data = kwargs.setdefault("rison", {})
+ rison_data.setdefault("filters", [])
+ rison_data["filters"].append({"col": "table_id", "opr": "eq", "value": pk})
+ rison_data["page_size"] = -1
+ return self.get_list_headless(**kwargs)
Review Comment:
I Agree let's refactor this after. Still think we need to apply the `DatasourceFilter` here, have you checked it?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org