You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Danny Chen (Jira)" <ji...@apache.org> on 2019/12/06 01:44:00 UTC

[jira] [Resolved] (CALCITE-3429) AssertionError thrown for user-defined table function with map argument

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

Danny Chen resolved CALCITE-3429.
---------------------------------
    Resolution: Fixed

Fixed in [ff44204|https://github.com/apache/calcite/commit/ff44204dc2899e0c34e94f70c2e0c301170daca3], thanks for your PR, [~yanlin-Lynn] !

> AssertionError thrown for user-defined table function with map argument
> -----------------------------------------------------------------------
>
>                 Key: CALCITE-3429
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3429
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Wang Yanlin
>            Assignee: Wang Yanlin
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> Similar to [CALCITE-3424|https://issues.apache.org/jira/browse/CALCITE-3424], but with different exception.
> Using Map type in table function cause AssertionError.
> Add this test case in *TableFunctionTest* to reproduce, you need to implement the function in *Smalls* to run the test.
> {code:java}
> @Test public void testTableFunctionWithMapParameter() throws SQLException {
>     try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
>       CalciteConnection calciteConnection =
>           connection.unwrap(CalciteConnection.class);
>       SchemaPlus rootSchema = calciteConnection.getRootSchema();
>       SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
>       final TableFunction table =
>           TableFunctionImpl.create(Smalls.GENERATE_STRINGS_OF_INPUT_MAP_SIZE_METHOD);
>       schema.add("GenerateStringsOfInputMapSize", table);
>       final String sql = "select *\n"
>           + "from table(\"s\".\"GenerateStringsOfInputMapSize\"(Map[5,4,3,1])) as t(n, c)\n"
>           + "where char_length(c) > 0";
>       ResultSet resultSet = connection.createStatement().executeQuery(sql);
>       assertThat(CalciteAssert.toString(resultSet),
>           equalTo("N=1; C=a\n"));
>     }
>   }
> {code}
> The stack trace 
> {code:java}
> java.lang.AssertionError: No assign rules for OTHER defined
> 	at org.apache.calcite.sql.type.SqlTypeAssignmentRules.canCastFrom(SqlTypeAssignmentRules.java:427)
> 	at org.apache.calcite.sql.type.SqlTypeUtil.canCastFrom(SqlTypeUtil.java:908)
> 	at org.apache.calcite.sql.SqlUtil.lambda$filterRoutinesByParameterType$4(SqlUtil.java:631)
> 	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:675)
> 	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
> 	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
> 	at com.google.common.collect.Iterators.addAll(Iterators.java:364)
> 	at com.google.common.collect.Lists.newArrayList(Lists.java:162)
> 	at org.apache.calcite.sql.SqlUtil.lookupSubjectRoutines(SqlUtil.java:506)
> 	at org.apache.calcite.sql.SqlUtil.lookupRoutine(SqlUtil.java:435)
> 	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:5640)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5627)
> 	at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1692)
> 	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:1009)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:969)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3129)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3111)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3383)
> 	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:1009)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:969)
> 	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:944)
> 	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:651)
> 	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:558)
> 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:265)
> 	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:231)
> {code}



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