xuzifu666 commented on code in PR #4431:
URL: https://github.com/apache/calcite/pull/4431#discussion_r2176419360
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -2545,6 +2545,30 @@ void testCastToBoolean(CastType castType,
SqlOperatorFixture f) {
f.checkNull("cast(null as integer array) || array[1]");
}
+ /** Test case for <a
href="https://issues.apache.org/jira/browse/CALCITE-7063">
+ * Result type inferred for CONCAT_FUNCTION is incorrect for BINARY
arguments</a>. */
+ @Test void testConcatFuncMysql() {
+ final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.MYSQL);
+
+ // test for ByteString
+ f.setFor(SqlLibraryOperators.CONCAT_FUNCTION_MYSQL);
+ f.checkString("concat('a', x'61')", "6161", "BINARY(2) NOT NULL");
+ f.checkString("concat('abc', 'bb', 'cc')", "abcbbcc", "VARCHAR(7) NOT
NULL");
+ f.checkString("concat(x'616263',x'62')", "61626362", "BINARY(4) NOT NULL");
+ f.checkString("concat(x'616263','abc')", "616263616263", "BINARY(6) NOT
NULL");
+ f.checkString("concat(x'61',x'62')", "6162", "BINARY(2) NOT NULL");
+ f.checkString("concat(cast(x'61' as binary), cast(x'62' as binary), "
Review Comment:
The calculation of 4 is that the default logic of
STRING_BYTESTRING_PRECISION was wrong before, but it has been deleted. The
current situation is:
Execute
```f.checkString("concat(_UTF8'方煤石', x'61')", "e696b9e8a7a3e79fb361",
"BINARY(10) NOT NULL");```
SqlTester will perform two verifications:
The first is
```concat(_UTF8'方煤石', x'61')```, which infers that binary(10) is fine,
but it will also perform a second verification:
```select concat(p1, p0) from (values (x'61', _UTF8'方煤石')) as t(p0, p1)```
Here, whether it returns binary(10) or varbinary neither will be consistent
with the expected result
```BINARY(10) NOT NULL```.
Because this situation will cause this case to fail.
--
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]