xiaochen-zhou commented on code in PR #4123:
URL: https://github.com/apache/calcite/pull/4123#discussion_r1903675608


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -3747,6 +3747,46 @@ private SqlDialect nonOrdinalDialect() {
     sql(query).dialect(mySqlDialect(NullCollation.LAST)).ok(expected);
   }
 
+  @Test void testStarRocksCastToVarcharWithLessThanMaxPrecision() {
+    final String query = "select cast(\"product_id\" as varchar(50)), 
\"product_id\" "
+        + "from \"product\" ";
+    final String expected = "SELECT CAST(`product_id` AS VARCHAR(50)), 
`product_id`\n"
+        + "FROM `foodmart`.`product`";
+    sql(query).withStarRocks().ok(expected);
+  }
+
+  @Test void testStarRocksCastToVarcharWithGreaterThanMaxPrecision() {
+    final String query = "select cast(\"product_id\" as varchar(150000)), 
\"product_id\" "
+        + "from \"product\" ";
+    final String expected = "SELECT CAST(`product_id` AS VARCHAR(65533)), 
`product_id`\n"
+        + "FROM `foodmart`.`product`";
+    sql(query).withStarRocks().ok(expected);
+  }
+
+  @Test void testStarRocksCastToVarcharWithOutPrecision() {
+    final String query = "select cast(\"product_id\" as varchar), 
\"product_id\" "
+        + "from \"product\" ";
+    final String expected = "SELECT CAST(`product_id` AS VARCHAR), 
`product_id`\n"
+        + "FROM `foodmart`.`product`";
+    sql(query).withStarRocks().ok(expected);
+  }
+
+  @Test void testStarRocksCastToVarbinaryWithLessThanMaxPrecision() {
+    final String query = "select CAST(x'ABCDEF12' AS VARBINARY(2)), 
\"product_id\" "

Review Comment:
   > Why do we need constant literal to test this?
   
   I initially wanted to test the default precision of the VARBINARY cast, but 
it seems unnecessary, so I removed it.
   



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