You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Vova Vysotskyi (Jira)" <ji...@apache.org> on 2020/02/27 16:50:00 UTC
[jira] [Created] (CALCITE-3835) Overloaded table functions fail
with an assertion error if param types differ
Vova Vysotskyi created CALCITE-3835:
---------------------------------------
Summary: Overloaded table functions fail with an assertion error if param types differ
Key: CALCITE-3835
URL: https://issues.apache.org/jira/browse/CALCITE-3835
Project: Calcite
Issue Type: Bug
Reporter: Vova Vysotskyi
Assignee: Vova Vysotskyi
Fix For: 1.23.0
For the case of using named parameters in table functions, when several table functions with the same name, but with different argument types, query with such function fails with an assertion error.
For example, the following table functions:
{{View(String R, String S, Integer T)}} and {{View(String R, String S, Integer T, String S2)}}
will fail with assertion error for the following query:
{code:sql}
select * from table("adhoc"."View"(t=>5, s=>'6'))
{code}
with error:
{noformat}
VARCHAR
java.lang.AssertionError: VARCHAR
at org.apache.calcite.sql.type.SqlTypeExplicitPrecedenceList.compareTypePrecedence(SqlTypeExplicitPrecedenceList.java:139)
at org.apache.calcite.sql.SqlUtil.bestMatch(SqlUtil.java:691)
at org.apache.calcite.sql.SqlUtil.filterRoutinesByTypePrecedence(SqlUtil.java:660)
at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:519)
at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:439)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:240)
at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:218)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5854)
at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5841)
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.ProcedureNamespace.validateImpl(ProcedureNamespace.java:53)
at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3256)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3238)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3510)
at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1110)
at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1084)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232)
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.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:565)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:241)
at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:207)
at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:634)
at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:498)
at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:468)
at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231)
at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:550)
at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:533)
at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1519)
at org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1451)
at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1517)
at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1500)
at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1463)
at org.apache.calcite.test.JdbcTest.testTableMacroWithNamedParameters(JdbcTest.java:546)
{noformat}
The issue here is that {{SqlUtil.filterRoutinesByTypePrecedence()}} assumes that all functions will have the same type at the same position, but table functions allow omitting arguments or flipping them.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)