sunchao commented on a change in pull request #32407:
URL: https://github.com/apache/spark/pull/32407#discussion_r627154100



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2FunctionSuite.scala
##########
@@ -183,6 +183,28 @@ class DataSourceV2FunctionSuite extends 
DatasourceV2SQLBase {
     checkAnswer(sql("SELECT testcat.ns.strlen('abc')"), Row(3) :: Nil)
   }
 
+  test("scalar function: static magic method in Java") {
+    
catalog("testcat").asInstanceOf[SupportsNamespaces].createNamespace(Array("ns"),
 emptyProps)
+    addFunction(Identifier.of(Array("ns"), "strlen"),
+      new JavaStrLen(new JavaStrLenStaticMagic))
+    checkAnswer(sql("SELECT testcat.ns.strlen('abc')"), Row(3) :: Nil)
+  }
+
+  test("scalar function: magic method should take higher precedence in Java") {
+    
catalog("testcat").asInstanceOf[SupportsNamespaces].createNamespace(Array("ns"),
 emptyProps)
+    addFunction(Identifier.of(Array("ns"), "strlen"),
+      new JavaStrLen(new JavaStrLenBoth))
+    // to differentiate, the static method returns string length + 100
+    checkAnswer(sql("SELECT testcat.ns.strlen('abc')"), Row(103) :: Nil)
+  }
+
+  test("scalar function: bad static magic method should fallback to 
non-static") {

Review comment:
       Because there is a valid definition of `invoke` in the class? I might 
misunderstood what you mean.




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to