You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "eschutho (via GitHub)" <gi...@apache.org> on 2026/09/20 16:52:46 UTC

[PR] fix(chart): wrap raw pandas TypeError/DataError from post-processing as QueryObjectValidationError [superset]

eschutho opened a new pull request, #44463:
URL: https://github.com/apache/superset/pull/44463

   ### SUMMARY
   
   Post-processing operators (e.g. `resample`) dispatched by `exec_post_processing` in `ExploreMixin.get_query_result` can raise raw `TypeError` or `pandas.errors.DataError` from their underlying pandas calls when the DataFrame contains non-numeric (object-dtype) columns alongside numeric metrics.
   
   **Example**: `resample` with `method="mean"` on a DataFrame that includes a string dimension column causes `df.resample(rule).mean()` to raise `TypeError: agg function failed [how->mean,dtype->object]`. Similarly, `rolling` with non-numeric columns raises `pandas.errors.DataError: Cannot aggregate non-numeric type: object`.
   
   The existing `except InvalidPostProcessingError` clause does not catch these raw exceptions, so they propagate through the chart-data REST API path and produce an opaque 500 instead of a clean 400.
   
   **Fix**: Widen the `except` in `get_query_result` to also catch `TypeError` and `pd.errors.DataError` and re-raise them as `QueryObjectValidationError` with the same 400 semantics as the existing arm. This is a two-line additive change at the call-site boundary — no operator internals modified.
   
   Precedent: apache/superset#43081 and apache/superset#44011 follow the same "wrap raw exception as `QueryObjectValidationError` at a chart-data boundary" pattern.
   
   Note for future: `superset/semantic_layers/models.py:364` has the identical narrow-catch pattern and is a candidate for a follow-up fix.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — backend-only fix; error response changes from HTTP 500 to HTTP 400 with a human-readable message.
   
   ### TESTING INSTRUCTIONS
   
   1. Regression test added in `tests/unit_tests/models/helpers_test.py::test_get_query_result_wraps_post_processing_type_error`.
   2. The test uses a `QueryObject` with `post_processing=[{"operation": "resample", "options": {"method": "mean", "rule": "1D"}}]` on a DataFrame with a DatetimeIndex and an `object`-dtype column. Without the fix the test fails with `TypeError`; with the fix it asserts `QueryObjectValidationError` is raised.
   3. Run: `pytest tests/unit_tests/models/helpers_test.py::test_get_query_result_wraps_post_processing_type_error`
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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


Re: [PR] fix(chart): wrap raw pandas TypeError/DataError from post-processing as QueryObjectValidationError [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44463:
URL: https://github.com/apache/superset/pull/44463#issuecomment-5751255422

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44463?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `2 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 57.34%. Comparing base ([`4511c13`](https://app.codecov.io/gh/apache/superset/commit/4511c1381930ec53cd74c1e25c3ad4397768e2b4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`91bcff4`](https://app.codecov.io/gh/apache/superset/commit/91bcff4c452f558bf526a05d0655f3f1e0f1405a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44463?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/models/helpers.py](https://app.codecov.io/gh/apache/superset/pull/44463?src=pr&el=tree&filepath=superset%2Fmodels%2Fhelpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44463?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (4511c13) and HEAD (91bcff4). Click for more details.
   > 
   > <details><summary>HEAD has 126 uploads less than BASE</summary>
   >
   >| Flag | BASE (4511c13) | HEAD (91bcff4) |
   >|------|------|------|
   >|python|98|2|
   >|presto|16|1|
   >|hive|16|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #44463       +/-   ##
   ===========================================
   - Coverage   80.65%   57.34%   -23.32%     
   ===========================================
     Files        2942     2942               
     Lines      175692   175694        +2     
     Branches    40788    40788               
   ===========================================
   - Hits       141705   100750    -40955     
   - Misses      31325    73984    +42659     
   + Partials     2662      960     -1702     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `37.15% <0.00%> (-0.01%)` | :arrow_down: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.03% <0.00%> (-0.01%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.08% <0.00%> (-45.88%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/44463/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44463?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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


Re: [PR] fix(chart): wrap raw pandas TypeError/DataError from post-processing as QueryObjectValidationError [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44463:
URL: https://github.com/apache/superset/pull/44463#issuecomment-5751219880

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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


Re: [PR] fix(chart): wrap raw pandas TypeError/DataError from post-processing as QueryObjectValidationError [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #44463:
URL: https://github.com/apache/superset/pull/44463#issuecomment-5751263668

   @richardfogaca — chart-data post-processing exception wrapping, your area (#43081 precedent). Straightforward two-line fix to catch raw `TypeError`/`DataError` from pandas operators in `get_query_result`.


-- 
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


Re: [PR] fix(chart): wrap raw pandas TypeError/DataError from post-processing as QueryObjectValidationError [superset]

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #44463:
URL: https://github.com/apache/superset/pull/44463


-- 
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