This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 62ccb3b815 PHOENIX-7067 View indexes should be created only on non
overlapping updatable views (#1709)
62ccb3b815 is described below
commit 62ccb3b815aca1c1cd2f2b9fb8feab024bec834f
Author: Viraj Jasani
AuthorDate: Thu Nov 9 18:13:07 2023 -0900
PHOENIX-7067 View indexes should be created only on non overlapping
updatable views (#1709)
---
.../org/apache/phoenix/end2end/AlterTableIT.java | 75 +-
.../phoenix/end2end/MetaDataEndpointImplIT.java| 26 +-
.../end2end/ViewExtendsPkRestrictionsIT.java | 1169
.../java/org/apache/phoenix/end2end/ViewTTLIT.java | 65 +-
.../phoenix/compile/CreateTableCompiler.java | 61 +
.../apache/phoenix/exception/SQLExceptionCode.java |4 +
.../phoenix/jdbc/PhoenixDatabaseMetaData.java |2 +
.../query/DelegateConnectionQueryServices.java |2 +-
.../phoenix/query/DelegateQueryServices.java |4 +-
.../org/apache/phoenix/query/QueryServices.java| 11 +
.../org/apache/phoenix/schema/MetaDataClient.java | 74 +-
11 files changed, 1420 insertions(+), 73 deletions(-)
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index b6c1cc1b12..8908af2047 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1182,50 +1182,93 @@ public class AlterTableIT extends
ParallelStatsDisabledIT {
}
@Test
-public void testDeclaringColumnAsRowTimestamp() throws Exception {
+public void testIndexColumnAsRowTimestamp() throws Exception {
try (Connection conn = DriverManager.getConnection(getUrl())) {
-conn.createStatement().execute("CREATE TABLE " + dataTableFullName
+ " (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR CONSTRAINT PK PRIMARY
KEY(PK1 ROW_TIMESTAMP, PK2)) " + tableDDLOptions);
-PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class);
-PTable table = phxConn.getTable(new
PTableKey(phxConn.getTenantId(), dataTableFullName));
+conn.createStatement().execute("CREATE TABLE " + dataTableFullName
++ " (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR "
++ "CONSTRAINT PK PRIMARY KEY(PK1 ROW_TIMESTAMP, PK2)) " +
tableDDLOptions);
+PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class);
+PTable table =
+phxConn.getTable(new PTableKey(phxConn.getTenantId(),
dataTableFullName));
// Assert that the column shows up as row time stamp in the cache.
assertTrue(table.getColumnForColumnName("PK1").isRowTimestamp());
assertFalse(table.getColumnForColumnName("PK2").isRowTimestamp());
assertIsRowTimestampSet(schemaName, dataTableName, "PK1");
-
+
String dataTableName2 = BaseTest.generateUniqueName();
String dataTableFullName2 = SchemaUtil.getTableName(schemaName,
dataTableName2);
-conn.createStatement().execute("CREATE IMMUTABLE TABLE " +
dataTableFullName2 + " (PK1 VARCHAR, PK2 DATE PRIMARY KEY ROW_TIMESTAMP, KV1
VARCHAR, KV2 INTEGER)");
+conn.createStatement().execute("CREATE IMMUTABLE TABLE " +
dataTableFullName2 +
+" (PK1 VARCHAR, PK2 DATE PRIMARY KEY ROW_TIMESTAMP, KV1
VARCHAR, KV2 INTEGER)");
table = phxConn.getTable(new PTableKey(phxConn.getTenantId(),
dataTableFullName2));
// Assert that the column shows up as row time stamp in the cache.
assertFalse(table.getColumnForColumnName("PK1").isRowTimestamp());
assertTrue(table.getColumnForColumnName("PK2").isRowTimestamp());
assertIsRowTimestampSet(schemaName, dataTableName2, "PK2");
-
+
// Create an index on a table has a row time stamp pk column. The
column should show up as a row time stamp column for the index too.
-conn.createStatement().execute("CREATE INDEX " + indexTableName +
" ON " + dataTableFullName2 + " (KV1) include (KV2)");
-PTable indexTable = phxConn.getTable(new
PTableKey(phxConn.getTenantId(), indexTableFullName));
+conn.createStatement().execute(
+"CREATE INDEX " + indexTableName + " ON " +
dataTableFullName2 +
+" (KV1) include (KV2)");
+PTable indexTable =
+phxConn.getTable(new PTableKey(phxConn.getTenantId(),
indexTableFullName));
String indexColName =
IndexUtil.getIndexColumnName(table.getColumnForColumnName("PK2"));