osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jira] [Created] (CALCITE-2430) AssertionError: RelDataTypeImpl.getFieldList when SQL Advisor inspects non-struct field


Vladimir Sitnikov created CALCITE-2430:
------------------------------------------

             Summary: AssertionError: RelDataTypeImpl.getFieldList when SQL Advisor inspects non-struct field
                 Key: CALCITE-2430
                 URL: https://issues.apache.org/jira/browse/CALCITE-2430
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.17.0
            Reporter: Vladimir Sitnikov
            Assignee: Julian Hyde


Test case (in JdbcTest):
{code:java}  @Test public void testSqlAdvisorNonStructColumn()
      throws SQLException, ClassNotFoundException {
    adviseSql("select e.\"empid\".^ from \"hr\".\"emps\" e",
        CalciteAssert.checkResultUnordered(
            "id=; names=null; type=MATCH",
            "id=hr.dependents; names=[hr, dependents]; type=TABLE",
            "id=hr.depts; names=[hr, depts]; type=TABLE",
            "id=hr.emps; names=[hr, emps]; type=TABLE",
            "id=hr.locations; names=[hr, locations]; type=TABLE",
            "id=hr; names=[hr]; type=SCHEMA"));
  }{code}

Relevant source from RelDataTypeImpl.getFieldList:
{code:java}  public List<RelDataTypeField> getFieldList() {
    assert isStruct(); // <-- Error here
    return fieldList;
  }{code}

Relevant source from SqlValidatorImpl.lookupNameCompletionHints:
{code:java}      if (ns != null) {
        RelDataType rowType = ns.getRowType();
        for (RelDataTypeField field : rowType.getFieldList()) { // <-- Error here
          hintList.add(
              new SqlMonikerImpl(
                  field.getName(),
                  SqlMonikerType.COLUMN));
        }
      }{code}

It looks like it makes sense to add {{isStruct}} check before iterating over {{rowType.getFieldList()}}.

Any objections?

Original exception: {noformat}
java.lang.AssertionError
	at org.apache.calcite.rel.type.RelDataTypeImpl.getFieldList(RelDataTypeImpl.java:146)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupNameCompletionHints(SqlValidatorImpl.java:808)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:690)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupSelectHints(SqlValidatorImpl.java:701)
	at org.apache.calcite.sql.validate.SqlValidatorImpl.lookupHints(SqlValidatorImpl.java:655)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:235)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:182)
	at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:142)
	at org.apache.calcite.sql.advise.SqlAdvisorGetHintsFunction.getCompletionHints(SqlAdvisorGetHintsFunction.java:105)
	at Baz.bind(Unknown Source)
	at org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:356)
	at org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:309)
	at org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:506)
	at org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:497)
	at org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:182)
	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:64)
	at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:43)
	at org.apache.calcite.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:573)
	at org.apache.calcite.avatica.AvaticaPreparedStatement.executeQuery(AvaticaPreparedStatement.java:137)
	at org.apache.calcite.test.JdbcTest.adviseSql(JdbcTest.java:426)
	at org.apache.calcite.test.JdbcTest.testSqlAdvisorNonStructColumn(JdbcTest.java:359)
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)