Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
When we create view with extra columns and upsert into the view then calcite was not able to recognise the additional columns in the view and failing with column not found exception.
Here is the base table:
PARENT_TABLE_DDL = "CREATE TABLE " + PARENT_TABLE_NAME + " ( \n" + " \"user\" VARCHAR ,\n" + " tenant_id VARCHAR NOT NULL,\n" + " tenant_type_id VARCHAR(3) NOT NULL, \n" + " id INTEGER NOT NULL\n" + " CONSTRAINT pk PRIMARY KEY (tenant_id, tenant_type_id, id)) MULTI_TENANT=true, IMMUTABLE_ROWS=true";
Here is the view:
TENANT_TABLE_DDL = "CREATE VIEW " + TENANT_TABLE_NAME + " ( \n" + " tenant_col VARCHAR) AS SELECT *\n" + " FROM " + PARENT_TABLE_NAME + " WHERE tenant_type_id= '" + TENANT_TYPE_ID + "'";
Upsert query:
conn.createStatement().executeUpdate("upsert into " + TENANT_TABLE_NAME + " (id, tenant_col) values (1, 'Cheap Sunglasses')");
Failing with TENANT_COL not present in view.
java.sql.SQLException: Error while executing SQL "upsert into V_T000010 (id, tenant_col) values (1, 'Cheap Sunglasses')": From line 1, column 28 to line 1, column 37: Unknown target column 'TENANT_COL' at org.apache.phoenix.end2end.TenantSpecificTablesDMLIT.testJoinWithGlobalTable(TenantSpecificTablesDMLIT.java:155) Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 28 to line 1, column 37: Unknown target column 'TENANT_COL'