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

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 30677e4f4e [spark] Fix IndexOutOfBoundsException for vector_search 
with too few arguments (#9164)
30677e4f4e is described below

commit 30677e4f4e84bf4b70086626cfe623aab862dbda
Author: jackylee <[email protected]>
AuthorDate: Wed Aug 12 11:26:35 2026 +0800

    [spark] Fix IndexOutOfBoundsException for vector_search with too few 
arguments (#9164)
---
 .../catalyst/plans/logical/PaimonTableValuedFunctions.scala   |  7 ++++---
 .../spark/catalyst/plans/logical/VectorSearchQueryTest.scala  | 11 +++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/PaimonTableValuedFunctions.scala
 
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/PaimonTableValuedFunctions.scala
index 851acf933e..4c0123824f 100644
--- 
a/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/PaimonTableValuedFunctions.scala
+++ 
b/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/catalyst/plans/logical/PaimonTableValuedFunctions.scala
@@ -596,9 +596,10 @@ case class VectorSearchQuery(override val args: 
Seq[Expression])
   }
 
   def hasOuterReference(argsWithoutTable: Seq[Expression]): Boolean = {
-    val queryVector = argsWithoutTable(1)
-    (argsWithoutTable.size == 3 || argsWithoutTable.size == 4) &&
-    (queryVector.references.nonEmpty || containsOuterReference(queryVector))
+    (argsWithoutTable.size == 3 || argsWithoutTable.size == 4) && {
+      val queryVector = argsWithoutTable(1)
+      queryVector.references.nonEmpty || containsOuterReference(queryVector)
+    }
   }
 
   private def containsOuterReference(expr: Expression): Boolean = {
diff --git 
a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/catalyst/plans/logical/VectorSearchQueryTest.scala
 
b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/catalyst/plans/logical/VectorSearchQueryTest.scala
index e0d4d4870b..464913601d 100644
--- 
a/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/catalyst/plans/logical/VectorSearchQueryTest.scala
+++ 
b/paimon-spark/paimon-spark-common/src/test/scala/org/apache/paimon/spark/catalyst/plans/logical/VectorSearchQueryTest.scala
@@ -319,6 +319,17 @@ class VectorSearchQueryTest extends AnyFunSuite {
     assert(vectorSearch.options().get("hnsw.ef_search") == "64")
   }
 
+  test("reject vector search with too few parameters") {
+    Seq(Seq.empty[Expression], Seq(Literal("v"))).foreach {
+      args =>
+        val exception = intercept[RuntimeException] {
+          VectorSearchQuery(Seq.empty).createVectorSearch(innerTable, args)
+        }
+        assert(exception.getMessage.contains("needs three or four parameters"))
+        assert(!VectorSearchQuery(Seq.empty).hasOuterReference(args))
+    }
+  }
+
   private def createVectorSearch(args: Expression*) =
     VectorSearchQuery(Seq.empty).createVectorSearch(innerTable, args)
 

Reply via email to