ILuffZhe commented on code in PR #4110:
URL: https://github.com/apache/calcite/pull/4110#discussion_r1896226002


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -11262,11 +11264,12 @@ private static void 
checkSubstringFunction(SqlOperatorFixture f) {
           String.format(Locale.ROOT, "^substring('string', CAST(%d AS DOUBLE), 
"
               + "CAST(%d AS DOUBLE))^", Byte.MIN_VALUE, Byte.MAX_VALUE + 10),
           "Cannot apply 'SUBSTRING' to arguments of type "
-            + ".*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*", false);
+            + ".*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*\\n.*", false);

Review Comment:
   What changed here?



##########
core/src/test/resources/sql/misc.iq:
##########
@@ -18,7 +18,75 @@
 !use post
 !set outputformat mysql
 
-# Compared by casting varchar to number
+SELECT UUID '123e4567-e89b-12d3-a456-426655440000';
++--------------------------------------+
+| EXPR$0                               |
++--------------------------------------+
+| 123e4567-e89b-12d3-a456-426655440000 |
++--------------------------------------+
+(1 row)
+
+!ok
+
+SELECT CAST('123e4567-e89b-12d3-a456-426655440000' AS UUID);
++--------------------------------------+
+| EXPR$0                               |
++--------------------------------------+
+| 123e4567-e89b-12d3-a456-426655440000 |
++--------------------------------------+
+(1 row)
+
+!ok
+
+SELECT CAST('123e4567e89b12d3a456426655440000' AS UUID);
+java.lang.IllegalArgumentException: Invalid UUID string: 
123e4567e89b12d3a456426655440000
+!error
+
+SELECT CAST(UUID '123e4567-e89b-12d3-a456-426655440000' AS VARCHAR);
++--------------------------------------+
+| EXPR$0                               |
++--------------------------------------+
+| 123e4567-e89b-12d3-a456-426655440000 |
++--------------------------------------+
+(1 row)
+
+!ok
+
+SELECT CAST(UUID '123e4567-e89b-12d3-a456-426655440000' AS VARBINARY);
++----------------------------------+
+| EXPR$0                           |
++----------------------------------+
+| d3129be867453e1200004455664256a4 |
++----------------------------------+
+(1 row)
+
+!ok
+
+SELECT CAST(x'd3129be867453e1200004455664256a4' AS UUID);
++--------------------------------------+
+| EXPR$0                               |
++--------------------------------------+
+| 123e4567-e89b-12d3-a456-426655440000 |
++--------------------------------------+
+(1 row)
+
+!ok
+
+SELECT CAST(x'00' AS UUID);
+java.lang.IllegalArgumentException: Need at least 16 bytes for UUID
+!error
+
+SELECT UUID '123e4567-e89b-12d3-a456-426655440000' = 
'123e4567-e89b-12d3-a456-426655440000';
++--------+
+| EXPR$0 |
++--------+
+| true   |
++--------+
+(1 row)
+
+!ok
+
+# Compare varchar to number

Review Comment:
   The former doc points out there is implicit cast for it.



##########
core/src/test/resources/sql/misc.iq:
##########
@@ -18,7 +18,75 @@
 !use post
 !set outputformat mysql
 
-# Compared by casting varchar to number
+SELECT UUID '123e4567-e89b-12d3-a456-426655440000';

Review Comment:
   What are the results of `cast(null as UUID)` and `UUID null`



##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -277,6 +279,20 @@ public static boolean throwUnless(boolean condition, 
String message) {
     return condition;
   }
 
+  public static String uuidToString(UUID uuid) {

Review Comment:
   Shall we add some tests in `SqlFunctionsTest`?



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