kz930 opened a new issue, #6792:
URL: https://github.com/apache/texera/issues/6792
### What happened?
`BarChartOpDesc.categoryColumn` declares a JSON default of `"No Selection"`
but its Scala field initializer is the empty string:
`common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/barChart/BarChartOpDesc.scala`
```scala
@JsonProperty(defaultValue = "No Selection", required = false)
...
var categoryColumn: EncodableString = "" // Scala default is "", not
"No Selection"
```
`generatePythonCode` decides whether a category column was chosen by
comparing only against `"No Selection"`:
```scala
var isCategoryColumn = "False"
if (categoryColumn != "No Selection")
isCategoryColumn = "True"
```
When `categoryColumn` is empty — the Scala default, reached whenever the
field is absent from the deserialized JSON (`defaultValue` is schema metadata
and is not applied to the Scala var) — `"" != "No Selection"` is **true**, so
`isCategoryColumn = "True"`. The generated code then passes the empty column
name to `px.bar(color=...)`:
```python
color=self.decode_python_template('') if True else None # -> color="" ->
px.bar(color="")
```
`px.bar(color="")` raises a KeyError/ValueError at runtime, so a bar chart
with **no category selected** fails.
**Expected:** an unset/empty `categoryColumn` yields `color=None` (no
category grouping).
### How to reproduce?
**A — user-facing:** Add a **Bar Chart** operator, set only Value and Fields
(leave the Category column unset), and run. The chart fails at runtime instead
of rendering without a category.
**B — confirmed against `main`'s operator directly:** construct
`BarChartOpDesc` with `value = "score"`, `fields = "name"`, and
`categoryColumn` left at its default (`""`), then call `generatePythonCode()`.
The emitted call contains:
```
color=self.decode_python_template('') if True else None
```
i.e. `isCategoryColumn` is `True` for the empty column, so `color` is set to
the empty-string column name → `px.bar(color="")`.
**Proposed fix:** also guard against the empty value:
```scala
if (categoryColumn.nonEmpty && categoryColumn != "No Selection")
isCategoryColumn = "True"
```
so an unset/empty `categoryColumn` yields `color=None`.
### Version/Branch
`main` (1.3.0-incubating-SNAPSHOT)
--
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]