Skip to content

fix(postprocessing): keep operation signatures visible through validate_column_args - #43186

Open
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/postprocessing-preserve-signature
Open

fix(postprocessing): keep operation signatures visible through validate_column_args#43186
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/postprocessing-preserve-signature

Conversation

@bikash-barnwal

Copy link
Copy Markdown

SUMMARY

validate_column_args returned a bare wrapped(df, **options) without functools.wraps, so every decorated post-processing operation lost its __name__, __doc__ and signature. inspect.signature(pandas_postprocessing.pivot) reported the wrapper's (df, **options) catch-all rather than index, aggregates and the rest — every operation looked like it accepts arbitrary keywords.

That matters beyond tidiness. As #42926 describes, a chart's stored query_context is never migrated, so it can carry options an operation has since dropped — pivot no longer takes flatten_columns or reset_index — and replaying one raises TypeError from deep inside pandas on every non-Explore path (chart data API, alerts and reports, thumbnails, cache warm-up, CSV/Excel export, MCP tools). Any attempt to spot a stale option by introspection needs the real signature to be reachable first, and the missing wraps is precisely what hides it.

Scope: this is the secondary defect called out in #42926. The missing query_context migration itself is not addressed here — that is a larger design question also tracked in #33152 and #31872 — so this says Addresses rather than Fixes and leaves the issue open.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

>>> inspect.signature(pandas_postprocessing.pivot)
(df: DataFrame, **options: Any)                       # before
(df, index, aggregates, columns=None, metric_fill_value=None, ...)   # after

TESTING INSTRUCTIONS

pytest tests/unit_tests/utils/pandas_postprocessing/validate_column_args_tests.py
pytest tests/unit_tests/pandas_postprocessing tests/unit_tests/utils/pandas_postprocessing

New tests assert the operation keeps its name and docstring, that its real parameters are introspectable, that the removed flatten_columns / reset_index are visibly absent, and that column validation still rejects unknown columns. Locally: 4 passed for the new file and 110 passed across the post-processing suites.

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

…te_column_args

validate_column_args returned a bare `wrapped(df, **options)` without
functools.wraps, so every decorated post-processing operation lost its name,
docstring and signature. `inspect.signature(pandas_postprocessing.pivot)`
reported the wrapper's catch-all instead of `index`, `aggregates` and friends,
which makes each operation look like it accepts arbitrary keywords.

That matters beyond tidiness: a chart's stored query_context is never migrated,
so it can carry options an operation has since dropped -- `pivot` no longer
takes `flatten_columns` or `reset_index` -- and replaying one raises TypeError
from deep inside pandas. Any attempt to detect a stale option by introspection
first needs the real signature to be reachable.

This is the secondary defect described in apache#42926; the missing query_context
migration itself is not addressed here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b7ec1b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: efef806..efef806
    • superset/utils/pandas_postprocessing/utils.py
    • tests/unit_tests/utils/pandas_postprocessing/validate_column_args_tests.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.65%. Comparing base (0a7ebe1) to head (efef806).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43186      +/-   ##
==========================================
- Coverage   66.70%   66.65%   -0.06%     
==========================================
  Files        2872     2873       +1     
  Lines      163447   163607     +160     
  Branches    37727    37763      +36     
==========================================
+ Hits       109027   109051      +24     
- Misses      52291    52426     +135     
- Partials     2129     2130       +1     
Flag Coverage Δ
hive 38.17% <100.00%> (-0.05%) ⬇️
mysql 57.84% <100.00%> (-0.09%) ⬇️
postgres 57.87% <100.00%> (-0.09%) ⬇️
presto 40.12% <100.00%> (-0.05%) ⬇️
python 59.26% <100.00%> (-0.09%) ⬇️
sqlite 57.51% <100.00%> (-0.09%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants