fix(BarChart, v1.2): treat an empty categoryColumn as no category (px.bar color) - #6997
Open
Yicong-Huang wants to merge 1 commit into
Open
Conversation
…olor) (#6807) ### What changes were proposed in this PR? Fixes `BarChartOpDesc.generatePythonCode` treating an **unset** `categoryColumn` as a real column, which breaks `px.bar` at runtime. `categoryColumn`'s Scala field default is the empty string, while its JSON `defaultValue = "No Selection"` is only schema metadata (not applied to the Scala var, and not present when the field is absent from the deserialized JSON). The category guard compared **only** against `"No Selection"`: ```scala var isCategoryColumn = "False" if (categoryColumn != "No Selection") // "" != "No Selection" is true isCategoryColumn = "True" ``` So for an empty `categoryColumn`, `isCategoryColumn` became `"True"` and the empty column name flowed into the generated call: ```python color=self.decode_python_template('') if True else None # -> px.bar(color="") ``` `px.bar(color="")` raises at runtime, so a bar chart with **no category selected** fails. The fix also guards against empty, so an unset category yields `color=None`: ```diff - if (categoryColumn != "No Selection") + if (categoryColumn.nonEmpty && categoryColumn != "No Selection") ``` ### Any related issues, documentation, discussions? Closes #6792 ### How was this PR tested? Added a regression test in `BarChartOpDescSpec` that constructs a `BarChartOpDesc` with `value`/`fields` set and `categoryColumn` left at its default, calls `generatePythonCode()`, and asserts the color site is guarded to `None` (`... if False else None`) with no `... if True else None`. Verified the test **fails** on the pre-fix code and **passes** with the fix; full `BarChartOpDescSpec` is green (9/9). ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- (backported from commit c24755c) Signed-off-by: Kary Zheng <150742834+kz930@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Automated Reviewer SuggestionsBased on the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Backport of #6807 to
release/v1.2, cherry-picked from c24755c. The cherry-pick applied cleanly.Follows the Direct Backport Push convention; opened as a PR (rather than a direct push) per a backport-coverage audit.
Any related issues, documentation, discussions?
Backport of #6807. Originally linked #6792.
How was this PR tested?
Release-branch CI runs on this PR. Cherry-pick applied cleanly onto
release/v1.2; no manual conflict resolution was needed.Was this PR authored or co-authored using generative AI tooling?
Yes — backport prepared with Claude Code (mechanical cherry-pick; the change itself is #6807 by its original author).
🤖 Generated with Claude Code