macroguo-ghy commented on code in PR #3389:
URL: https://github.com/apache/calcite/pull/3389#discussion_r1302943102


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -1804,6 +1804,35 @@ void testCastToBoolean(CastType castType, 
SqlOperatorFixture f) {
         consumer);
   }
 
+  @Test void testCodePointsToBytes() {
+    final SqlOperatorFixture f = fixture()
+        .setFor(SqlLibraryOperators.CODE_POINTS_TO_BYTES, VM_FENNEL, VM_JAVA)
+        .withLibrary(SqlLibrary.BIG_QUERY);
+    f.checkFails("^code_points_to_bytes('abc')^",
+        "Cannot apply 'CODE_POINTS_TO_BYTES' to arguments of type "
+            + "'CODE_POINTS_TO_BYTES\\(<CHAR\\(3\\)>\\)'\\. "
+            + "Supported form\\(s\\): CODE_POINTS_TO_BYTES\\(<INTEGER 
ARRAY>\\)",
+        false);
+    f.checkFails("^code_points_to_bytes(array['abc'])^",
+        "Cannot apply 'CODE_POINTS_TO_BYTES' to arguments of type "
+            + "'CODE_POINTS_TO_BYTES\\(<CHAR\\(3\\) ARRAY>\\)'\\. "
+            + "Supported form\\(s\\): CODE_POINTS_TO_BYTES\\(<INTEGER 
ARRAY>\\)",
+        false);
+
+    f.checkFails("code_points_to_bytes(array[-1])",
+        "Input arguments of CODE_POINTS_TO_BYTES out of range: -1", true);
+    f.checkFails("code_points_to_bytes(array[2147483648, 1])",
+        "Input arguments of CODE_POINTS_TO_BYTES out of range: 2147483648", 
true);
+
+    f.checkString("code_points_to_bytes(array[65, 66, 67, 68])", "41424344", 
"VARBINARY NOT NULL");
+    f.checkString("code_points_to_bytes(array[255, 254, 65, 64])", "fffe4140",

Review Comment:
   I add a test for expressions inputs: `code_points_to_bytes(array[1+2, 3, 
4])`. 
   For empty array, I try to use `array[]` and `array()` construct a emtpy 
array, but both of them fail. `array[]` requires more then 1 argument, 
`array()` only enabled for SPARKSQL.



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

To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org

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

Reply via email to