dongjoon-hyun commented on a change in pull request #32407:
URL: https://github.com/apache/spark/pull/32407#discussion_r627116538



##########
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:
       Thank you for this test coverage.




-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to