mihaibudiu commented on code in PR #4027:
URL: https://github.com/apache/calcite/pull/4027#discussion_r1826092703
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10901,6 +10901,26 @@ void checkEndsWith(SqlOperatorFixture f0,
FunctionAlias functionAlias) {
+ "requires extra delimiter argument", false);
}
+ /** Tests the {@code SPLIT_PART} operator. */
+ @Test void testSplitPartFunction() {
+ final SqlOperatorFixture f0 =
fixture().setFor(SqlLibraryOperators.SPLIT_PART);
+ f0.checkFails("^split_part('hello', 1)^",
+ "No match found for function signature SPLIT_PART\\(<CHARACTER>,
<NUMERIC>\\)",
+ false);
+ final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.POSTGRESQL);
+
+ f.checkScalar("SPLIT_PART('abc~@~def~@~ghi', '~@~', 2)", "def",
"VARCHAR(15) NOT NULL");
Review Comment:
This type comes from ARG0_NULLABLE.
It is true that the result will never be larger.
Another reasonable type would be VARCHAR.
I think there are many functions which use this result type inference.
But indeed, the VARCHAR(N) types have some unintuitive behaviors sometimes.
--
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]