[ https://issues.apache.org/jira/browse/CALCITE-4524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17355281#comment-17355281 ]
Steven Talbot commented on CALCITE-4524: ---------------------------------------- [~julianhyde] I believe this fixed a bug. The following tweak of an existing test in RelToSqlConverter before this fix blows up with the below stack trace {code:java} @Test void testValuesEmpty2() { final String sql = "select *\n" + "from (values (1, 'a'), (2, 'bb')) as t(x, y)\n" + "limit 0"; final RuleSet rules = RuleSets.ofList(PruneEmptyRules.SORT_FETCH_ZERO_INSTANCE); final String sql2 = "SELECT SUBSTRING(y, 1, 1) FROM (" + sql + ") t"; final String expected = "SELECT SUBSTRING(`Y` FROM 1 FOR 1)\n" + "FROM (SELECT NULL AS `X`, NULL AS `Y`) AS `t`\n" + "WHERE 1 = 0"; sql(sql2).optimize(rules, null).withMysql().ok(expected); } {code} {noformat} java.lang.IndexOutOfBoundsException: Index: 1, Size: 1java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at org.apache.calcite.sql.SqlNodeList.get(SqlNodeList.java:154) at org.apache.calcite.rel.rel2sql.SqlImplementor$Result$1.field(SqlImplementor.java:1720) at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:698) at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:1134) at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.callToSql(SqlImplementor.java:853) at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:829) ...{noformat} Basically, the code in SqlImplementor$Result.field does (did) not handle the explicit singleton star list. Of course, post this change, it now does. Do you want a tracking bug? > Make some fields non-nullable (SqlSelect.selectList, > DataContext.getTypeFactory) > -------------------------------------------------------------------------------- > > Key: CALCITE-4524 > URL: https://issues.apache.org/jira/browse/CALCITE-4524 > Project: Calcite > Issue Type: Bug > Reporter: Julian Hyde > Assignee: Julian Hyde > Priority: Major > Fix For: 1.27.0 > > > Make some fields non-nullable: {{SqlSelect.selectList}}, > {{DataContext.getTypeFactory()}}, {{DataContext.getQueryProvider()}}. > Add {{class DataContexts}}, with a few useful implementations of {{interface > DataContext}}. > Resolve some other TODOs relating to nullability. -- This message was sent by Atlassian Jira (v8.3.4#803005)