You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Feng Zhu (Jira)" <ji...@apache.org> on 2020/03/27 14:41:00 UTC

[jira] [Reopened] (CALCITE-3864) Supports CONCAT for variable arguments

     [ https://issues.apache.org/jira/browse/CALCITE-3864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Feng Zhu reopened CALCITE-3864:
-------------------------------

> Supports CONCAT for variable arguments
> --------------------------------------
>
>                 Key: CALCITE-3864
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3864
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: TANG Wen-hui
>            Assignee: TANG Wen-hui
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.23.0
>
>          Time Spent: 8h
>  Remaining Estimate: 0h
>
> Add the Implementation for SqlLibraryOperators.CONCAT_FUNCTION in SqlFunctions rather than register it as a kind of || operator in StandardConvertletTable, because it would be better for Jdbc adaptor to generate CONCAT for mysql rather than || operator, since CONCAT in mysql is not totally same as || operator.
> According to my test, as for PG ,the result of "concat('a', 'b', 'c')" is equal to " 'a' || 'b' || 'c' " , which is 'abc', as for Mysql, the result of "concat('a', 'b', 'c')" is 'abc', but the result of " 'a'||'b'|| 'c' " is 0, as for oracle, concat only have two argument and the the result of 'a'||'b'||'c' is 'abc'.
>  And the return type inference of SqlLibraryOperators.CONCAT_FUNCTION will cause AssertionError when the precsion of its operands are not specified.
> {code:java}
> concat(cast('a' as varchar), cast('b' as varchar),cast('c' as varchar)){code}
> {code:java}
> at org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:64)at org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:64) at org.apache.calcite.sql.fun.SqlLibraryOperators.lambda$static$1(SqlLibraryOperators.java:291) at org.apache.calcite.sql.type.SqlTypeTransformCascade.inferReturnType(SqlTypeTransformCascade.java:54) at org.apache.calcite.sql.SqlOperator.inferReturnType(SqlOperator.java:486) at org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:453) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:321) at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5858) at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5845) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1800) at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1785) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:260) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:423) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5552) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:116) at org.apache.calcite.sql.SqlNode.validateExpr(SqlNode.java:259) at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:423) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:5552) at org.apache.calcite.sql.SqlCall.validate(SqlCall.java:116) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1059) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:766) at org.apache.calcite.sql.test.AbstractSqlTester.parseAndValidate(AbstractSqlTester.java:175) at org.apache.calcite.sql.test.AbstractSqlTester.getResultType(AbstractSqlTester.java:163) at org.apache.calcite.sql.test.AbstractSqlTester.getColumnType(AbstractSqlTester.java:155) at org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:477) at org.apache.calcite.sql.test.SqlOperatorBaseTest$TesterImpl.check(SqlOperatorBaseTest.java:9489) at org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:462) at org.apache.calcite.sql.test.AbstractSqlTester.checkString(AbstractSqlTester.java:447) at org.apache.calcite.sql.test.SqlOperatorBaseTest.testConcatOperator(SqlOperatorBaseTest.java:2184){code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)