[
https://issues.apache.org/jira/browse/CALCITE-3424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16958051#comment-16958051
]
Julian Hyde commented on CALCITE-3424:
--------------------------------------
[~IhorHuzenko] I noticed in this change and in CALCITE-3393 that you seem to be
generating SqlToRelConverterTest.xml by hand. It's better to use the copy that
is generated under core/target/surefire. It fills out the "sql" property and it
puts the resources into approximately alphabetical order so that they don't
conflict with other people's change.
You don't need to do anything - I'm about to commit a fix.
> AssertionError thrown for user-defined table function with array argument
> -------------------------------------------------------------------------
>
> Key: CALCITE-3424
> URL: https://issues.apache.org/jira/browse/CALCITE-3424
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.21.0
> Reporter: Igor Guzenko
> Assignee: Igor Guzenko
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.22.0
>
> Time Spent: 3h 20m
> Remaining Estimate: 0h
>
> *Steps to reproduce:*
> *1.* Add method with list parameter to Smalls.java
> {code:java}
> public static final Method GENERATE_STRINGS_2_METHOD =
> Types.lookupMethod(Smalls.class, "generateStrings2", List.class);
> public static QueryableTable generateStrings2(final List<Integer> list) {
> return generateStrings(list.size());
> }
> {code}
> *2.* Add test method which uses new user-defined table function to
> TableFunctionTest.java
> {code:java}
> @Test public void testTableFunction2() 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_2_METHOD);
> schema.add("GenerateStrings2", table);
> final String sql = "select *\n"
> + "from table(\"s\".\"GenerateStrings2\"(5,4,3,1,2)) as t(n, c)\n"
> + "where char_length(c) > 3";
> ResultSet resultSet = connection.createStatement().executeQuery(sql);
> assertThat(CalciteAssert.toString(resultSet),
> equalTo("N=4; C=abcd\n"));
> }
> }
> {code}
> Execution result produced by such test method is the following stack trace:
> {code:none}
> java.lang.AssertionError: use createArrayType() instead
> at
> org.apache.calcite.sql.type.SqlTypeFactoryImpl.assertBasic(SqlTypeFactoryImpl.java:221)
> at
> org.apache.calcite.sql.type.SqlTypeFactoryImpl.createSqlType(SqlTypeFactoryImpl.java:48)
> at
> org.apache.calcite.jdbc.JavaTypeFactoryImpl.toSql(JavaTypeFactoryImpl.java:255)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.toSql(CalciteCatalogReader.java:381)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.lambda$toSql$7(CalciteCatalogReader.java:370)
> at
> com.google.common.collect.Lists$TransformingRandomAccessList$1.transform(Lists.java:640)
> at
> com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
> at java.util.AbstractCollection.toArray(AbstractCollection.java:141)
> at
> com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:239)
> at org.apache.calcite.sql.SqlFunction.<init>(SqlFunction.java:123)
> at
> org.apache.calcite.sql.validate.SqlUserDefinedFunction.<init>(SqlUserDefinedFunction.java:63)
> at
> org.apache.calcite.sql.validate.SqlUserDefinedTableFunction.<init>(SqlUserDefinedTableFunction.java:45)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.toOp(CalciteCatalogReader.java:338)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.toOp(CalciteCatalogReader.java:302)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.lambda$lookupOperatorOverloads$3(CalciteCatalogReader.java:271)
> at
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
> at
> java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
> at
> java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
> at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
> at
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
> at
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
> at
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
> at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> at
> java.util.stream.ReferencePipeline.forEachOrdered(ReferencePipeline.java:490)
> at
> org.apache.calcite.prepare.CalciteCatalogReader.lookupOperatorOverloads(CalciteCatalogReader.java:272)
> at
> org.apache.calcite.sql.util.ChainedSqlOperatorTable.lookupOperatorOverloads(ChainedSqlOperatorTable.java:73)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.performUnconditionalRewrites(SqlValidatorImpl.java:1195)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.performUnconditionalRewrites(SqlValidatorImpl.java:1180)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.performUnconditionalRewrites(SqlValidatorImpl.java:1180)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.performUnconditionalRewrites(SqlValidatorImpl.java:1180)
> at
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:937)
> 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)
> at
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:638)
> at
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:502)
> at
> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:472)
> 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.TableFunctionTest.testTableFunction2(TableFunctionTest.java:120)
> {code}
> *Tip:* In scope of CALCITE-3238 was added new assertion to
> *_SqlTypeFactoryImpl.assertBasic(...)_* method, and now this check can't be
> ignored inside _*JavaTypeFactoryImpl.toSql(typeFactory, type)*_ static
> method.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)