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

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-7298-573ed7eaa247a53da4378f80c37dd885915f9d16
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 6d4bea6c83c5783a51cd3d03fd175bfc6f231a9a
Author: Prateek Ganigi <[email protected]>
AuthorDate: Thu Aug 6 13:24:10 2026 -0700

    fix(workflow-operator): give a clear error when the HF result column 
collides with an input column (#7298)
    
    ### What changes were proposed in this PR?
    
    If the HuggingFace operator's Result Column Name matches an existing
    input column, `getOutputSchemas` reached `Schema.add`, which threw a
    generic `RuntimeException("Attribute name '...' already exists in the
    schema")`, which is unhelpful, and it doesn't tell the user what to do.
    
    This adds a pre-check in `getOutputSchemas`: if the resolved result
    column already exists in the input schema, it throws a clear, actionable
    message ("Result column '...' already exists in the input table. Choose
    a different Result Column Name.") instead of the opaque internal error.
    
    ### Any related issues, documentation, discussions?
    
    Closes #7198.
    
    ### How was this PR tested?
    
    `sbt "WorkflowOperator/testOnly
    org.apache.texera.amber.operator.huggingFace.*"`: passes (124 tests).
    Added a test that a colliding result column produces the clear "Result
    column '...'" error. scalafmt clean.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    This PR was not authored or co-authored using generative AI tooling.
---
 .../operator/huggingFace/HuggingFaceInferenceOpDesc.scala | 15 ++++++++++++---
 .../huggingFace/HuggingFaceInferenceOpDescSpec.scala      |  9 +++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDesc.scala
 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDesc.scala
index 590b509787..cf506fb760 100644
--- 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDesc.scala
+++ 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDesc.scala
@@ -262,9 +262,18 @@ class HuggingFaceInferenceOpDesc extends 
PythonOperatorDescriptor {
 
   override def getOutputSchemas(
       inputSchemas: Map[PortIdentity, Schema]
-  ): Map[PortIdentity, Schema] =
+  ): Map[PortIdentity, Schema] = {
+    val inputSchema = inputSchemas.values.head
+    val resultCol = resolvedResultColumn
+    if (inputSchema.containsAttribute(resultCol)) {
+      throw new RuntimeException(
+        s"Result column '$resultCol' already exists in the input table. " +
+          "Choose a different Result Column Name."
+      )
+    }
     Map(
-      operatorInfo.outputPorts.head.id -> inputSchemas.values.head
-        .add(resolvedResultColumn, AttributeType.STRING)
+      operatorInfo.outputPorts.head.id -> inputSchema
+        .add(resultCol, AttributeType.STRING)
     )
+  }
 }
diff --git 
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDescSpec.scala
 
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDescSpec.scala
index b6b0355435..bf6549fb80 100644
--- 
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDescSpec.scala
+++ 
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/huggingFace/HuggingFaceInferenceOpDescSpec.scala
@@ -687,4 +687,13 @@ class HuggingFaceInferenceOpDescSpec extends AnyFlatSpec 
with Matchers {
       .path("type")
       .asText() shouldBe "password"
   }
+
+  it should "give a clear error when the result column collides with an input 
column" in {
+    val desc = makeDesc(resultColumn = "prompt")
+    val inputSchema = Schema().add("prompt", AttributeType.STRING)
+    val ex = intercept[RuntimeException] {
+      desc.getOutputSchemas(Map(PortIdentity(0) -> inputSchema))
+    }
+    ex.getMessage should include("Result column 'prompt'")
+  }
 }

Reply via email to