xuzifu666 commented on code in PR #4431:
URL: https://github.com/apache/calcite/pull/4431#discussion_r2161552178


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -2565,6 +2568,17 @@ private static void checkConcatFunc(SqlOperatorFixture 
f) {
     f.checkString("concat('', '', 'a')", "a", "VARCHAR(1) NOT NULL");
     f.checkString("concat('', '', '')", "", "VARCHAR(0) NOT NULL");
     f.checkFails("^concat()^", INVALID_ARGUMENTS_NUMBER, false);
+
+    // test for ByteString
+    f.checkString("concat(x'61',x'62')", "0x6162", "VARCHAR(2) NOT NULL");
+    f.checkString("concat(cast(x'61' as binary), cast(x'62' as binary), "
+        + "cast(x'63' as binary))", "0x616263", "VARCHAR(3) NOT NULL");

Review Comment:
   I have considered this precision issue before, but the concat function 
supports int/double/... (all types that can be cast as string) not only 
```string/bytestring``` types. Even if we define a SqlReturnTypeInference, we 
cannot accurately calculate the exact precision of the int type.
   For example, for INT, we can only get the precision of 10 from type. eg 
```concat(x'61', 1, 'a')```, the type sequence we get is ```binary(1), int(10), 
varchar(1)```,  It would definitely unreasonable to infer the length of 12, so 
I think VARCHAR_NULLABLE can only be used at this position. Choosing this 
ReturnTypes should not affect the result, such as SqlFunction BASE64. If you 
have other suggestions also can tell me.



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