[
https://issues.apache.org/jira/browse/PHOENIX-6227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17438199#comment-17438199
]
ASF GitHub Bot commented on PHOENIX-6227:
-----------------------------------------
gjacoby126 commented on a change in pull request #1341:
URL: https://github.com/apache/phoenix/pull/1341#discussion_r742156665
##########
File path:
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java
##########
@@ -82,7 +79,66 @@ private static void verifyNewColumns(ResultSet rs, String
... values) throws SQL
assertFalse(rs.next());
assertEquals(values.length, i - 1);
}
-
+
+ @Test
+ public void testCreateAndAlterViewsWithChangeDetectionEnabled() throws
Exception {
+ String tenantId = "TE_" + generateUniqueName();
+ String schemaName = "S_" + generateUniqueName();
+ String tableName = "T_" + generateUniqueName();
+ String globalViewName = "GV_" + generateUniqueName();
+ String tenantViewName = "TV_" + generateUniqueName();
+ String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
+ String fullGlobalViewName = SchemaUtil.getTableName(schemaName,
globalViewName);
+ String fullTenantViewName = SchemaUtil.getTableName(schemaName,
tenantViewName);
+
+ PTable globalView = null;
+ PTable alteredGlobalView = null;
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ String ddl = "CREATE TABLE " + fullTableName +
+ " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2
bigint NOT NULL," +
+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " +
+ "MULTI_TENANT=true, CHANGE_DETECTION_ENABLED=true";
+ conn.createStatement().execute(ddl);
+ PTable table = PhoenixRuntime.getTableNoCache(conn, fullTableName);
+ assertTrue(table.isChangeDetectionEnabled());
+ AlterTableIT.verifySchemaExport(table,
getUtility().getConfiguration());
+
+ String globalViewDdl = "CREATE VIEW " + fullGlobalViewName +
+ " (id2 CHAR(12) NOT NULL PRIMARY KEY, col3 BIGINT NULL) " +
+ " AS SELECT * FROM " + fullTableName + "
CHANGE_DETECTION_ENABLED=true";
+
+ conn.createStatement().execute(globalViewDdl);
+ globalView = PhoenixRuntime.getTableNoCache(conn,
fullGlobalViewName);
+ assertTrue(globalView.isChangeDetectionEnabled());
+ // base column count doesn't get set properly
+ PTableImpl.Builder builder =
PTableImpl.builderFromExisting(globalView);
+ builder.setBaseColumnCount(table.getColumns().size());
+ globalView = builder.setColumns(globalView.getColumns()).build();
+ AlterTableIT.verifySchemaExport(globalView,
getUtility().getConfiguration());
+
+ String alterViewDdl = "ALTER VIEW " + fullGlobalViewName + " ADD
id3 VARCHAR(12) NULL "
Review comment:
Added tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
> Option for DDL changes to export to external schema repository
> --------------------------------------------------------------
>
> Key: PHOENIX-6227
> URL: https://issues.apache.org/jira/browse/PHOENIX-6227
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Geoffrey Jacoby
> Assignee: Geoffrey Jacoby
> Priority: Major
> Fix For: 4.17.0, 5.2.0
>
>
> When a user creates or drops a table or view, or adds/removes a column from
> one, there should be the option for Phoenix to notify an external schema
> repository. This should be a configurable plugin so that core Phoenix is not
> coupled to any particular repository implementation.
> This will also store a schema id generated by the external schema registry in
> a new field in System.Catalog so that a future JIRA can switch to using the
> schema id in change detection WAL annotations. Because of this this JIRA will
> not be able to be backported to 5.1.x or 4.16.x
--
This message was sent by Atlassian Jira
(v8.3.4#803005)