[ https://issues.apache.org/jira/browse/PHOENIX-7391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
rejeb ben rejeb updated PHOENIX-7391: ------------------------------------- Description: Given multitenant table: {code:java} CREATE TABLE MULTITENANT_TABLE (TENANT_ID VARCHAR NOT NULL, GLOBAL_COL1 VARCHAR, GLOBAL_COL2 VARCHAR CONSTRAINT pk PRIMARY KEY (TENANT_ID, GLOBAL_COL1)) MULTI_TENANT=true{code} Create View with tenantId= "MyTenantId": {code:java} CREATE VIEW IF NOT EXISTS TENANT_VIEW(TENANT_ONLY_COL VARCHAR) AS SELECT * FROM MULTITENANT_TEST_TABLE {code} When call: {code:java} Properties props = new Properties(); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "MyTenantId"); Connection conn = DriverManager.getConnection(getUrl(), props); List<String> result = PhoenixRuntime.generateColumnInfo(tsconn,"TENANT_VIEW",null).stream() .map(ColumnInfo::getDisplayName).collect(Collectors.toList());{code} Expected result is: GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL Actual: TENANT_ID, GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL When I looked at method implementation I foud out that salted column was filtered when getting columns info but not the tenantId column: {code:java} <line 5612> int offset = (table.getBucketNum() == null ? 0 : 1); {code} As for Salt column, TENANT_ID column is an internal managed column so it should be filtered when returning the list of columns. For generic process which use this method to get table column list, if tenantId column is retruned in the list of column and the process try to insert or fetch data with that list Phoenix will throw exception as it will not recognize the column TENANT_ID. was: Given multitenant table: {code:java} CREATE TABLE MULTITENANT_TABLE (TENANT_ID VARCHAR NOT NULL, GLOBAL_COL1 VARCHAR, GLOBAL_COL2 VARCHAR CONSTRAINT pk PRIMARY KEY (TENANT_ID, GLOBAL_COL1)) MULTI_TENANT=true{code} Create View with tenantId= "MyTenantId": {code:java} CREATE VIEW IF NOT EXISTS TENANT_VIEW(TENANT_ONLY_COL VARCHAR) AS SELECT * FROM MULTITENANT_TEST_TABLE {code} When call: {code:java} Properties props = new Properties(); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "MyTenantId"); Connection conn = DriverManager.getConnection(getUrl(), props); List<String> result = PhoenixRuntime.generateColumnInfo(tsconn,"TENANT_VIEW",null).stream() .map(ColumnInfo::getDisplayName).collect(Collectors.toList());{code} Expected result is: GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL Actual: TENANT_ID, GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL When I looked at method implementation I foud out that salted column was filtered when getting columns info but not the tenantId column: {code:java} <line 5612> int offset = (table.getBucketNum() == null ? 0 : 1); {code} As for Salt column, TENANT_ID column is an internal managed column so it should be filtered when returning the list of columns. For generic process which use this method to get table column list, if tenantId column is retruned in the list of column and the process try to insert or fetch data with that list Phoenix will throw exception as it will not recognize the column TENANT_ID. I faced the issue when testing multitenant table with phoenix spark connectors. > PhoenixRuntime.generateColumnInfo does not filter tenant_id column > ------------------------------------------------------------------ > > Key: PHOENIX-7391 > URL: https://issues.apache.org/jira/browse/PHOENIX-7391 > Project: Phoenix > Issue Type: Bug > Components: core > Reporter: rejeb ben rejeb > Assignee: rejeb ben rejeb > Priority: Minor > > Given multitenant table: > {code:java} > CREATE TABLE MULTITENANT_TABLE (TENANT_ID VARCHAR NOT NULL, GLOBAL_COL1 > VARCHAR, GLOBAL_COL2 VARCHAR CONSTRAINT pk PRIMARY KEY (TENANT_ID, > GLOBAL_COL1)) MULTI_TENANT=true{code} > > Create View with tenantId= "MyTenantId": > {code:java} > CREATE VIEW IF NOT EXISTS TENANT_VIEW(TENANT_ONLY_COL VARCHAR) AS SELECT * > FROM MULTITENANT_TEST_TABLE {code} > When call: > {code:java} > Properties props = new Properties(); > props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "MyTenantId"); > Connection conn = DriverManager.getConnection(getUrl(), props); > List<String> result = > PhoenixRuntime.generateColumnInfo(tsconn,"TENANT_VIEW",null).stream() > .map(ColumnInfo::getDisplayName).collect(Collectors.toList());{code} > Expected result is: GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL > Actual: TENANT_ID, GLOBAL_COL1,GLOBAL_COL2,TENANT_ONLY_COL > > When I looked at method implementation I foud out that salted column was > filtered when getting columns info but not the tenantId column: > {code:java} > <line 5612> int offset = (table.getBucketNum() == null ? 0 : 1); {code} > > As for Salt column, TENANT_ID column is an internal managed column so it > should be filtered when returning the list of columns. > For generic process which use this method to get table column list, if > tenantId column is retruned in the list of column and the process try to > insert or fetch data with that list Phoenix will throw exception as it will > not recognize the column TENANT_ID. -- This message was sent by Atlassian Jira (v8.20.10#820010)