Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-5581

Cannot create a grandchild view with condition on newly added view column when the base table has an index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      CREATE TABLE IF NOT EXISTS TEST (ID INTEGER NOT NULL PRIMARY KEY, HOST VARCHAR(10));
      CREATE INDEX I ON TEST(HOST);
      – create updatable view (equality condition in where clause)
      CREATE VIEW V1 (col1 INTEGER) AS SELECT * FROM TEST WHERE ID=15;
      CREATE VIEW GRAND_CHILD_V1 AS SELECT * FROM V1 WHERE col1 > 2;
      – Note that the where clause of the grandchild view is a condition on the new view column
       
      The last step fails with the following exception: 
       
      Error: ERROR 504 (42703): Undefined column. columnName=V1#I.0:COL1 (state=42703,code=504)
      org.apache.phoenix.schema.ColumnNotFoundException: ERROR 504 (42703): Undefined column. columnName=V1#I.0:COL1
      at org.apache.phoenix.schema.PTableImpl.getColumnForColumnName(PTableImpl.java:1076)
      at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.resolveColumn(FromCompiler.java:528)
      at org.apache.phoenix.compile.ExpressionCompiler.resolveColumn(ExpressionCompiler.java:368)
      at org.apache.phoenix.compile.WhereCompiler$WhereExpressionCompiler.resolveColumn(WhereCompiler.java:191)
      at org.apache.phoenix.compile.WhereCompiler$WhereExpressionCompiler.visit(WhereCompiler.java:177)
      at org.apache.phoenix.compile.WhereCompiler$WhereExpressionCompiler.visit(WhereCompiler.java:164)
      at org.apache.phoenix.parse.ColumnParseNode.accept(ColumnParseNode.java:56)
      at org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
      at org.apache.phoenix.parse.CastParseNode.accept(CastParseNode.java:60)
      at org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
      at org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:45)
      at org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
      at org.apache.phoenix.parse.AndParseNode.accept(AndParseNode.java:47)
      at org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:94)
      at org.apache.phoenix.util.IndexUtil.rewriteViewStatement(IndexUtil.java:549)
      at org.apache.phoenix.util.ViewUtil.addIndexesFromParent(ViewUtil.java:328)
      at org.apache.phoenix.util.ViewUtil.addDerivedColumnsAndIndexesFromParent(ViewUtil.java:576)
      at org.apache.phoenix.schema.MetaDataClient.addColumnsAndIndexesFromAncestors(MetaDataClient.java:868)
      at org.apache.phoenix.schema.MetaDataClient.addTableToCache(MetaDataClient.java:4487)
      at org.apache.phoenix.schema.MetaDataClient.addTableToCache(MetaDataClient.java:4483)
      at org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:3013)
      at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:1058)
      at org.apache.phoenix.compile.CreateTableCompiler$1.execute(CreateTableCompiler.java:217)
      at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:411)
      at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:394)
      at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
      at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:393)
      at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:381)
      at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1843)
       
      However, the header rows for the grandchild view are still created in SYSTEM.CATALOG.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              swaroopa Swaroopa Kadam
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: