You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by gi...@apache.org on 2026/07/23 03:58:41 UTC
(texera) branch gh-readonly-queue/main/pr-6807-6495ebd84ab0dc7f4f6b1d4fbc09ff051f4cfd10 created (now c24755c98e)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-6807-6495ebd84ab0dc7f4f6b1d4fbc09ff051f4cfd10
in repository https://gitbox.apache.org/repos/asf/texera.git
at c24755c98e fix(BarChart): treat an empty categoryColumn as no category (px.bar color) (#6807)
This branch includes the following new commits:
new c24755c98e fix(BarChart): treat an empty categoryColumn as no category (px.bar color) (#6807)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(texera) 01/01: fix(BarChart): treat an empty categoryColumn as no category (px.bar color) (#6807)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6807-6495ebd84ab0dc7f4f6b1d4fbc09ff051f4cfd10
in repository https://gitbox.apache.org/repos/asf/texera.git
commit c24755c98e0d17b07712ee677ee9ddd7d33ccb68
Author: Kary Zheng <15...@users.noreply.github.com>
AuthorDate: Wed Jul 22 20:58:20 2026 -0700
fix(BarChart): treat an empty categoryColumn as no category (px.bar color) (#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)
---------
Signed-off-by: Kary Zheng <15...@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <no...@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <17...@users.noreply.github.com>
---
.../amber/operator/visualization/barChart/BarChartOpDesc.scala | 4 +++-
.../operator/visualization/barChart/BarChartOpDescSpec.scala | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDesc.scala b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDesc.scala
index 26ef772153..440437c9c0 100644
--- a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDesc.scala
+++ b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDesc.scala
@@ -109,7 +109,9 @@ class BarChartOpDesc extends PythonOperatorDescriptor {
isPatternSelected = "True"
var isCategoryColumn = "False"
- if (categoryColumn != "No Selection")
+ // "" is the Scala default ("No Selection" is only JSON metadata); an empty
+ // column must also count as "no category", else px.bar(color="") fails.
+ if (categoryColumn.nonEmpty && categoryColumn != "No Selection")
isCategoryColumn = "True"
val finalCode =
diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDescSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDescSpec.scala
index 3081b49d77..4c8afb0d36 100644
--- a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDescSpec.scala
+++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDescSpec.scala
@@ -110,4 +110,14 @@ class BarChartOpDescSpec extends AnyFlatSpec with BeforeAndAfter with Matchers {
ex.getMessage should (include("Value column") or include("Fields"))
}
+ "BarChartOpDesc.generatePythonCode" should "treat an unset categoryColumn as no category (color guarded to None)" in {
+ // An empty categoryColumn (its Scala default) must guard color to None, not
+ // emit `... if True else None` with an empty column name for px.bar(color=).
+ opDesc.value = "score"
+ opDesc.fields = "name"
+ val code = opDesc.generatePythonCode()
+ code should include("color=self.decode_python_template('') if False else None")
+ code should not include "color=self.decode_python_template('') if True else None"
+ }
+
}