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


##########
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))");

Review Comment:
   You need to add a test for numbers
   
   ```
   scala> val df = spark.sql("select hex('1')")
   df: org.apache.spark.sql.DataFrame = [hex(1): string]
   
   scala> df.show()
   +------+                                                                     
   
   |hex(1)|
   +------+
   |    31|
   +------+
   
   
   scala> val df = spark.sql("select hex('0')")
   df: org.apache.spark.sql.DataFrame = [hex(0): string]
   
   scala> df.show()
   +------+
   |hex(0)|
   +------+
   |    30|
   +------+
   
   
   scala> val df = spark.sql("select hex('-1')")
   df: org.apache.spark.sql.DataFrame = [hex(-1): string]
   
   scala> df.show()
   +-------+
   |hex(-1)|
   +-------+
   |   2D31|
   +-------+
   ```
   
   



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