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-9003-32158db624ca32263b6f1f3b1ba38f057f0e31e4
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 25b10ed1fa8ec53fe3eb85d2a2b2f136ad844610
Author: Kary Zheng <[email protected]>
AuthorDate: Sat Oct 24 05:41:10 2026 +0000

    feat(operator): let a null Interval Join key match nothing (#9003)
    
    ### What changes were proposed in this PR?
    
    Interval Join read each key with `asInstanceOf`, which unboxes a null
    INTEGER, LONG or DOUBLE to 0, so a row with a null key joined as if the
    key were 0. A null TIMESTAMP key threw a NullPointerException and failed
    the run. A tuple whose key is null now produces nothing and never enters
    the operator's cache, so the comparisons never read a null. This matches
    the other joins, where a null key matches nothing.
    
    ### Any related issues, documentation, discussions?
    
    Closes #9002
    
    ### How was this PR tested?
    
    A new case in `IntervalOpExecSpec` feeds a null key on each side for
    INTEGER, LONG, DOUBLE and TIMESTAMP, and checks that it joins nothing
    and that a later row still joins. It fails on main. The existing
    Interval Join tests pass.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Claude Opus 5.5)
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 .../operator/intervalJoin/IntervalJoinOpExec.scala |  5 +++
 .../operator/intervalJoin/IntervalOpExecSpec.scala | 41 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/intervalJoin/IntervalJoinOpExec.scala
 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/intervalJoin/IntervalJoinOpExec.scala
index 4dd6832d4d..9aa62a4805 100644
--- 
a/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/intervalJoin/IntervalJoinOpExec.scala
+++ 
b/common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/intervalJoin/IntervalJoinOpExec.scala
@@ -49,6 +49,11 @@ class IntervalJoinOpExec(descString: String) extends 
OperatorExecutor {
   }
 
   override def processTuple(tuple: Tuple, port: Int): Iterator[TupleLike] = {
+    // A null key matches nothing, as in the other joins. It never enters a
+    // cache, so the comparisons below never read one: `asInstanceOf` unboxes a
+    // null number to 0, and a null timestamp has no getTime.
+    val key = if (port == 0) desc.leftAttributeName else 
desc.rightAttributeName
+    if (tuple.getField[Any](key) == null) return Iterator()
     if (port == 0) {
       leftTable += tuple
       if (rightTable.nonEmpty) {
diff --git 
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/intervalJoin/IntervalOpExecSpec.scala
 
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/intervalJoin/IntervalOpExecSpec.scala
index 9063105e0a..87fb7ae5cd 100644
--- 
a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/intervalJoin/IntervalOpExecSpec.scala
+++ 
b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/intervalJoin/IntervalOpExecSpec.scala
@@ -557,6 +557,47 @@ class IntervalOpExecSpec extends AnyFlatSpec with 
BeforeAndAfter {
     } finally exec.close()
   }
 
+  // A null key used to unbox to 0 for a number, so it joined as if it were 0,
+  // and to throw for a timestamp, which failed the run.
+  it should "let a null key match nothing on either side" in {
+    val zero = Map[AttributeType, Any](
+      AttributeType.INTEGER -> 0,
+      AttributeType.LONG -> 0L,
+      AttributeType.DOUBLE -> 0.0,
+      AttributeType.TIMESTAMP -> Timestamp.valueOf("2020-03-05 00:00:00")
+    )
+    zero.foreach {
+      case (attributeType, value) =>
+        val desc = new IntervalJoinOpDesc("point", "range", 3L, true, true, 
TimeIntervalType.DAY)
+
+        val nullLeft = new 
IntervalJoinOpExec(objectMapper.writeValueAsString(desc))
+        nullLeft.open()
+        try {
+          assert(
+            nullLeft.processTuple(newTuple("range", 1, value, attributeType), 
right).isEmpty
+          )
+          assert(
+            nullLeft.processTuple(newTuple[Any]("point", 1, null, 
attributeType), left).isEmpty,
+            s"a null $attributeType point joined"
+          )
+          // The null point stayed out of the cache, so a real one still joins.
+          assert(nullLeft.processTuple(newTuple("point", 1, value, 
attributeType), left).size == 1)
+        } finally nullLeft.close()
+
+        val nullRight = new 
IntervalJoinOpExec(objectMapper.writeValueAsString(desc))
+        nullRight.open()
+        try {
+          assert(
+            nullRight.processTuple(newTuple[Any]("range", 1, null, 
attributeType), right).isEmpty
+          )
+          assert(
+            nullRight.processTuple(newTuple("point", 1, value, attributeType), 
left).isEmpty,
+            s"a null $attributeType range joined"
+          )
+        } finally nullRight.close()
+    }
+  }
+
   it should "reject a join key whose type does not support interval 
comparison" in {
     val desc = new IntervalJoinOpDesc("point", "range", 3L, true, true, 
TimeIntervalType.DAY)
     val exec = new IntervalJoinOpExec(objectMapper.writeValueAsString(desc))

Reply via email to