You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2014/12/03 21:22:17 UTC

[2/2] phoenix git commit: PHOENIX-1484 Index creation failed due to specifying DEFAULT_COLUMN_FAMILY option

PHOENIX-1484 Index creation failed due to specifying DEFAULT_COLUMN_FAMILY option


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e758b6d3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e758b6d3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e758b6d3

Branch: refs/heads/4.0
Commit: e758b6d3b8114dcc3d0a5f86939c51d58441aeed
Parents: fb651e1
Author: James Taylor <jt...@salesforce.com>
Authored: Wed Dec 3 12:21:51 2014 -0800
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed Dec 3 12:21:51 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/phoenix/schema/MetaDataClient.java    | 10 ++++------
 .../org/apache/phoenix/compile/QueryCompilerTest.java     |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e758b6d3/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index af699e4..ea333ac 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -727,7 +727,6 @@ public class MetaDataClient {
         connection.rollback();
         try {
             connection.setAutoCommit(true);
-            MutationState state;
             MutationPlan mutationPlan;
             
             // For local indexes, we optimize the initial index population by *not* sending Puts over
@@ -827,7 +826,7 @@ public class MetaDataClient {
                     throw new SQLException(e);
                 }
             }            
-            state = connection.getQueryServices().updateData(mutationPlan);
+            MutationState state = connection.getQueryServices().updateData(mutationPlan);
             indexStatement = FACTORY.alterIndex(FACTORY.namedTable(null, 
                 TableName.create(index.getSchemaName().getString(), index.getTableName().getString())),
                 dataTableRef.getTable().getTableName().getString(), false, PIndexState.ACTIVE);
@@ -1037,7 +1036,7 @@ public class MetaDataClient {
                 }
                 // Set DEFAULT_COLUMN_FAMILY_NAME of index to match data table
                 // We need this in the props so that the correct column family is created
-                if (dataTable.getDefaultFamilyName() != null && dataTable.getType() != PTableType.VIEW) {
+                if (dataTable.getDefaultFamilyName() != null && dataTable.getType() != PTableType.VIEW && indexId == null) {
                     statement.getProps().put("", new Pair<String,Object>(DEFAULT_COLUMN_FAMILY_NAME,dataTable.getDefaultFamilyName().getString()));
                 }
                 CreateTableStatement tableStatement = FACTORY.createTable(indexTableName, statement.getProps(), columnDefs, pk, statement.getSplitNodes(), PTableType.INDEX, statement.ifNotExists(), null, null, statement.getBindCount());
@@ -1237,11 +1236,10 @@ public class MetaDataClient {
             }
             
             boolean removedProp = false;
-            // Can't set MULTI_TENANT or DEFAULT_COLUMN_FAMILY_NAME on an index
-            if ((tableType != PTableType.INDEX || indexId != null) && (tableType != PTableType.VIEW || viewType == ViewType.MAPPED)) {
+            // Can't set MULTI_TENANT or DEFAULT_COLUMN_FAMILY_NAME on an INDEX or a non mapped VIEW
+            if (tableType != PTableType.INDEX && (tableType != PTableType.VIEW || viewType == ViewType.MAPPED)) {
                 Boolean multiTenantProp = (Boolean) tableProps.remove(PhoenixDatabaseMetaData.MULTI_TENANT);
                 multiTenant = Boolean.TRUE.equals(multiTenantProp);
-                // Remove, but add back after our check below
                 defaultFamilyName = (String)tableProps.remove(PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME);  
                 removedProp = (defaultFamilyName != null);
             }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e758b6d3/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
index bb864d9..314431a 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
@@ -1462,6 +1462,7 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
                     + "ln varchar constraint pk primary key(id)) DEFAULT_COLUMN_FAMILY='F'");
             try {
                 statement.execute("create local index my_idx on example (fn) DEFAULT_COLUMN_FAMILY='F'");
+                fail();
             } catch (SQLException e) {
                 assertEquals(SQLExceptionCode.VIEW_WITH_PROPERTIES.getErrorCode(),e.getErrorCode());
             }