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/20 02:24:00 UTC

[jira] [Commented] (CALCITE-3864) Add Implementation for SqlLibraryOperators.CONCAT_FUNCTION in SqlFunctions and correct the return type inference of SqlLibraryOperators.CONCAT_FUNCTION

    [ https://issues.apache.org/jira/browse/CALCITE-3864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17063039#comment-17063039 ] 

Feng Zhu commented on CALCITE-3864:
-----------------------------------

I remember that the concat function differs in many products. Could you please make a survey? Maybe we also need to take the unparse logic into consideration when converting to SQL.

> Add Implementation for SqlLibraryOperators.CONCAT_FUNCTION in SqlFunctions and correct the return type inference of SqlLibraryOperators.CONCAT_FUNCTION
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 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
>          Time Spent: 10m
>  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.
>  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)