You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ka...@apache.org on 2019/06/14 00:25:53 UTC
[phoenix] branch 4.x-HBase-1.4 updated: PHOENIX-5343 OrphanViewTool
should not check Index Tables
This is an automated email from the ASF dual-hosted git repository.
kadir pushed a commit to branch 4.x-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.4 by this push:
new 28c40a6 PHOENIX-5343 OrphanViewTool should not check Index Tables
28c40a6 is described below
commit 28c40a6ae1519cdf302df43ac13c2fa684dc2414
Author: Kadir <ko...@salesforce.com>
AuthorDate: Thu Jun 13 13:53:53 2019 -0700
PHOENIX-5343 OrphanViewTool should not check Index Tables
---
.../apache/phoenix/end2end/OrphanViewToolIT.java | 23 ++++++++++++----------
.../apache/phoenix/mapreduce/OrphanViewTool.java | 3 ++-
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
index 44a8f67..7a05d27 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
@@ -80,6 +80,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
private static final String createBaseTableFirstPartDDL = "CREATE TABLE IF NOT EXISTS %s";
private static final String createBaseTableSecondPartDDL = "(%s PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " +
" CONSTRAINT NAME_PK PRIMARY KEY (%s PK2)) %s";
+ private static final String createBaseTableIndexDDL = "CREATE INDEX %s ON %s (V1)";
private static final String deleteTableRows = "DELETE FROM " + SYSTEM_CATALOG_NAME +
" WHERE " + TABLE_SCHEM + " %s AND " +
TABLE_TYPE + " = '" + PTableType.TABLE.getSerializedValue() + "'";
@@ -183,12 +184,14 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
connection.commit();
}
- private void createBaseTableAndViews(Connection baseTableConnection, String baseTableFullName,
- Connection viewConnection, String childViewSchemaName,
- String grandchildViewSchemaName, String grandGrandChildViewSchemaName)
+ private void createBaseTableIndexAndViews(Connection baseTableConnection, String baseTableFullName,
+ Connection viewConnection, String childViewSchemaName,
+ String grandchildViewSchemaName, String grandGrandChildViewSchemaName)
throws SQLException {
baseTableConnection.createStatement().execute(generateDDL(String.format(createBaseTableFirstPartDDL,
baseTableFullName) + createBaseTableSecondPartDDL));
+ baseTableConnection.createStatement().execute(String.format(createBaseTableIndexDDL,
+ generateUniqueName(), baseTableFullName));
// Create a view tree (i.e., tree of views) with depth of 3
for (int i = 0; i < fanout; i++) {
String childView = SchemaUtil.getTableName(childViewSchemaName, generateUniqueName());
@@ -230,7 +233,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
// Run the orphan view tool to drop orphan views but no view should be dropped
runOrphanViewTool(true, false, true, false);
verifyOrphanFileLineCounts(0, 0, 0, 0);
@@ -275,7 +278,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA2, SCHEMA2);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA2, SCHEMA2);
// Delete the base table row from the system catalog
executeDeleteQuery(connection, deleteTableRows, SCHEMA1);
// Verify that the views we have created are still in the system catalog table
@@ -309,7 +312,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, null, SCHEMA3, SCHEMA3);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, null, SCHEMA3, SCHEMA3);
// Delete the rows of the immediate child views of the base table from the system catalog
executeDeleteQuery(connection, deleteViewRows, null);
// Verify that the other views we have created are still in the system catalog table
@@ -338,7 +341,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, null);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, null);
// Delete the grand child view rows from the system catalog
executeDeleteQuery(connection, deleteViewRows, SCHEMA3);
// Verify that grand grand child views are still in the system catalog table
@@ -368,7 +371,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
// Delete the CHILD_TABLE links to grand child views
executeDeleteQuery(connection, deleteChildLinks, SCHEMA2);
// Verify that grand grand child views are still in the system catalog table
@@ -396,7 +399,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4);
// Delete the PARENT_TABLE links from grand grand child views
executeDeleteQuery(connection, deleteParentLinks, SCHEMA4);
// Verify that grand grand child views are still in the system catalog table
@@ -422,7 +425,7 @@ public class OrphanViewToolIT extends ParallelStatsDisabledIT {
try (Connection connection = DriverManager.getConnection(getUrl());
Connection viewConnection =
isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) {
- createBaseTableAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA3);
+ createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA3);
// Delete the physical table link rows from the system catalog
executeDeleteQuery(connection, deletePhysicalLinks, SCHEMA2);
// Verify that the views we have created are still in the system catalog table
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
index 5fc5808..3e999c1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
@@ -125,7 +125,8 @@ public class OrphanViewTool extends Configured implements Tool {
TABLE_SCHEM + ", " +
TABLE_NAME +
" FROM " + SYSTEM_CATALOG_NAME +
- " WHERE "+ " NOT " + TABLE_TYPE + " = '" + PTableType.VIEW.getSerializedValue() + "'";
+ " WHERE " + TABLE_TYPE + " != '" + PTableType.VIEW.getSerializedValue() + "' AND " +
+ TABLE_TYPE + " != '" + PTableType.INDEX.getSerializedValue() + "'";
// The path of the directory of the output files
private String outputPath;
// The path of the directory of the input files