Fix working of async index building by adding the INDEX_TYPE column name to result set of ASYNC_INDEX_INFO_QUERY. Also refactored the test case to utilize the same.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/badae2a3 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/badae2a3 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/badae2a3 Branch: refs/heads/encodecolumns Commit: badae2a355cc6ae0ee84b1f58e11142115b32dfd Parents: b157be2 Author: tejamobref <[email protected]> Authored: Mon Jul 25 18:36:26 2016 +0530 Committer: Thomas D'Silva <[email protected]> Committed: Mon Jul 25 10:55:31 2016 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/index/AsyncIndexIT.java | 30 +++----------------- .../apache/phoenix/query/QueryConstants.java | 23 ++++++++------- 2 files changed, 17 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/badae2a3/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexIT.java index 43d1bd9..19b460d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/AsyncIndexIT.java @@ -17,15 +17,7 @@ */ package org.apache.phoenix.end2end.index; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ASYNC_CREATED_DATE; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_FAMILY; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_NAME; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DATA_TABLE_NAME; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE; +import static org.apache.phoenix.query.QueryConstants.ASYNC_INDEX_INFO_QUERY; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -39,12 +31,8 @@ import java.util.HashMap; import java.util.Map; import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest; -import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.schema.PIndexState; -import org.apache.phoenix.schema.PTableType; -import org.apache.phoenix.schema.types.PDate; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.After; import org.junit.Test; @@ -57,19 +45,9 @@ public class AsyncIndexIT extends BaseTest { private static final String PERSON_TABLE_NAME_WITH_SCHEMA = "TEST.PERSON"; private static final String TEST_SCHEMA = "TEST"; - private static final String PERSON_TABLE_ASYNC_INDEX_INFO_QUERY = "SELECT " - + DATA_TABLE_NAME + ", " + TABLE_SCHEM + ", " - + TABLE_NAME + " FROM " + SYSTEM_CATALOG_SCHEMA + ".\"" - + SYSTEM_CATALOG_TABLE + "\"" - + " (" + ASYNC_CREATED_DATE + " " - + PDate.INSTANCE.getSqlTypeName() + ") " + " WHERE " - + COLUMN_NAME + " IS NULL and " + COLUMN_FAMILY + " IS NULL and " - + ASYNC_CREATED_DATE + " IS NOT NULL and " - + TABLE_TYPE + " = '" + PTableType.INDEX.getSerializedValue() - + "' and DATA_TABLE_NAME='" + PERSON_TABLE_NAME - + "' and TABLE_SCHEM='" + TEST_SCHEMA + "' and " - + PhoenixDatabaseMetaData.INDEX_STATE + " = '" - + PIndexState.BUILDING.getSerializedValue() + "'"; + private static final String PERSON_TABLE_ASYNC_INDEX_INFO_QUERY = + ASYNC_INDEX_INFO_QUERY + " and DATA_TABLE_NAME='" + PERSON_TABLE_NAME + + "' and TABLE_SCHEM='" + TEST_SCHEMA + "'"; private void dropTable(Statement stmt) throws SQLException, IOException { stmt.execute("DROP TABLE IF EXISTS " + PERSON_TABLE_NAME_WITH_SCHEMA); http://git-wip-us.apache.org/repos/asf/phoenix/blob/badae2a3/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java index 8bc1c5b..28393aa 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java @@ -172,17 +172,20 @@ public interface QueryConstants { public static final byte[] TRUE = new byte[] {1}; public static final String ASYNC_INDEX_INFO_QUERY = "SELECT " - + DATA_TABLE_NAME + ", " + TABLE_SCHEM + ", " - + TABLE_NAME + ", " + ASYNC_CREATED_DATE - + " FROM " + SYSTEM_CATALOG_SCHEMA + ".\"" - + SYSTEM_CATALOG_TABLE + "\"" - + " (" + ASYNC_CREATED_DATE + " " - + PDate.INSTANCE.getSqlTypeName() + ") " + " WHERE " - + COLUMN_NAME + " IS NULL and " + COLUMN_FAMILY + " IS NULL and " + + INDEX_TYPE + "," + + DATA_TABLE_NAME + ", " + + TABLE_SCHEM + ", " + + TABLE_NAME + ", " + + ASYNC_CREATED_DATE + + " FROM " + + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\"" + + " (" + ASYNC_CREATED_DATE + " " + PDate.INSTANCE.getSqlTypeName() + ") " + + " WHERE " + + COLUMN_NAME + " IS NULL and " + + COLUMN_FAMILY + " IS NULL and " + ASYNC_CREATED_DATE + " IS NOT NULL and " - + TABLE_TYPE + " = '" + PTableType.INDEX.getSerializedValue() - + "' and " + PhoenixDatabaseMetaData.INDEX_STATE + " = '" - + PIndexState.BUILDING.getSerializedValue() + "'"; + + TABLE_TYPE + " = '" + PTableType.INDEX.getSerializedValue() + "' and " + + PhoenixDatabaseMetaData.INDEX_STATE + " = '" + PIndexState.BUILDING.getSerializedValue() + "'"; /** * Separator used between variable length keys for a composite key.
