This is an automated email from the ASF dual-hosted git repository.

linxinyuan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 41e7339f1b fix(operator): convert booleans to Python-compatible values 
in BubbleChart/ContourPlot/TernaryPlot (#4238)
41e7339f1b is described below

commit 41e7339f1b1464c55d5d548a5c5285401fd0e20b
Author: Xuan Gu <[email protected]>
AuthorDate: Fri Apr 17 00:30:20 2026 -0700

    fix(operator): convert booleans to Python-compatible values in 
BubbleChart/ContourPlot/TernaryPlot (#4238)
    
    <!--
    Thanks for sending a pull request (PR)! Here are some tips for you:
    1. If this is your first time, please read our contributor guidelines:
    [Contributing to
    Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
      2. Ensure you have added or run the appropriate tests for your PR
      3. If the PR is work in progress, mark it a draft on GitHub.
      4. Please write your PR title to summarize what this PR proposes, we
        are following Conventional Commits style for PR titles as well.
      5. Be sure to keep the PR description updated to reflect all changes.
    -->
    
    ### What changes were proposed in this PR?
    <!--
    Please clarify what changes you are proposing. The purpose of this
    section
    is to outline the changes. Here are some tips for you:
      1. If you propose a new API, clarify the use case for a new API.
      2. If you fix a bug, you can clarify why it is a bug.
      3. If it is a refactoring, clarify what has been changed.
      3. It would be helpful to include a before-and-after comparison using
         screenshots or GIFs.
      4. Please consider writing useful notes for better and faster reviews.
    -->
    This PR fixes a bug in `BubbleChartOpDesc`, `ContourPlotOpDesc`, and
    `TernaryPlotOpDesc` where boolean fields were interpolated into the
    Python template without quotes, resulting in code like `if false ==
    'true'`. Since Python does not recognize lowercase false as a valid
    identifier, this caused a `NameError: name 'false' is not defined`. The
    fix wraps the variables in quotes (`if '$enableColor' == 'true'`),
    reverting to the string comparison approach used before the Python
    template was introduced, so the generated Python performs a
    string-to-string comparison.
    
    Demo:
    <img width="700" height="738" alt="bubblechart"
    
src="https://github.com/user-attachments/assets/d2811da5-beb9-4d8d-89f8-cca544f93e68";
    />
    
    ### Any related issues, documentation, discussions?
    <!--
    Please use this section to link other resources if not mentioned
    already.
    1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves
    #1234`
    or `Closes #1234`. If it is only related, simply mention the issue
    number.
      2. If there is design documentation, please add the link.
      3. If there is a discussion in the mailing list, please add the link.
    -->
    Closes #4257
    
    ### How was this PR tested?
    <!--
    If tests were added, say they were added here. Or simply mention that if
    the PR
    is tested with existing test cases. Make sure to include/update test
    cases that
    check the changes thoroughly including negative and positive cases if
    possible.
    If it was tested in a way different from regular unit tests, please
    clarify how
    you tested step by step, ideally copy and paste-able, so that other
    reviewers can
    test and check, and descendants can verify in the future. If tests were
    not added,
    please describe why they were not added and/or why it was difficult to
    add.
    -->
    Manually tested
    
    ### Was this PR authored or co-authored using generative AI tooling?
    <!--
    If generative AI tooling has been used in the process of authoring this
    PR,
    please include the phrase: 'Generated-by: ' followed by the name of the
    tool
    and its version. If no, write 'No'.
    Please refer to the [ASF Generative Tooling
    Guidance](https://www.apache.org/legal/generative-tooling.html) for
    details.
    -->
    No
    
    ---------
    
    Co-authored-by: carloea2 <[email protected]>
    Co-authored-by: Xinyuan Lin <[email protected]>
---
 .../amber/operator/visualization/bubbleChart/BubbleChartOpDesc.scala    | 2 +-
 .../amber/operator/visualization/contourPlot/ContourPlotOpDesc.scala    | 2 +-
 .../amber/operator/visualization/ternaryPlot/TernaryPlotOpDesc.scala    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/bubbleChart/BubbleChartOpDesc.scala
 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/bubbleChart/BubbleChartOpDesc.scala
index da2a6fe17a..4a1a7bf39e 100644
--- 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/bubbleChart/BubbleChartOpDesc.scala
+++ 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/bubbleChart/BubbleChartOpDesc.scala
@@ -103,7 +103,7 @@ class BubbleChartOpDesc extends PythonOperatorDescriptor {
   def createPlotlyFigure(): PythonTemplateBuilder = {
     assert(xValue.nonEmpty && yValue.nonEmpty && zValue.nonEmpty)
     pyb"""
-         |        if $enableColor == 'true':
+         |        if '$enableColor' == 'true':
          |            fig = go.Figure(px.scatter(table, x=$xValue, y=$yValue, 
size=$zValue, size_max=100, color=$colorCategory))
          |        else:
          |            fig = go.Figure(px.scatter(table, x=$xValue, y=$yValue, 
size=$zValue, size_max=100))
diff --git 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotOpDesc.scala
 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotOpDesc.scala
index 56d7bb9f0c..62349e3c7f 100644
--- 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotOpDesc.scala
+++ 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotOpDesc.scala
@@ -98,7 +98,7 @@ class ContourPlotOpDesc extends PythonOperatorDescriptor {
        |        y = table[$y].values
        |        z = table[$z].values
        |        grid_size = int($gridSize)
-       |        connGaps = True if $connectGaps == 'true' else False
+       |        connGaps = True if '$connectGaps' == 'true' else False
        |
        |        grid_x, grid_y = np.meshgrid(np.linspace(min(x), max(x), 
grid_size), np.linspace(min(y), max(y), grid_size))
        |        grid_z = griddata((x, y), z, (grid_x, grid_y), method='cubic')
diff --git 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/ternaryPlot/TernaryPlotOpDesc.scala
 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/ternaryPlot/TernaryPlotOpDesc.scala
index 8df0381387..b2135e9768 100644
--- 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/ternaryPlot/TernaryPlotOpDesc.scala
+++ 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/ternaryPlot/TernaryPlotOpDesc.scala
@@ -99,7 +99,7 @@ class TernaryPlotOpDesc extends PythonOperatorDescriptor {
   /** Returns a Python string that creates the ternary plot figure */
   def createPlotlyFigure(): PythonTemplateBuilder = {
     pyb"""
-       |        if $colorEnabled == 'true' and $colorDataField != "":
+       |        if '$colorEnabled' == 'true' and $colorDataField != "":
        |            fig = px.scatter_ternary(table, a=$firstVariable, 
b=$secondVariable, c=$thirdVariable, color=$colorDataField)
        |        else:
        |            fig = px.scatter_ternary(table, a=$firstVariable, 
b=$secondVariable, c=$thirdVariable)

Reply via email to