Copilot commented on code in PR #42410:
URL: https://github.com/apache/superset/pull/42410#discussion_r3659561267
##########
tests/unit_tests/queries/query_object_test.py:
##########
@@ -371,3 +374,29 @@ def
test_cache_key_cache_impersonation_on_with_different_user_and_db_impersonati
],
any_order=True,
)
+
+
+def test_exec_post_processing_unsupported_operation():
+ """
+ An unknown post processing operation must surface as
+ InvalidPostProcessingError, naming the offending operation.
+ """
+ query_object = QueryObject(
+ row_limit=1,
+ post_processing=[{"operation": "not_a_real_operation"}],
+ )
+
+ with pytest.raises(InvalidPostProcessingError) as excinfo:
+ query_object.exec_post_processing(DataFrame({"y": [1, 2, 3]}))
+
+ assert "not_a_real_operation" in str(excinfo.value.message)
Review Comment:
This assertion couples the test to an exception `.message` attribute. To
make the test more robust against exception implementation changes, assert
against `str(excinfo.value)` (or another stable public API) instead of
`.message`.
##########
superset/utils/pandas_postprocessing/select.py:
##########
@@ -48,6 +51,13 @@ def select(
if columns:
df_select = df_select[columns]
if exclude:
+ # `exclude` is validated against the incoming DataFrame by the
decorator, but
+ # a preceding `columns` selection may already have removed the column.
Reject
+ # that as a validation error instead of letting pandas raise a bare
KeyError.
+ if any(column not in df_select.columns for column in exclude):
+ raise InvalidPostProcessingError(
+ _("Referenced columns not available in DataFrame.")
+ )
Review Comment:
The new validation error message is too generic and makes it hard to
diagnose which `exclude` entries are invalid (especially when the failure is
due to a preceding `columns` projection). Consider including the missing column
name(s) in the message (e.g., list the missing entries from `exclude`) so users
can quickly correct the request payload.
--
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]