rubenada commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1224504358
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5474,6 +5474,29 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("array_length(null)");
}
+ @Test void testArrayToStringFunc() {
+ final SqlOperatorFixture f0 = fixture();
+ f0.setFor(SqlLibraryOperators.ARRAY_TO_STRING);
+ f0.checkFails("^array_to_string(array['aa', 'b', 'c'], '-')^", "No match
found for function"
+ + " signature ARRAY_TO_STRING\\(<CHAR\\(2\\) ARRAY>, <CHARACTER>\\)",
false);
+
+ final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+ f.checkScalar("array_to_string(array['aa', 'b', 'c'], '-')", "aa-b-c",
+ "VARCHAR NOT NULL");
+ f.checkScalar("array_to_string(array[null, 'aa', null, 'b', null], '-',
'empty')",
+ "empty-aa-empty-b-empty", "VARCHAR NOT NULL");
+ f.checkScalar("array_to_string(array[null, 'aa', null, 'b', null], '-')",
"aa-b",
+ "VARCHAR NOT NULL");
+ f.checkScalar("array_to_string(array[null, x'aa', null, x'bb', null],
'-')", "aa-bb",
+ "VARCHAR NOT NULL");
+ f.checkScalar("array_to_string(array['', 'b'], '-')", "-b", "VARCHAR NOT
NULL");
+ f.checkScalar("array_to_string(array['', ''], '-')", "-", "VARCHAR NOT
NULL");
+ f.checkNull("array_to_string(null, '-')");
+ f.checkNull("array_to_string(array['a', 'b', null], null)");
+ f.checkFails("array_to_string(array[1, 2, 3], '-')",
+ "arrayToString supports only String or ByteString, but got
java.lang.Integer", true);
+ }
Review Comment:
@liuyongvs what do you think about the newer version (including the
validation check)?
--
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]