beliefer commented on a change in pull request #25172: [SPARK-28412][SQL] ANSI 
SQL: OVERLAY function support byte array
URL: https://github.com/apache/spark/pull/25172#discussion_r306157829
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
 ##########
 @@ -452,6 +452,45 @@ class StringExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
     // scalastyle:on
   }
 
+  test("overlay for byte array") {
+    val input = Literal(Array[Byte](1, 2, 3, 4, 5, 6, 7, 8, 9))
+    checkEvaluation(new Overlay(input, Literal(Array[Byte](-1)),
+      Literal.create(6, IntegerType)), Array[Byte](1, 2, 3, 4, 5, -1, 7, 8, 9))
 
 Review comment:
   Thanks for your reminder. but the negative is illegal in `Postgresql`.
   ```
   org.postgresql.util.PSQLException: ERROR: negative substring length not 
allowed
     在位置:SQL function "overlay" statement 1
   ```
   Oracle's description:
   `If pos is specified, it must be greater than or equal to 1.`
   DB2's description:
   `If you specify n, it must be a positive whole number.`
   Vertical's description:
   `(INTEGER) is the character or octet position (counting from one) at which 
to begin the overlay`
   I will check position is larger than 9.
   Postgresql's behavior is:
   `select OVERLAY('abcdef' PLACING '45' FROM 7);      // abcdef45`
   Oracle and DB2 expanded the Overlay function, but not follow ANSI standard.

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


With regards,
Apache Git Services

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

Reply via email to