sadpandajoe commented on code in PR #43337:
URL: https://github.com/apache/superset/pull/43337#discussion_r3817481834
##########
superset/charts/schemas.py:
##########
@@ -972,21 +979,31 @@ class ChartDataGeodeticParseOptionsSchema(
class ChartDataPostProcessingOperationSchema(Schema):
+ _builtin_ops = pandas_postprocessing.__all__
+
operation = fields.String(
metadata={
"description": "Post processing operation type",
"example": "aggregate",
},
required=True,
- validate=validate.OneOf(
- choices=[
- name
- for name, value in inspect.getmembers(
- pandas_postprocessing, inspect.isfunction
- )
- ]
- ),
)
+
+ @validates("operation")
+ def validate_operation(self, value: str, **kwargs: object) -> None:
+ from flask import current_app
+
+ extra_op_names = list(
+ pandas_postprocessing.build_extra_ops_map(
+ current_app.config.get("EXTRA_PANDAS_POSTPROCESSING_OPS", [])
Review Comment:
Validating even built-in operations now dereferences `current_app`, so
callers that load chart query schemas outside an app context fail with
`RuntimeError` where they previously succeeded. Could this only read the
extra-op config when needed, or handle the missing context like the neighboring
config-backed validators?
##########
superset/common/query_object.py:
##########
@@ -545,12 +546,19 @@ def exec_post_processing(self, df: DataFrame) ->
DataFrame:
_("`operation` property of post processing object
undefined")
)
if not hasattr(pandas_postprocessing, operation):
Review Comment:
An extra callable named `build_extra_ops_map` passes validation and the
startup collision check, but `hasattr` treats the helper as built-in and
invokes it instead of the configured callable. Could this dispatch only names
in `__all__` before looking in `extra_ops`?
--
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]