Repository: phoenix
Updated Branches:
  refs/heads/4.2 8a6db7e45 -> fecc730dc


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/fecc730d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/fecc730d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/fecc730d

Branch: refs/heads/4.2
Commit: fecc730dc7d3af8201fa5aa5f3d1523e7170768c
Parents: 8a6db7e
Author: James Taylor <[email protected]>
Authored: Wed Dec 3 12:21:51 2014 -0800
Committer: James Taylor <[email protected]>
Committed: Wed Dec 3 12:22:54 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/fecc730d/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/fecc730d/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());
             }

Reply via email to