kz930 opened a new pull request, #6807:
URL: https://github.com/apache/texera/pull/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).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]