caicancai commented on code in PR #4172:
URL: https://github.com/apache/calcite/pull/4172#discussion_r1934185151


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5823,6 +5823,38 @@ void testBitGetFunc(SqlOperatorFixture f, String 
functionName) {
     f0.forEachLibrary(libraries, consumer);
   }
 
+  @Test void testHex() {
+    SqlOperatorFixture sqlOperatorFixture = fixture();
+    final SqlOperatorFixture f0 = 
sqlOperatorFixture.setFor(SqlLibraryOperators.HEX);
+    f0.checkFails("^hex('')^",
+        "No match found for function signature HEX\\(<CHARACTER>\\)",
+        false);
+    final Consumer<SqlOperatorFixture> consumer = f -> {
+      f.checkString("hex('abc')",
+          "616263",
+          "VARCHAR NOT NULL");
+      f.checkString("hex('')", "", "VARCHAR NOT NULL");
+      f.checkNull("hex(cast(null as varbinary))");
+    };
+    f0.forEachLibrary(list(SqlLibrary.HIVE, SqlLibrary.SPARK), consumer);
+  }
+
+  @Test void testUnHex() {
+    SqlOperatorFixture sqlOperatorFixture = fixture();
+    final SqlOperatorFixture f0 = 
sqlOperatorFixture.setFor(SqlLibraryOperators.UNHEX);
+    f0.checkFails("^unhex('')^",
+        "No match found for function signature UNHEX\\(<CHARACTER>\\)",
+        false);
+    final Consumer<SqlOperatorFixture> consumer = f -> {
+      f.checkString("unhex('616263')",
+          "abc",
+          "VARCHAR NOT NULL");
+      f.checkString("unhex('')", "", "VARCHAR NOT NULL");
+      f.checkNull("unhex(cast(null as varbinary))");

Review Comment:
   Are you sure that unhex(0) is equal to null? I tested it in Spark and the 
result is [00]



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to