The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-6807-6495ebd84ab0dc7f4f6b1d4fbc09ff051f4cfd10
 has succeeded.
Run started by GitHub user aglinxinyuan (triggered by aglinxinyuan).

Head commit for run:
c24755c98e0d17b07712ee677ee9ddd7d33ccb68 / Kary Zheng 
<[email protected]>
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 <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Co-authored-by: Copilot Autofix powered by AI 
<[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/29978351560

With regards,
GitHub Actions via GitBox

Reply via email to