SEPURI-SAI-KRISHNA commented on code in PR #43206:
URL: https://github.com/apache/superset/pull/43206#discussion_r3788720756
##########
superset/charts/schemas.py:
##########
@@ -677,15 +677,28 @@ class
ChartDataSortOptionsSchema(ChartDataPostProcessingOperationOptionsSchema):
Sort operation config.
"""
- columns = fields.Dict(
+ is_sort_index = fields.Boolean(
metadata={
- "description": "columns by by which to sort. The key specifies the
column "
- "name, value specifies if sorting in ascending order.",
- "example": {"country": True, "gender": False},
+ "description": "Whether to sort by the index rather than by column
values.",
+ "example": True,
+ },
+ )
+ by = fields.Raw(
+ # TODO: add correct union type once supported by Marshmallow
+ metadata={
+ "description": "Name, or list of names, of the columns to sort by.
"
+ "Ignored when `is_sort_index` is set.",
+ "example": "country",
+ },
+ )
+ ascending = fields.Raw(
+ # TODO: add correct union type once supported by Marshmallow
+ metadata={
+ "description": "Sort ascending (the default) or descending. A list
of "
+ "booleans may be given to set the direction per entry in `by`.",
+ "example": True,
},
Review Comment:
Accurate, but pre-existing and orthogonal. Nothing validates options at all,
ChartDataPostProcessingOperationOptionsSchema.options is a bare fields.Dict, so
these per-operation
schemas are documentation, not enforcement, as the PR description notes.
Tightening by/ascending here wouldn't close the hole, since a client can send
any dict regardless.
fields.Raw also matches the existing convention for union-typed options in
this file, yearly_seasonality and weekly_seasonality use it with the same #
TODO: add correct union type once supported by Marshmallow note. Making the
dispatch reject malformed options with a 400 instead of a TypeError is a
separate change to exec_post_processing.
--
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]