[ https://issues.apache.org/jira/browse/PHOENIX-2999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15345396#comment-15345396 ]
Samarth Jain commented on PHOENIX-2999: --------------------------------------- [~an...@apache.org] - is there a way we can check what namespaces are views and view indexes getting mapped to? Can you add a test for the same? Or point me to test cases where you are checking that views with different schema names are mapped to the same namespace as the data table. Similarly, tests to assert that view indexes on these views are all mapped to the same name space as data table. Also, it would be better to have different view names and view indexes for global and tenant specific connections. {code} + try (Connection conn = DriverManager.getConnection(getUrl())) { + conn.createStatement().execute("CREATE TABLE " + phoenixFullTableName + + "(k VARCHAR not null, v INTEGER not null, f INTEGER, g INTEGER NULL, h INTEGER NULL CONSTRAINT pk PRIMARY KEY(k,v)) MULTI_TENANT=true"); + PreparedStatement upsertStmt = conn + .prepareStatement("UPSERT INTO " + phoenixFullTableName + " VALUES(?, ?, 0, 0, 0)"); + int i = 1; + for (String str : strings) { + upsertStmt.setString(1, str); + upsertStmt.setInt(2, i++); + upsertStmt.execute(); + } + conn.commit(); + + // creating global index + conn.createStatement().execute("create index " + indexName + " on " + phoenixFullTableName + "(f)"); + // creating view in schema 'diff' + conn.createStatement().execute("CREATE VIEW diff.v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + // creating view in schema 'test' + conn.createStatement().execute("CREATE VIEW test.v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + conn.createStatement().execute("CREATE VIEW v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + // Creating index on views + conn.createStatement().execute("create index v_idx on diff.v(col)"); + conn.createStatement().execute("create index v_idx on test.v(col)"); + } + Properties props = new Properties(); + String tenantId = "a"; + props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + PreparedStatement upsertStmt = conn + .prepareStatement("UPSERT INTO " + phoenixFullTableName + "(k,v,f,g,h) VALUES(?, ?, 0, 0, 0)"); + int i = 1; + for (String str : strings) { + upsertStmt.setString(1, str); + upsertStmt.setInt(2, i++); + upsertStmt.execute(); + } + conn.commit(); + // creating view in schema 'diff' + conn.createStatement().execute("CREATE VIEW diff.v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + // creating view in schema 'test' + conn.createStatement().execute("CREATE VIEW test.v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + conn.createStatement().execute("CREATE VIEW v (col VARCHAR) AS SELECT * FROM " + phoenixFullTableName); + // Creating index on views + conn.createStatement().execute("create index v_idx on diff.v(col)"); + conn.createStatement().execute("create index v_idx on test.v(col)"); + } {code} > Upgrading Multi-tenant table to map with namespace using upgradeUtil > -------------------------------------------------------------------- > > Key: PHOENIX-2999 > URL: https://issues.apache.org/jira/browse/PHOENIX-2999 > Project: Phoenix > Issue Type: Bug > Affects Versions: 4.8.0 > Reporter: Ankit Singhal > Assignee: Ankit Singhal > Fix For: 4.8.0 > > Attachments: PHOENIX-2999.patch > > > currently upgradeUtil doesn't handle multi-tenant table with tenant views > properly. -- This message was sent by Atlassian JIRA (v6.3.4#6332)