The GitHub Actions job "Required Checks" on 
texera.git/backport/6807-treat-an-empty-categorycolumn-as-no-cate-v1.2 has 
failed.
Run started by GitHub user Yicong-Huang (triggered by Yicong-Huang).

Head commit for run:
30cb3c792bb16b7dde1f0b66ccc2202e9c07b457 / 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)

---------

(backported from commit c24755c98e0d17b07712ee677ee9ddd7d33ccb68)

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

With regards,
GitHub Actions via GitBox

Reply via email to