[ https://issues.apache.org/jira/browse/PHOENIX-7190?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rushabh Shah updated PHOENIX-7190: ---------------------------------- Description: Steps to reproduce: 1. Create base table table1 with columns: PK1, V0, V1, V2 2. Create view view1 on the base table as SELECT * from table1; 3. Run SELECT * from view1; --> This will cache PTable of view1 on the client side. This will resolve all the columns of the base table and cache it in view's PTable. 4. Run ALTER table table1 DROP COLUMN V1; This will update the last ddl timestamp of table1 5. Run SELECT * from table1; Server will throw StaleMetadataCacheException and it will fetch the latest PTable of the base table from server and cache it on client. 6. Run SELECT V1 from view1; Expected behavior: Client should encounter ColumnNotFoundException since we remove V1 from the base table. Actual behavior: Client doesn't throw any Exception Why? The client is using the PTable object of view1 which was cached after step 3. During the query execution, client will validate last ddl timestamp of the table and the view. Client has upto date last ddl timestamp of the view1 after step 3 Client has upto date last ddl timestamp of the base table after 5. Thats why the select query in step6 didn't fail. Solution: While caching the view on the client side, we should also store the last ddl timestamp of the whole hierarchy inside view's PTable object. While validating last ddl timestamp of the view, we should validate the last ddl timestamp of the hierarchy which is cached inside view's PTable but the view was resolved sometime in the past. was: Steps to reproduce: 1. Create base table table1 with columns: PK1, V0, V1, V2 2. Create view view1 on the base table as SELECT * from table1; 3. Run SELECT * from view1; --> This will cache PTable of view1 on the client side. This will resolve all the columns of the base table and cache it in view's PTable. 4. Run ALTER table table1 DROP COLUMN V1; This will update the last ddl timestamp of table1 5. Run SELECT * from table1; Server will throw StaleMetadataCacheException and it will fetch the latest PTable of the base table from server and cache it on client. 6. Run SELECT V1 from view1; This SHOULD throw ColumnNotFoundException since we remove V1 from the base table. But it doesn't throw any Exception and the test fails. Why the test is not failing? The client is using the PTable object of view1 which was cached after step 3. During the query execution, client will validate last ddl timestamp of the table and the view. Client has upto date last ddl timestamp of the view1 after step 3 Client has upto date last ddl timestamp of the base table after 5. Thats why the select query in step6 didn't fail. Solution: While caching the view on the client side, we should also store the last ddl timestamp of the whole hierarchy inside view's PTable object. While validating last ddl timestamp of the view, we should validate the last ddl timestamp of the hierarchy which is cached inside view's PTable but the view was resolved sometime in the past. > Changes made to base table directly are not visible to the view. > ---------------------------------------------------------------- > > Key: PHOENIX-7190 > URL: https://issues.apache.org/jira/browse/PHOENIX-7190 > Project: Phoenix > Issue Type: Sub-task > Reporter: Rushabh Shah > Priority: Major > > Steps to reproduce: > 1. Create base table table1 with columns: PK1, V0, V1, V2 > 2. Create view view1 on the base table as SELECT * from table1; > 3. Run SELECT * from view1; --> This will cache PTable of view1 on the client > side. This will resolve all the columns of the base table and cache it in > view's PTable. > 4. Run ALTER table table1 DROP COLUMN V1; > This will update the last ddl timestamp of table1 > 5. Run SELECT * from table1; > Server will throw StaleMetadataCacheException and it will fetch the latest > PTable of the base table from server and cache it on client. > 6. Run SELECT V1 from view1; > > Expected behavior: > Client should encounter ColumnNotFoundException since we remove V1 from the > base table. > > Actual behavior: > Client doesn't throw any Exception > > Why? > The client is using the PTable object of view1 which was cached after step 3. > During the query execution, client will validate last ddl timestamp of the > table and the view. > Client has upto date last ddl timestamp of the view1 after step 3 > Client has upto date last ddl timestamp of the base table after 5. > Thats why the select query in step6 didn't fail. > Solution: > While caching the view on the client side, we should also store the last ddl > timestamp of the whole hierarchy inside view's PTable object. While > validating last ddl timestamp of the view, we should validate the last ddl > timestamp of the hierarchy which is cached inside view's PTable but the view > was resolved sometime in the past. > -- This message was sent by Atlassian Jira (v8.20.10#820010)