You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2015/01/10 01:35:47 UTC

[1/2] phoenix git commit: Allow ALTER TABLE SET command to update HTableDescriptor and HColumnDescriptor properties (Samarth Jain/Alicia Ying Shu)
Repository: phoenix
Updated Branches:
  refs/heads/4.0 cae025a52 -> 7578ee92b


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/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 623fc0e..8a3a2b2 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
@@ -20,6 +20,7 @@ package org.apache.phoenix.schema;
 import static com.google.common.collect.Lists.newArrayListWithExpectedSize;
 import static com.google.common.collect.Sets.newLinkedHashSet;
 import static com.google.common.collect.Sets.newLinkedHashSetWithExpectedSize;
+import static org.apache.hadoop.hbase.HColumnDescriptor.TTL;
 import static org.apache.phoenix.exception.SQLExceptionCode.INSUFFICIENT_MULTI_TENANT_COLUMNS;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARRAY_SIZE;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_COUNT;
@@ -72,16 +73,21 @@ import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Types;
+import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -133,6 +139,7 @@ import org.apache.phoenix.parse.ParseNodeFactory;
 import org.apache.phoenix.parse.PrimaryKeyConstraint;
 import org.apache.phoenix.parse.TableName;
 import org.apache.phoenix.parse.UpdateStatisticsStatement;
+import org.apache.phoenix.query.ConnectionQueryServices;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
@@ -151,11 +158,14 @@ import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.ServerUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterators;
+import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.primitives.Ints;
@@ -285,6 +295,9 @@ public class MetaDataClient {
         ") VALUES (?, ?, ?, ?, ?, ?)";
     
     private final PhoenixConnection connection;
+    
+    private static final HColumnDescriptor defaultColDescriptor = new HColumnDescriptor(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES);
+    
 
     public MetaDataClient(PhoenixConnection connection) {
         this.connection = connection;
@@ -1455,6 +1468,11 @@ public class MetaDataClient {
                     Map<String,Object> combinedFamilyProps = Maps.newHashMapWithExpectedSize(props.size() + commonFamilyProps.size());
                     combinedFamilyProps.putAll(commonFamilyProps);
                     for (Pair<String,Object> prop : props) {
+                        // Don't allow specifying column families for TTL. TTL can only apply for the all the column families of the table 
+                        // i.e. it can't be column family specific.
+                        if (!familyName.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY) && prop.getFirst().equals(TTL)) {
+                            throw new SQLExceptionInfo.Builder(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL).build().buildException(); 
+                        }
                         combinedFamilyProps.put(prop.getFirst(), prop.getSecond());
                     }
                     familyPropList.add(new Pair<byte[],Map<String,Object>>(familyName.getBytes(),combinedFamilyProps));
@@ -1954,33 +1972,100 @@ public class MetaDataClient {
             TableName tableNameNode = statement.getTable().getName();
             String schemaName = tableNameNode.getSchemaName();
             String tableName = tableNameNode.getTableName();
-            // Outside of retry loop, as we're removing the property and wouldn't find it the second time
-            Boolean isImmutableRowsProp = (Boolean)statement.getProps().remove(PTable.IS_IMMUTABLE_ROWS_PROP_NAME);
-            Boolean multiTenantProp = (Boolean)statement.getProps().remove(PhoenixDatabaseMetaData.MULTI_TENANT);
-            Boolean disableWALProp = (Boolean)statement.getProps().remove(DISABLE_WAL);
             
+            Boolean isImmutableRowsProp = null;
+            Boolean multiTenantProp = null;
+            Boolean disableWALProp = null;
+            
+            // flatten, separate and validate properties
+            ListMultimap<String,Pair<String,Object>> stmtPropsMap = statement.getProps();
+            Map<String, Map<String, Object>> stmtFamiliesPropsMap = new HashMap<>(stmtPropsMap.size());
+            Map<String, Object> tableProps = new HashMap<>(stmtPropsMap.size());
+            PTable table = FromCompiler.getResolver(statement, connection).getTables().get(0).getTable();
+            Map<String,Object> commonFamilyProps = new HashMap<>();
+            List<ColumnDef> columnDefs = statement.getColumnDefs();
+            if (columnDefs == null) {                    
+                columnDefs = Lists.newArrayListWithExpectedSize(1);
+            }
+            for (String family : stmtPropsMap.keySet()) {
+                List<Pair<String, Object>> propsList = stmtPropsMap.get(family);
+                Map<String, Object> colFamilyPropsMap = new HashMap<String, Object>(propsList.size());
+                for (Pair<String, Object> prop : propsList) {
+                    String propName = prop.getFirst();
+                    if ((isHTableProperty(propName) ||  TableProperty.isPhoenixTableProperty(propName)) && columnDefs.size() > 0) {
+                    	// setting HTable and PhoenixTable properties while adding a column is not allowed.
+                    	throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN)
+                    	.setMessage("Property: " + propName).build()
+                    	.buildException();
+                    }
+                    if (isHTableProperty(propName)) {
+                        // Can't have a column family name for a property that's an HTableProperty
+                        if (!family.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY)) {
+                            throw new SQLExceptionInfo.Builder(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY)
+                            .setMessage("Column Family: " + family + ", Property: " + propName).build()
+                            .buildException(); 
+                        }
+                        tableProps.put(propName, prop.getSecond());
+                    } else {
+                        if (TableProperty.isPhoenixTableProperty(propName)) {
+                        	TableProperty.valueOf(propName).validate(true, !family.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY), table.getType());
+                            if (propName.equals(TTL)) {
+                                // Even though TTL is really a HColumnProperty we treat it specially.
+                                // We enforce that all column families have the same TTL.
+                            	commonFamilyProps.put(propName, prop.getSecond());
+                            } else if (propName.equals(PTable.IS_IMMUTABLE_ROWS_PROP_NAME)) {
+                                isImmutableRowsProp = (Boolean)prop.getSecond();
+                            } else if (propName.equals(PhoenixDatabaseMetaData.MULTI_TENANT)) {
+                                multiTenantProp = (Boolean)prop.getSecond();
+                            } else if (propName.equals(DISABLE_WAL)) {
+                                disableWALProp = (Boolean)prop.getSecond();
+                            } 
+                        } else {
+                            if (isHColumnProperty(propName)) {
+                                if (family.equals(QueryConstants.ALL_FAMILY_PROPERTIES_KEY)) {
+                                    commonFamilyProps.put(propName, prop.getSecond());
+                                } else {
+                                    colFamilyPropsMap.put(propName, prop.getSecond());
+                                }
+                            } else {
+                                // invalid property - neither of HTableProp, HColumnProp or PhoenixTableProp
+                                // FIXME: This isn't getting triggered as currently a property gets evaluated 
+                                // as HTableProp if its neither HColumnProp or PhoenixTableProp.
+                                throw new SQLExceptionInfo.Builder(SQLExceptionCode.SET_UNSUPPORTED_PROP_ON_ALTER_TABLE)
+                                .setMessage("Column Family: " + family + ", Property: " + propName).build()
+                                .buildException();
+                            }
+                        }
+                    }
+                }
+                if (!colFamilyPropsMap.isEmpty()) {
+                    stmtFamiliesPropsMap.put(family, colFamilyPropsMap);
+                }
+            }
+            
+                        
             boolean retried = false;
             while (true) {
-                List<Mutation> tableMetaData = Lists.newArrayListWithExpectedSize(2);
                 ColumnResolver resolver = FromCompiler.getResolver(statement, connection);
-                PTable table = resolver.getTables().get(0).getTable();
+                table = resolver.getTables().get(0).getTable();
+                List<Mutation> tableMetaData = Lists.newArrayListWithExpectedSize(2);
                 if (logger.isDebugEnabled()) {
                     logger.debug(LogUtil.addCustomAnnotations("Resolved table to " + table.getName().getString() + " with seqNum " + table.getSequenceNumber() + " at timestamp " + table.getTimeStamp() + " with " + table.getColumns().size() + " columns: " + table.getColumns(), connection));
                 }
-                
+
                 int position = table.getColumns().size();
-                
+
                 List<PColumn> currentPKs = table.getPKColumns();
                 PColumn lastPK = currentPKs.get(currentPKs.size()-1);
                 // Disallow adding columns if the last column is VARBIANRY.
                 if (lastPK.getDataType() == PVarbinary.INSTANCE || lastPK.getDataType().isArrayType()) {
                     throw new SQLExceptionInfo.Builder(SQLExceptionCode.VARBINARY_LAST_PK)
-                        .setColumnName(lastPK.getName().getString()).build().buildException();
+                    .setColumnName(lastPK.getName().getString()).build().buildException();
                 }
                 // Disallow adding columns if last column is fixed width and nullable.
                 if (lastPK.isNullable() && lastPK.getDataType().isFixedWidth()) {
                     throw new SQLExceptionInfo.Builder(SQLExceptionCode.NULLABLE_FIXED_WIDTH_LAST_PK)
-                        .setColumnName(lastPK.getName().getString()).build().buildException();
+                    .setColumnName(lastPK.getName().getString()).build().buildException();
                 }
 
                 Boolean isImmutableRows = null;
@@ -2001,36 +2086,14 @@ public class MetaDataClient {
                         disableWAL = disableWALProp;
                     }
                 }
-                
-                if (statement.getProps().get(PhoenixDatabaseMetaData.SALT_BUCKETS) != null) {
-                    throw new SQLExceptionInfo.Builder(SQLExceptionCode.SALT_ONLY_ON_CREATE_TABLE)
-                    .setTableName(table.getName().getString()).build().buildException();
-                }
-                if (statement.getProps().get(PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME) != null) {
-                    throw new SQLExceptionInfo.Builder(SQLExceptionCode.DEFAULT_COLUMN_FAMILY_ONLY_ON_CREATE_TABLE)
-                    .setTableName(table.getName().getString()).build().buildException();
-                }
-                
+
                 boolean isAddingPKColumn = false;
                 PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN);
-                
-                List<ColumnDef> columnDefs = statement.getColumnDefs();
-                if (columnDefs == null) {                    
-                    columnDefs = Lists.newArrayListWithExpectedSize(1);
-                }
 
-                List<Pair<byte[],Map<String,Object>>> families = Lists.newArrayList();                
                 List<PColumn> columns = Lists.newArrayListWithExpectedSize(columnDefs.size());
-
-                if ( columnDefs.size() > 0 ) {
-                    // Disallow setting these props for now on an add column, as that
-                    // would a bit of a strange thing to do. We can revisit later if
-                    // need be. We'd need to do the error checking we do in the else
-                    // if we want to support this.
-                    if (isImmutableRowsProp != null || multiTenantProp != null) {
-                        throw new SQLExceptionInfo.Builder(SQLExceptionCode.SET_UNSUPPORTED_PROP_ON_ALTER_TABLE)
-                        .setTableName(table.getName().getString()).build().buildException();
-                    }
+                Set<String> colFamiliesForPColumnsToBeAdded = new LinkedHashSet<>();
+                HashSet<String> existingColumnFamilies = existingColumnFamilies(table);
+                if (columnDefs.size() > 0 ) {
                     short nextKeySeq = SchemaUtil.getMaxKeySeq(table);
                     for( ColumnDef colDef : columnDefs) {
                         if (colDef != null && !colDef.isNull()) {
@@ -2054,10 +2117,11 @@ public class MetaDataClient {
                             pkName = table.getPKName() == null ? null : table.getPKName().getString();
                             keySeq = ++nextKeySeq;
                         } else {
-                            families.add(new Pair<byte[],Map<String,Object>>(column.getFamilyName().getBytes(),statement.getProps()));
+                            colFamiliesForPColumnsToBeAdded.add(column.getFamilyName().getString());
                         }
                         addColumnMutation(schemaName, tableName, column, colUpsert, null, pkName, keySeq, table.getBucketNum() != null);
                     }
+                    
                     // Add any new PK columns to end of index PK
                     if (isAddingPKColumn) {
                         for (PTable index : table.getIndexes()) {
@@ -2078,12 +2142,6 @@ public class MetaDataClient {
                     tableMetaData.addAll(connection.getMutationState().toMutations().next().getSecond());
                     connection.rollback();
                 } else {
-                    // Only support setting IMMUTABLE_ROWS=true and DISABLE_WAL=true on ALTER TABLE SET command
-                    // TODO: support setting HBase table properties too
-                    if (!statement.getProps().isEmpty()) {
-                        throw new SQLExceptionInfo.Builder(SQLExceptionCode.SET_UNSUPPORTED_PROP_ON_ALTER_TABLE)
-                        .setTableName(table.getName().getString()).build().buildException();
-                    }
                     // Check that HBase configured properly for mutable secondary indexing
                     // if we're changing from an immutable table to a mutable table and we
                     // have existing indexes.
@@ -2100,7 +2158,7 @@ public class MetaDataClient {
                         throwIfInsufficientColumns(schemaName, tableName, table.getPKColumns(), table.getBucketNum()!=null, multiTenant);
                     }
                 }
-                
+
                 if (isAddingPKColumn && !table.getIndexes().isEmpty()) {
                     for (PTable index : table.getIndexes()) {
                         incrementTableSeqNum(index, index.getType(), 1);
@@ -2109,29 +2167,101 @@ public class MetaDataClient {
                     connection.rollback();
                 }
                 long seqNum = incrementTableSeqNum(table, statement.getTableType(), 1, isImmutableRows, disableWAL, multiTenant);
-                
+
                 tableMetaData.addAll(connection.getMutationState().toMutations().next().getSecond());
                 connection.rollback();
                 // Force the table header row to be first
                 Collections.reverse(tableMetaData);
                 
-                Pair<byte[],Map<String,Object>> family = families.size() > 0 ? families.get(0) : null;
-                
+                byte[] family = colFamiliesForPColumnsToBeAdded.size() > 0 ? colFamiliesForPColumnsToBeAdded.iterator().next().getBytes() : null;
+
                 // Figure out if the empty column family is changing as a result of adding the new column
                 byte[] emptyCF = null;
                 byte[] projectCF = null;
                 if (table.getType() != PTableType.VIEW && family != null) {
                     if (table.getColumnFamilies().isEmpty()) {
-                        emptyCF = family.getFirst();
+                        emptyCF = family;
                     } else {
                         try {
-                            table.getColumnFamily(family.getFirst());
+                            table.getColumnFamily(family);
                         } catch (ColumnFamilyNotFoundException e) {
-                            projectCF = family.getFirst();
+                            projectCF = family;
                             emptyCF = SchemaUtil.getEmptyColumnFamily(table);
                         }
                     }
                 }
+                
+                Map<String, Map<String, Object>> allFamiliesProps = new HashMap<>(existingColumnFamilies.size() + stmtFamiliesPropsMap.size());
+                commonFamilyProps = Collections.unmodifiableMap(commonFamilyProps);
+                if (columnDefs.size() == 0) {
+                	// Add the common family props to all existing column families
+                	for (String existingColFamily : existingColumnFamilies) {
+                		Map<String, Object> m = new HashMap<String, Object>(commonFamilyProps.size());
+                		m.putAll(commonFamilyProps);
+                		allFamiliesProps.put(existingColFamily, m);
+                	}
+                } else {
+                	// Add the common family props to the column families of the columns being added
+                	for (String colFamily : colFamiliesForPColumnsToBeAdded) {
+                		Map<String, Object> m = new HashMap<String, Object>(commonFamilyProps.size());
+                		m.putAll(commonFamilyProps);
+                		allFamiliesProps.put(colFamily, m);
+                	}
+                }
+                
+                if (table.getColumnFamilies().isEmpty() && columnDefs.size() == 0 && !commonFamilyProps.isEmpty()) {
+                	allFamiliesProps.put(Bytes.toString(table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES : table.getDefaultFamilyName().getBytes() ), commonFamilyProps);
+                }
+                
+                // Now go through the column family properties specified in the statement
+                // and merge them with the common family properties.
+                for (String f : stmtFamiliesPropsMap.keySet()) {
+                    if (allFamiliesProps.get(f) != null) {
+                        Map<String, Object> props = allFamiliesProps.get(f);
+                        Map<String, Object> stmtProps = stmtFamiliesPropsMap.get(f);
+                        props.putAll(stmtProps);
+                    } else {
+                    	if (columnDefs.size() == 0) {
+                    		throw new ColumnFamilyNotFoundException(f);
+                    	} else {
+                    		if (!existingColumnFamilies.contains(f)) {
+                    			throw new ColumnFamilyNotFoundException(f);
+                    		} else {
+                    			// If the family already exists then an attempt was made to 
+                        		// add property for a column family that doesn't have a column
+                        		// being added in the statement. 
+                    			throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_SET_PROPERTY_FOR_COLUMN_NOT_ADDED).build()
+                                .buildException();
+                    		}
+                    	}
+                    }
+                }
+                
+                // Views are not allowed to have any of these properties.
+                if (table.getType() == PTableType.VIEW && (!stmtFamiliesPropsMap.isEmpty() || !commonFamilyProps.isEmpty() || !tableProps.isEmpty())) {
+                    throw new SQLExceptionInfo.Builder(SQLExceptionCode.VIEW_WITH_PROPERTIES).build()
+                    .buildException();
+                }
+                
+                HTableDescriptor newTableDesc = null;
+                if (!tableProps.isEmpty()) {
+                	newTableDesc = modifyTableProps(tableName, table, tableProps); 	
+                }
+                
+                if (columnDefs.size() > 0) {
+                	// Make sure that all the CFs of the table have the same TTL as the empty CF. 
+                	setTTLToEmptyCFTTL(allFamiliesProps, table, newTableDesc);
+                }
+                
+                List<Pair<byte[], Map<String, Object>>> families = new ArrayList<>(allFamiliesProps.size());
+                for (Entry<String, Map<String, Object>> entry : allFamiliesProps.entrySet()) {
+                    byte[] cf = entry.getKey().getBytes();
+                    Map<String, Object> props = entry.getValue();
+                    if (!props.isEmpty()) {
+                        families.add(new Pair<>(cf, props));
+                    }
+                }
+                
                 MetaDataMutationResult result = connection.getQueryServices().addColumn(tableMetaData, families, table);
                 try {
                     MutationCode code = processMutationResult(schemaName, tableName, result);
@@ -2142,6 +2272,7 @@ public class MetaDataClient {
                         }
                         return new MutationState(0,connection);
                     }
+
                     // Only update client side cache if we aren't adding a PK column to a table with indexes.
                     // We could update the cache manually then too, it'd just be a pain.
                     if (!isAddingPKColumn || table.getIndexes().isEmpty()) {
@@ -2194,8 +2325,49 @@ public class MetaDataClient {
             connection.setAutoCommit(wasAutoCommit);
         }
     }
+    
+   private void setTTLToEmptyCFTTL(Map<String, Map<String, Object>> familyProps, PTable table, 
+		   HTableDescriptor newTableDesc) throws SQLException {
+	   if (!familyProps.isEmpty()) {
+		   int emptyCFTTL = getTTLForEmptyCf(SchemaUtil.getEmptyColumnFamily(table), table.getPhysicalName().getBytes(), newTableDesc);
+		   for (String family : familyProps.keySet()) {
+			   Map<String, Object> props = familyProps.get(family) != null ? familyProps.get(family) : new HashMap<String, Object>();
+			   props.put(TTL, emptyCFTTL);
+		   }
+	   }
+   }
 
-
+    private HTableDescriptor modifyTableProps(String tableName, PTable table, Map<String, Object> tableProps) throws SQLException {
+    	byte[] tableNameBytes = Bytes.toBytes(tableName);
+    	ConnectionQueryServices services = connection.getQueryServices();
+    	HTableDescriptor existingTableDescriptor = services.getTableDescriptor(tableNameBytes);
+    	HTableDescriptor newTableDescriptor = new HTableDescriptor(existingTableDescriptor);
+    	// add all the table properties to the existing table descriptor
+    	for (Entry<String, Object> entry : tableProps.entrySet()) {
+    		newTableDescriptor.setValue(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
+    	}
+    	SQLException sqlE = null;
+    	try {
+    		services.modifyTable(tableNameBytes, newTableDescriptor);
+    		return newTableDescriptor;
+    	} catch (IOException e) {
+    		sqlE = ServerUtil.parseServerException(e);
+    		return null;
+    	} catch (InterruptedException e) {
+    		// restore the interrupt status
+    		Thread.currentThread().interrupt();
+    		sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.INTERRUPTED_EXCEPTION).setRootCause(e).build().buildException();
+    		return null;
+    	} catch (TimeoutException e) {
+    		sqlE = new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setRootCause(e.getCause() != null ? e.getCause() : e).build().buildException();
+    		return null;
+    	} finally {
+    		if (sqlE != null) {
+    			throw sqlE;
+    		}
+    	} 
+    }
+    
     private String dropColumnMutations(PTable table, List<PColumn> columnsToDrop, List<Mutation> tableMetaData) throws SQLException {
         String tenantId = connection.getTenantId() == null ? "" : connection.getTenantId().getString();
         String schemaName = table.getSchemaName().getString();
@@ -2557,4 +2729,35 @@ public class MetaDataClient {
         }
         return table.getTableStats();
     }
+    
+    private boolean isHColumnProperty(String propName) {
+    	return defaultColDescriptor.getValue(propName) != null;
+    }
+
+    private boolean isHTableProperty(String propName) {
+    	return !isHColumnProperty(propName) && !TableProperty.isPhoenixTableProperty(propName);
+    } 
+
+    private HashSet<String> existingColumnFamilies(PTable table) {
+    	List<PColumnFamily> cfs = table.getColumnFamilies();
+    	HashSet<String> cfNames = new HashSet<>(cfs.size());
+    	for (PColumnFamily cf : table.getColumnFamilies()) {
+    		cfNames.add(cf.getName().getString());
+    	}
+    	return cfNames;
+    }
+
+    private int getTTLForEmptyCf(byte[] emptyCf, byte[] tableNameBytes, HTableDescriptor tableDescriptor) throws SQLException {
+    	if (tableDescriptor == null) {
+    		tableDescriptor = connection.getQueryServices().getTableDescriptor(tableNameBytes);
+    	}
+    	HColumnDescriptor[] colDescriptors = tableDescriptor.getColumnFamilies();
+    	for (HColumnDescriptor colDesc : colDescriptors) {
+    		if (Bytes.equals(emptyCf, colDesc.getName())) {
+    			return colDesc.getTimeToLive();
+    		}
+    	}
+    	throw new IllegalArgumentException("No match for empty column family found");
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
new file mode 100644
index 0000000..605851e
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/TableProperty.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.schema;
+
+import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_ALTER_PROPERTY;
+import static org.apache.phoenix.exception.SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL;
+import static org.apache.phoenix.exception.SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY;
+import static org.apache.phoenix.exception.SQLExceptionCode.DEFAULT_COLUMN_FAMILY_ONLY_ON_CREATE_TABLE;
+import static org.apache.phoenix.exception.SQLExceptionCode.SALT_ONLY_ON_CREATE_TABLE;
+import static org.apache.phoenix.exception.SQLExceptionCode.VIEW_WITH_PROPERTIES;
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME;
+
+import java.sql.SQLException;
+
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+
+public enum TableProperty {
+	
+	IMMUTABLE_ROWS(PhoenixDatabaseMetaData.IMMUTABLE_ROWS, true, true),
+
+	MULTI_TENANT(PhoenixDatabaseMetaData.MULTI_TENANT, true, false),
+
+	DISABLE_WAL(PhoenixDatabaseMetaData.DISABLE_WAL, true, false),
+
+	SALT_BUCKETS(PhoenixDatabaseMetaData.SALT_BUCKETS, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, false, SALT_ONLY_ON_CREATE_TABLE, false),
+
+	DEFAULT_COLUMN_FAMILY(DEFAULT_COLUMN_FAMILY_NAME, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, false, DEFAULT_COLUMN_FAMILY_ONLY_ON_CREATE_TABLE, false),
+
+	TTL(HColumnDescriptor.TTL, COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL, true, CANNOT_ALTER_PROPERTY, false);
+
+	private final String propertyName;
+	private final SQLExceptionCode colFamSpecifiedException;
+	private final boolean isMutable; // whether or not a property can be changed through statements like ALTER TABLE.
+	private final SQLExceptionCode mutatingImmutablePropException;
+	private final boolean isValidOnView;
+
+	private TableProperty(String propertyName, boolean isMutable, boolean isValidOnView) {
+		this(propertyName, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, isMutable, CANNOT_ALTER_PROPERTY, isValidOnView);
+	}
+
+	private TableProperty(String propertyName, SQLExceptionCode colFamilySpecifiedException, boolean isMutable, boolean isValidOnView) {
+		this(propertyName, colFamilySpecifiedException, isMutable, CANNOT_ALTER_PROPERTY, isValidOnView);
+	}
+
+	private TableProperty(String propertyName, boolean isMutable, boolean isValidOnView, SQLExceptionCode isMutatingException) {
+		this(propertyName, COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY, isMutable, isMutatingException, isValidOnView);
+	}
+
+	private TableProperty(String propertyName, SQLExceptionCode colFamSpecifiedException, boolean isMutable, SQLExceptionCode mutatingException, boolean isValidOnView) {
+		this.propertyName = propertyName;
+		this.colFamSpecifiedException = colFamSpecifiedException;
+		this.isMutable = isMutable;
+		this.mutatingImmutablePropException = mutatingException;
+		this.isValidOnView = isValidOnView;
+	}
+
+	public static boolean isPhoenixTableProperty(String property) {
+		try {
+			TableProperty.valueOf(property); 	 
+		} catch (IllegalArgumentException e) {
+			return false;
+		}
+		return true;
+	}
+
+	// isQualified is true if column family name is specified in property name
+	public void validate(boolean isMutating, boolean isQualified, PTableType tableType) throws SQLException {
+		checkForColumnFamily(isQualified);
+		checkForMutability(isMutating);
+		checkIfApplicableForView(tableType);
+	}
+
+	private void checkForColumnFamily(boolean isQualified) throws SQLException {
+		if (isQualified) {
+			throw new SQLExceptionInfo.Builder(colFamSpecifiedException).setMessage(". Property: " + propertyName).build().buildException();
+		}
+	}
+
+	private void checkForMutability(boolean isMutating) throws SQLException {
+		if (isMutating && !isMutable) {
+			throw new SQLExceptionInfo.Builder(mutatingImmutablePropException).setMessage(". Property: " + propertyName).build().buildException();
+		}
+	}
+
+	private void checkIfApplicableForView(PTableType tableType)
+			throws SQLException {
+		if (tableType == PTableType.VIEW && !isValidOnView) { 
+			throw new SQLExceptionInfo.Builder(
+					VIEW_WITH_PROPERTIES).setMessage("Property: " + propertyName).build().buildException(); 
+		}
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/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 d0baaee..3b93954 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
@@ -945,15 +945,21 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
     @Test
     public void testSetSaltBucketOnAlterTable() throws Exception {
         long ts = nextTimestamp();
-        String query = "ALTER TABLE atable ADD xyz INTEGER SALT_BUCKETS=4";
         String url = getUrl() + ";" + PhoenixRuntime.CURRENT_SCN_ATTRIB + "=" + (ts + 5); // Run query at timestamp 5
         Connection conn = DriverManager.getConnection(url);
         try {
-            PreparedStatement statement = conn.prepareStatement(query);
+            PreparedStatement statement = conn.prepareStatement("ALTER TABLE atable ADD xyz INTEGER SALT_BUCKETS=4");
+            statement.execute();
+            fail();
+        } catch (SQLException e) { // expected
+            assertEquals(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN.getErrorCode(), e.getErrorCode());
+        }
+        try {
+            PreparedStatement statement = conn.prepareStatement("ALTER TABLE atable SET SALT_BUCKETS=4");
             statement.execute();
             fail();
         } catch (SQLException e) { // expected
-            assertTrue(e.getErrorCode() == SQLExceptionCode.SALT_ONLY_ON_CREATE_TABLE.getErrorCode());
+            assertEquals(SQLExceptionCode.SALT_ONLY_ON_CREATE_TABLE.getErrorCode(), e.getErrorCode());
         }
     }
 


[2/2] phoenix git commit: Allow ALTER TABLE

SET command to update HTableDescriptor and HColumnDescriptor properties (Samarth Jain/Alicia Ying Shu)Posted by sa...@apache.org.
Allow ALTER TABLE <table> SET command to update HTableDescriptor and HColumnDescriptor properties (Samarth Jain/Alicia Ying Shu)


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

Branch: refs/heads/4.0
Commit: 7578ee92b70f81a531c1b56b71584c6bd5aaaf93
Parents: cae025a
Author: Samarth <sa...@salesforce.com>
Authored: Fri Jan 9 16:35:03 2015 -0800
Committer: Samarth <sa...@salesforce.com>
Committed: Fri Jan 9 16:35:03 2015 -0800

----------------------------------------------------------------------
 .../apache/phoenix/end2end/AlterTableIT.java    | 923 ++++++++++++++++++-
 .../apache/phoenix/end2end/CreateTableIT.java   |  47 +-
 phoenix-core/src/main/antlr3/PhoenixSQL.g       |   2 +-
 .../phoenix/exception/SQLExceptionCode.java     |  15 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   5 +-
 .../phoenix/parse/AddColumnStatement.java       |  14 +-
 .../apache/phoenix/parse/ParseNodeFactory.java  |   4 +-
 .../phoenix/query/ConnectionQueryServices.java  |   3 +
 .../query/ConnectionQueryServicesImpl.java      |  40 +-
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +
 .../apache/phoenix/schema/MetaDataClient.java   | 305 +++++-
 .../apache/phoenix/schema/TableProperty.java    | 111 +++
 .../phoenix/compile/QueryCompilerTest.java      |  12 +-
 14 files changed, 1365 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
----------------------------------------------------------------------
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 2943fe6..9a262cb 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
@@ -17,12 +17,12 @@
  */
 package org.apache.phoenix.end2end;
 
+import static org.apache.hadoop.hbase.HColumnDescriptor.DEFAULT_REPLICATION_SCOPE;
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.apache.phoenix.util.TestUtil.closeConnection;
 import static org.apache.phoenix.util.TestUtil.closeStatement;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -33,11 +33,13 @@ import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.coprocessor.MetaDataProtocol;
 import org.apache.phoenix.exception.SQLExceptionCode;
@@ -49,11 +51,23 @@ import org.apache.phoenix.schema.TableNotFoundException;
 import org.apache.phoenix.util.IndexUtil;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.phoenix.util.SchemaUtil;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
-
-public class AlterTableIT extends BaseHBaseManagedTimeIT {
+/**
+ * 
+ * A lot of tests in this class test HBase level properties. As a result,
+ * tests need to have non-overlapping table names. The option of 
+ * disabling and dropping underlying HBase tables at the end of each test
+ * to avoid the overlap makes the test class really slow. By having the 
+ * test class run in its own cluster and having non overlapping table names
+ * we don't need to worry about dropping the tables between each test
+ * or at the end of test class. 
+ *
+ */
+public class AlterTableIT extends BaseOwnClusterHBaseManagedTimeIT {
     public static final String SCHEMA_NAME = "";
     public static final String DATA_TABLE_NAME = "T";
     public static final String INDEX_TABLE_NAME = "I";
@@ -61,7 +75,13 @@ public class AlterTableIT extends BaseHBaseManagedTimeIT {
     public static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "T");
     public static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "I");
     public static final String LOCAL_INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "LI");
-
+    
+    @BeforeClass
+    public static void doSetup() throws Exception {
+        Map<String, String> props = Collections.emptyMap();
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+    }
+    
     @Test
     public void testAlterTableWithVarBinaryKey() throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
@@ -195,36 +215,27 @@ public class AlterTableIT extends BaseHBaseManagedTimeIT {
 
     
     @Test
-    public void testAlterColumnFamilyProperty() throws Exception {
-
+    public void testSetPropertyAndAddColumnForNewColumnFamily() throws Exception {
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
-        
-        String ddl = "CREATE TABLE test_table " +
+        String ddl = "CREATE TABLE SETPROPNEWCF " +
                 "  (a_string varchar not null, col1 integer" +
                 "  CONSTRAINT pk PRIMARY KEY (a_string))\n";
         try {
-                conn.createStatement().execute(ddl);
-              
-                conn.createStatement().execute("ALTER TABLE TEST_TABLE ADD col2 integer IN_MEMORY=true");
-                
-                HTableInterface htable1 = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes("TEST_TABLE")); 
-                HTableDescriptor htableDesciptor1 = htable1.getTableDescriptor();
-                HColumnDescriptor hcolumnDescriptor1 = htableDesciptor1.getFamily(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES);
-                assertNotNull(hcolumnDescriptor1);
-               
-                try {
-                    
-                    conn.createStatement().execute("ALTER TABLE TEST_TABLE SET IN_MEMORY=false");
-                    fail("Should have caught exception.");
-                    
-                } catch (SQLException e) {
-                    assertTrue(e.getMessage(), e.getMessage().contains("ERROR 1025 (42Y84): Unsupported property set in ALTER TABLE command."));
-                } 
-        }finally {
+            conn.createStatement().execute(ddl);
+            conn.createStatement().execute("ALTER TABLE SETPROPNEWCF ADD CF.col2 integer CF.IN_MEMORY=true");
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPNEWCF")).getColumnFamilies();
+                assertEquals(2, columnFamilies.length);
+                assertEquals("0", columnFamilies[0].getNameAsString());
+                assertFalse(columnFamilies[0].isInMemory());
+                assertEquals("CF", columnFamilies[1].getNameAsString());
+                assertTrue(columnFamilies[1].isInMemory());
+            }
+        } finally {
             conn.close();
         }
-     }
+    }
   
     private static void assertIndexExists(Connection conn, boolean exists) throws SQLException {
         ResultSet rs = conn.getMetaData().getIndexInfo(null, SCHEMA_NAME, DATA_TABLE_NAME, false, false);
@@ -928,4 +939,860 @@ public class AlterTableIT extends BaseHBaseManagedTimeIT {
         ddl = "ALTER TABLE T ADD CF.STRING VARCHAR";
         conn1.createStatement().execute(ddl);
     }
+    
+    @Test
+    public void testSetHColumnProperties() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T1 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T1 SET REPLICATION_SCOPE=1";
+        conn1.createStatement().execute(ddl);
+        try (HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("T1")).getColumnFamilies();
+            assertEquals(1, columnFamilies.length);
+            assertEquals("0", columnFamilies[0].getNameAsString());
+            assertEquals(1, columnFamilies[0].getScope());
+        }
+    }
+    
+    @Test
+    public void testSetHTableProperties() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T2 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T2 SET COMPACTION_ENABLED=FALSE";
+        conn1.createStatement().execute(ddl);
+        try (HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("T2"));
+            assertEquals(1, tableDesc.getColumnFamilies().length);
+            assertEquals("0", tableDesc.getColumnFamilies()[0].getNameAsString());
+            assertEquals(Boolean.toString(false), tableDesc.getValue(HTableDescriptor.COMPACTION_ENABLED));
+        }
+    }
+    
+    @Test
+    public void testSetHTableAndHColumnProperties() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T3 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T3 SET COMPACTION_ENABLED = FALSE, REPLICATION_SCOPE = 1";
+        conn1.createStatement().execute(ddl);
+        try (HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("T3"));
+            HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+            assertEquals(1, columnFamilies.length);
+            assertEquals("0", columnFamilies[0].getNameAsString());
+            assertEquals(1, columnFamilies[0].getScope());
+            assertEquals(false, tableDesc.isCompactionEnabled());
+        }
+    }
+    
+    @Test
+    public void testSetHTableHColumnAndPhoenixTableProperties() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T3 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CF1.CREATION_TIME BIGINT,\n"
+                +"CF2.LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) IMMUTABLE_ROWS=true";
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.createStatement().execute(ddl);
+        assertImmutableRows(conn, "T3", true);
+        ddl = "ALTER TABLE T3 SET COMPACTION_ENABLED = FALSE, VERSIONS = 10";
+        conn.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T3 SET COMPACTION_ENABLED = FALSE, CF1.MIN_VERSIONS = 1, CF2.MIN_VERSIONS = 3, MIN_VERSIONS = 8, IMMUTABLE_ROWS=false";
+        conn.createStatement().execute(ddl);
+        assertImmutableRows(conn, "T3", false);
+        
+        try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("T3"));
+            HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+            assertEquals(3, columnFamilies.length);
+            
+            assertEquals("0", columnFamilies[0].getNameAsString());
+            assertEquals(8, columnFamilies[0].getMinVersions());
+            assertEquals(10, columnFamilies[0].getMaxVersions());
+            
+            assertEquals("CF1", columnFamilies[1].getNameAsString());
+            assertEquals(1, columnFamilies[1].getMinVersions());
+            assertEquals(10, columnFamilies[1].getMaxVersions());
+            
+            assertEquals("CF2", columnFamilies[2].getNameAsString());
+            assertEquals(3, columnFamilies[2].getMinVersions());
+            assertEquals(10, columnFamilies[2].getMaxVersions());
+            
+            assertEquals(Boolean.toString(false), tableDesc.getValue(HTableDescriptor.COMPACTION_ENABLED));
+        }
+    }
+    
+    @Test
+    public void testSpecifyingColumnFamilyForHTablePropertyFails() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T4 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T4 SET CF.COMPACTION_ENABLED = FALSE";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSpecifyingColumnFamilyForPhoenixTablePropertyFails() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T5 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T5 SET CF.DISABLE_WAL = TRUE";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSpecifyingColumnFamilyForTTLFails() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T6 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"CF.LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T6 SET CF.TTL = 86400";
+        try {
+            conn1.createStatement().execute(ddl);
+            fail();
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSetPropertyNeedsColumnFamilyToExist() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T7 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T7 SET CF.REPLICATION_SCOPE = 1";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.COLUMN_FAMILY_NOT_FOUND.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSetDefaultColumnFamilyNotAllowed() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T8 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE T8 SET DEFAULT_COLUMN_FAMILY = 'A'";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.DEFAULT_COLUMN_FAMILY_ONLY_ON_CREATE_TABLE.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSetHColumnOrHTablePropertiesOnViewsNotAllowed() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T9 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "CREATE VIEW v AS SELECT * FROM T9 WHERE CREATION_TIME = 1";
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER VIEW v SET REPLICATION_SCOPE = 1";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.VIEW_WITH_PROPERTIES.getErrorCode(), e.getErrorCode());
+        }
+        ddl = "ALTER VIEW v SET COMPACTION_ENABLED = FALSE";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.VIEW_WITH_PROPERTIES.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSetForSomePhoenixTablePropertiesOnViewsAllowed() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T10 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "CREATE VIEW v AS SELECT * FROM T10 WHERE CREATION_TIME = 1";
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER VIEW v SET IMMUTABLE_ROWS = TRUE";
+        conn1.createStatement().execute(ddl);
+        assertImmutableRows(conn1, "V", true);
+        ddl = "ALTER VIEW v SET IMMUTABLE_ROWS = FALSE";
+        conn1.createStatement().execute(ddl);
+        assertImmutableRows(conn1, "V", false);
+        ddl = "ALTER VIEW v SET DISABLE_WAL = TRUE";
+        try {
+            conn1.createStatement().execute(ddl);
+        } catch (SQLException e) {
+            assertEquals(SQLExceptionCode.VIEW_WITH_PROPERTIES.getErrorCode(), e.getErrorCode());
+        }
+    }
+    
+    @Test
+    public void testSettingPropertiesWhenTableHasDefaultColFamilySpecified() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE T11 (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"CF.LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) IMMUTABLE_ROWS=true, DEFAULT_COLUMN_FAMILY = 'XYZ'";
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.createStatement().execute(ddl);
+        assertImmutableRows(conn, "T11", true);
+        ddl = "ALTER TABLE T11 SET COMPACTION_ENABLED = FALSE, CF.REPLICATION_SCOPE=1, IMMUTABLE_ROWS = TRUE, TTL=1000";
+        conn.createStatement().execute(ddl);
+        assertImmutableRows(conn, "T11", true);
+        try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("T11"));
+            HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+            assertEquals(2, columnFamilies.length);
+            assertEquals("CF", columnFamilies[0].getNameAsString());
+            assertEquals(1, columnFamilies[0].getScope());
+            assertEquals(1000, columnFamilies[0].getTimeToLive());
+            assertEquals("XYZ", columnFamilies[1].getNameAsString());
+            assertEquals(DEFAULT_REPLICATION_SCOPE, columnFamilies[1].getScope());
+            assertEquals(1000, columnFamilies[1].getTimeToLive());
+            assertEquals(Boolean.toString(false), tableDesc.getValue(HTableDescriptor.COMPACTION_ENABLED));
+        }
+    }
+    
+    @Test
+    public void testNewColumnFamilyInheritsTTLOfEmptyCF() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String ddl = "CREATE TABLE NEWCFTTLTEST (\n"
+                +"ID1 VARCHAR(15) NOT NULL,\n"
+                +"ID2 VARCHAR(15) NOT NULL,\n"
+                +"CREATED_DATE DATE,\n"
+                +"CREATION_TIME BIGINT,\n"
+                +"LAST_USED DATE,\n"
+                +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) SALT_BUCKETS = 8, TTL = 1000";
+        Connection conn1 = DriverManager.getConnection(getUrl(), props);
+        conn1.createStatement().execute(ddl);
+        ddl = "ALTER TABLE NEWCFTTLTEST ADD CF.STRING VARCHAR";
+        conn1.createStatement().execute(ddl);
+        try (HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+            HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("NEWCFTTLTEST"));
+            HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+            assertEquals(2, columnFamilies.length);
+            assertEquals("0", columnFamilies[0].getNameAsString());
+            assertEquals(1000, columnFamilies[0].getTimeToLive());
+            assertEquals("CF", columnFamilies[1].getNameAsString());
+            assertEquals(1000, columnFamilies[1].getTimeToLive());
+        }
+    }
+    
+    private static void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException {
+        PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
+        assertEquals(expectedValue, pconn.getMetaDataCache().getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows());
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnForExistingColumnFamily() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        String ddl = "CREATE TABLE SETPROPEXISTINGCF " +
+                "  (a_string varchar not null, col1 integer, CF.col2 integer" +
+                "  CONSTRAINT pk PRIMARY KEY (a_string))\n";
+        try {
+            conn.createStatement().execute(ddl);
+            conn.createStatement().execute("ALTER TABLE SETPROPEXISTINGCF ADD CF.col3 integer CF.IN_MEMORY=true");
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPEXISTINGCF")).getColumnFamilies();
+                assertEquals(2, columnFamilies.length);
+                assertEquals("0", columnFamilies[0].getNameAsString());
+                assertFalse(columnFamilies[0].isInMemory());
+                assertEquals("CF", columnFamilies[1].getNameAsString());
+                assertTrue(columnFamilies[1].isInMemory());
+            }
+        } finally {
+            conn.close();
+        }
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnForNewAndExistingColumnFamily() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        String ddl = "CREATE TABLE SETPROPNEWEXISTCF " +
+                "  (a_string varchar not null, col1 integer, CF1.col2 integer" +
+                "  CONSTRAINT pk PRIMARY KEY (a_string))\n";
+        try {
+            conn.createStatement().execute(ddl);
+            conn.createStatement().execute("ALTER TABLE SETPROPNEWEXISTCF ADD col4 integer, CF1.col5 integer, CF2.col6 integer IN_MEMORY=true, CF1.REPLICATION_SCOPE=1, CF2.IN_MEMORY=false ");
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPNEWEXISTCF")).getColumnFamilies();
+                assertEquals(3, columnFamilies.length);
+                assertEquals("0", columnFamilies[0].getNameAsString());
+                assertTrue(columnFamilies[0].isInMemory());
+                assertEquals(0, columnFamilies[0].getScope());
+                assertEquals("CF1", columnFamilies[1].getNameAsString());
+                assertTrue(columnFamilies[1].isInMemory());
+                assertEquals(1, columnFamilies[1].getScope());
+                assertEquals("CF2", columnFamilies[2].getNameAsString());
+                assertFalse(columnFamilies[2].isInMemory());
+                assertEquals(0, columnFamilies[2].getScope());
+            }
+        } finally {
+            conn.close();
+        }
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnWhenTableHasExplicitDefaultColumnFamily() throws Exception {
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        String ddl = "CREATE TABLE SETPROPNEWEXISTDEFCOLFAM " +
+                "  (a_string varchar not null, col1 integer, CF1.col2 integer" +
+                "  CONSTRAINT pk PRIMARY KEY (a_string)) DEFAULT_COLUMN_FAMILY = 'XYZ'\n";
+        try {
+            conn.createStatement().execute(ddl);
+            conn.createStatement().execute("ALTER TABLE SETPROPNEWEXISTDEFCOLFAM ADD col4 integer, CF1.col5 integer, CF2.col6 integer IN_MEMORY=true, CF1.REPLICATION_SCOPE=1, CF2.IN_MEMORY=false, XYZ.REPLICATION_SCOPE=1 ");
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPNEWEXISTDEFCOLFAM")).getColumnFamilies();
+                assertEquals(3, columnFamilies.length);
+                assertEquals("CF1", columnFamilies[0].getNameAsString());
+                assertTrue(columnFamilies[0].isInMemory());
+                assertEquals(1, columnFamilies[0].getScope());
+                assertEquals("CF2", columnFamilies[1].getNameAsString());
+                assertFalse(columnFamilies[1].isInMemory());
+                assertEquals(0, columnFamilies[1].getScope());
+                assertEquals("XYZ", columnFamilies[2].getNameAsString());
+                assertTrue(columnFamilies[2].isInMemory());
+                assertEquals(1, columnFamilies[2].getScope());
+            }
+        } finally {
+            conn.close();
+        }
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnFailsForColumnFamilyNotPresentInAddCol() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	String ddl = "CREATE TABLE ADDCOLNOTPRESENT " +
+    			"  (a_string varchar not null, col1 integer, CF1.col2 integer" +
+    			"  CONSTRAINT pk PRIMARY KEY (a_string)) DEFAULT_COLUMN_FAMILY = 'XYZ'\n";
+    	try {
+    		conn.createStatement().execute(ddl);
+    		try {
+    			conn.createStatement().execute("ALTER TABLE ADDCOLNOTPRESENT ADD col4 integer CF1.REPLICATION_SCOPE=1, XYZ.IN_MEMORY=true ");
+    			fail();
+    		} catch(SQLException e) {
+    			assertEquals(SQLExceptionCode.CANNOT_SET_PROPERTY_FOR_COLUMN_NOT_ADDED.getErrorCode(), e.getErrorCode());
+    		}
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnForDifferentColumnFamilies() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	String ddl = "CREATE TABLE SETPROPDIFFCFSTABLE " +
+    			"  (a_string varchar not null, col1 integer, CF1.col2 integer, CF2.col3 integer" +
+    			"  CONSTRAINT pk PRIMARY KEY (a_string)) DEFAULT_COLUMN_FAMILY = 'XYZ'\n";
+    	try {
+    		conn.createStatement().execute(ddl);
+    		conn.createStatement().execute("ALTER TABLE SETPROPDIFFCFSTABLE ADD col4 integer, CF1.col5 integer, CF2.col6 integer, CF3.col7 integer CF1.REPLICATION_SCOPE=1, CF1.IN_MEMORY=false, IN_MEMORY=true ");
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPDIFFCFSTABLE")).getColumnFamilies();
+                assertEquals(4, columnFamilies.length);
+                assertEquals("CF1", columnFamilies[0].getNameAsString());
+                assertFalse(columnFamilies[0].isInMemory());
+                assertEquals(1, columnFamilies[0].getScope());
+                assertEquals("CF2", columnFamilies[1].getNameAsString());
+                assertTrue(columnFamilies[1].isInMemory());
+                assertEquals(0, columnFamilies[1].getScope());
+                assertEquals("CF3", columnFamilies[2].getNameAsString());
+                assertTrue(columnFamilies[2].isInMemory());
+                assertEquals(0, columnFamilies[2].getScope());
+                assertEquals("XYZ", columnFamilies[3].getNameAsString());
+                assertTrue(columnFamilies[3].isInMemory());
+                assertEquals(0, columnFamilies[3].getScope());
+            }
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnUsingDefaultColumnFamilySpecifier() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	String ddl = "CREATE TABLE SETPROPDEFCF " +
+    			"  (a_string varchar not null, col1 integer, CF1.col2 integer" +
+    			"  CONSTRAINT pk PRIMARY KEY (a_string)) DEFAULT_COLUMN_FAMILY = 'XYZ'\n";
+    	try {
+            conn.createStatement().execute(ddl);
+            conn.createStatement().execute("ALTER TABLE SETPROPDEFCF ADD col4 integer XYZ.REPLICATION_SCOPE=1 ");
+            conn.createStatement().execute("ALTER TABLE SETPROPDEFCF ADD XYZ.col5 integer IN_MEMORY=true ");
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+                HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("SETPROPDEFCF")).getColumnFamilies();
+                assertEquals(2, columnFamilies.length);
+                assertEquals("CF1", columnFamilies[0].getNameAsString());
+                assertFalse(columnFamilies[0].isInMemory());
+                assertEquals(0, columnFamilies[0].getScope());
+                assertEquals("XYZ", columnFamilies[1].getNameAsString());
+                assertTrue(columnFamilies[1].isInMemory());
+                assertEquals(1, columnFamilies[1].getScope());
+            }
+        } finally {
+            conn.close();
+        }
+    }
+    
+    @Test
+    public void testSetPropertyAndAddColumnForDefaultColumnFamily() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	String ddl = "CREATE TABLE TT " +
+    			"  (a_string varchar not null, col1 integer" +
+    			"  CONSTRAINT pk PRIMARY KEY (a_string))\n";
+    	try {
+    		conn.createStatement().execute(ddl);
+    		conn.createStatement().execute("ALTER TABLE TT ADD col2 integer IN_MEMORY=true");
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("TT")).getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals("0", columnFamilies[0].getNameAsString());
+    			assertTrue(columnFamilies[0].isInMemory());
+    		}
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testAddNewColumnFamilyProperties() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+
+    	try {
+    		conn.createStatement()
+    		.execute(
+    				"CREATE TABLE mixed_add_table "
+    						+ "  (a_string varchar not null, col1 integer, cf1.col2 integer, col3 integer , cf2.col4 integer "
+    						+ "  CONSTRAINT pk PRIMARY KEY (a_string)) immutable_rows=true , SALT_BUCKETS=3 ");
+
+    		String ddl = "Alter table mixed_add_table add cf3.col5 integer, cf4.col6 integer in_memory=true";
+    		conn.createStatement().execute(ddl);
+
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("MIXED_ADD_TABLE"));
+    			assertTrue(tableDesc.isCompactionEnabled());
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(5, columnFamilies.length);
+    			assertEquals("0", columnFamilies[0].getNameAsString());
+    			assertFalse(columnFamilies[0].isInMemory());
+    			assertEquals("CF1", columnFamilies[1].getNameAsString());
+    			assertFalse(columnFamilies[1].isInMemory());
+    			assertEquals("CF2", columnFamilies[2].getNameAsString());
+    			assertFalse(columnFamilies[2].isInMemory());
+    			assertEquals("CF3", columnFamilies[3].getNameAsString());
+    			assertTrue(columnFamilies[3].isInMemory());
+    			assertEquals("CF4", columnFamilies[4].getNameAsString());
+    			assertTrue(columnFamilies[4].isInMemory());
+    		}	
+    	} finally {
+    		conn.close();
+    	}
+    }
+
+    @Test
+    public void testAddProperyToExistingColumnFamily() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+
+    	try {
+    		conn.createStatement()
+    		.execute(
+    				"CREATE TABLE exist_table "
+    						+ "  (a_string varchar not null, col1 integer, cf1.col2 integer, col3 integer , cf2.col4 integer "
+    						+ "  CONSTRAINT pk PRIMARY KEY (a_string)) immutable_rows=true , SALT_BUCKETS=3 ");
+
+    		String ddl = "Alter table exist_table add cf1.col5 integer in_memory=true";
+    		conn.createStatement().execute(ddl);
+
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("EXIST_TABLE"));
+    			assertTrue(tableDesc.isCompactionEnabled());
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(3, columnFamilies.length);
+    			assertEquals("0", columnFamilies[0].getNameAsString());
+    			assertFalse(columnFamilies[0].isInMemory());
+    			assertEquals("CF1", columnFamilies[1].getNameAsString());
+    			assertTrue(columnFamilies[1].isInMemory());
+    			assertEquals("CF2", columnFamilies[2].getNameAsString());
+    			assertFalse(columnFamilies[2].isInMemory());
+    		}
+    	} finally {
+    		conn.close();
+    	}
+    }
+
+    @Test
+    public void testAddTTLToExistingColumnFamily() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+
+    	try {
+    		String ddl = "CREATE TABLE exist_test (pk char(2) not null primary key, col1 integer, b.col1 integer) SPLIT ON ('EA','EZ')";
+    		conn.createStatement().execute(ddl);
+    		ddl = "ALTER TABLE exist_test add b.col2 varchar ttl=30";
+    		conn.createStatement().execute(ddl);
+    		fail();
+    	} catch (SQLException e) {
+    		assertEquals(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN.getErrorCode(), e.getErrorCode());
+    	} finally {
+    		conn.close();
+    	}
+    }
+
+    @Test
+    public void testSettingTTLWhenAddingColumnNotAllowed() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+
+    	try {
+    		String ddl = "CREATE TABLE ttl_test (pk char(2) not null primary key) TTL=100 SPLIT ON ('EA','EZ')";
+    		conn.createStatement().execute(ddl);
+    		ddl = "ALTER TABLE ttl_test add col1 varchar ttl=30";
+    		conn.createStatement().execute(ddl);
+    		fail();
+    	} catch (SQLException e) {
+    		assertEquals(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN.getErrorCode(), e.getErrorCode());
+    	}		
+    	try {
+    		String ddl = "ALTER TABLE ttl_test add col1 varchar a.ttl=30";
+    		conn.createStatement().execute(ddl);
+    		fail();
+    	} catch (SQLException e) {
+    		assertEquals(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN.getErrorCode(), e.getErrorCode());
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetTTLForTableWithOnlyPKCols() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS ttl_test2 ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'";
+            conn.createStatement().execute(ddl);
+            try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("TTL_TEST2"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals("XYZ", columnFamilies[0].getNameAsString());
+    			assertEquals(86400, columnFamilies[0].getTimeToLive());
+    		} 
+    		ddl = "ALTER TABLE ttl_test2 SET TTL=30";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("TTL_TEST2"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals(30, columnFamilies[0].getTimeToLive());
+    			assertEquals("XYZ", columnFamilies[0].getNameAsString());
+    		} 
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetHColumnPropertyForTableWithOnlyPKCols() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS SETHCPROPPKONLY ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'";
+            conn.createStatement().execute(ddl);
+            ddl = "ALTER TABLE SETHCPROPPKONLY SET IN_MEMORY=true";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("SETHCPROPPKONLY"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals("XYZ", columnFamilies[0].getNameAsString());
+    		} 
+    	} finally {
+    		conn.close();
+    	}
+    	
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS SETHCPROPPKONLY2 ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4";
+            conn.createStatement().execute(ddl);
+            ddl = "ALTER TABLE SETHCPROPPKONLY2 SET IN_MEMORY=true";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("SETHCPROPPKONLY2"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals("0", columnFamilies[0].getNameAsString());
+    		} 
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetHColumnPropertyAndAddColumnForDefaultCFForTableWithOnlyPKCols() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS SETHCPROPADDCOLPKONLY ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'";
+            conn.createStatement().execute(ddl);
+            ddl = "ALTER TABLE SETHCPROPADDCOLPKONLY ADD COL3 INTEGER IN_MEMORY=true";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("SETHCPROPADDCOLPKONLY"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(1, columnFamilies.length);
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals("XYZ", columnFamilies[0].getNameAsString());
+    		} 
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSetHColumnPropertyAndAddColumnForNewCFForTableWithOnlyPKCols() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS SETHCPROPADDNEWCFCOLPKONLY ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'";
+            conn.createStatement().execute(ddl);
+            ddl = "ALTER TABLE SETHCPROPADDNEWCFCOLPKONLY ADD NEWCF.COL3 INTEGER IN_MEMORY=true";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("SETHCPROPADDNEWCFCOLPKONLY"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(2, columnFamilies.length);
+    			assertEquals("NEWCF", columnFamilies[0].getNameAsString());
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals("XYZ", columnFamilies[1].getNameAsString());
+    			assertEquals(false, columnFamilies[1].isInMemory());
+    		} 
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testTTLAssignmentForNewEmptyCF() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	conn.setAutoCommit(false);
+    	try {
+    	   	String ddl = "create table IF NOT EXISTS NEWEMPTYCFTABLE ("
+        		    + " id char(1) NOT NULL,"
+        		    + " col1 integer NOT NULL,"
+        		    + " col2 bigint NOT NULL,"
+        		    + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+        		    + " ) TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'";
+            conn.createStatement().execute(ddl);
+            ddl = "ALTER TABLE NEWEMPTYCFTABLE ADD NEWCF.COL3 INTEGER IN_MEMORY=true";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("NEWEMPTYCFTABLE"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(2, columnFamilies.length);
+    			assertEquals("NEWCF", columnFamilies[0].getNameAsString());
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals(86400, columnFamilies[0].getTimeToLive());
+    			assertEquals("XYZ", columnFamilies[1].getNameAsString());
+    			assertEquals(false, columnFamilies[1].isInMemory());
+    			assertEquals(86400, columnFamilies[1].getTimeToLive());
+    		}
+    		
+    		ddl = "ALTER TABLE NEWEMPTYCFTABLE SET TTL=1000";
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("NEWEMPTYCFTABLE"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(2, columnFamilies.length);
+    			assertEquals("NEWCF", columnFamilies[0].getNameAsString());
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals(1000, columnFamilies[0].getTimeToLive());
+    			assertEquals("XYZ", columnFamilies[1].getNameAsString());
+    			assertEquals(false, columnFamilies[1].isInMemory());
+    			assertEquals(86400, columnFamilies[1].getTimeToLive());
+    		}
+    		
+    		// the new column will be assigned to the column family XYZ. With the a KV column getting added for XYZ, 
+    		// the column family will start showing up in PTable.getColumnFamilies() after the column is added. Thus
+    		// being a new column family for the PTable, it will end up inheriting the TTL of the emptyCF (NEWCF).
+    		ddl = "ALTER TABLE NEWEMPTYCFTABLE ADD COL3 INTEGER"; 
+    		conn.createStatement().execute(ddl);
+    		conn.commit();
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("NEWEMPTYCFTABLE"));
+    			HColumnDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
+    			assertEquals(2, columnFamilies.length);
+    			assertEquals("NEWCF", columnFamilies[0].getNameAsString());
+    			assertEquals(true, columnFamilies[0].isInMemory());
+    			assertEquals(1000, columnFamilies[0].getTimeToLive());
+    			assertEquals("XYZ", columnFamilies[1].getNameAsString());
+    			assertEquals(false, columnFamilies[1].isInMemory());
+    			assertEquals(1000, columnFamilies[1].getTimeToLive());
+    		}
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
+    @Test
+    public void testSettingNotHColumnNorPhoenixPropertyEndsUpAsHTableProperty() throws Exception {
+    	Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+    	Connection conn = DriverManager.getConnection(getUrl(), props);
+    	try {   	
+    		String ddl = "create table IF NOT EXISTS RANDMONPROPTABLE ("
+    				+ " id char(1) NOT NULL,"
+    				+ " col1 integer NOT NULL,"
+    				+ " col2 bigint NOT NULL,"
+    				+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)"
+    				+ " )";
+    		conn.createStatement().execute(ddl);
+    		ddl = "ALTER TABLE RANDMONPROPTABLE ADD NEWCF.COL3 INTEGER NEWCF.UNKNOWN_PROP='ABC'";
+    		try {
+    			conn.createStatement().execute(ddl);
+    		} catch (SQLException e) {
+    			assertEquals(SQLExceptionCode.CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN.getErrorCode(), e.getErrorCode());
+    		}
+    		ddl = "ALTER TABLE RANDMONPROPTABLE SET UNKNOWN_PROP='ABC'";
+    		conn.createStatement().execute(ddl);
+    		try (HBaseAdmin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
+    			HTableDescriptor tableDesc = admin.getTableDescriptor(Bytes.toBytes("RANDMONPROPTABLE"));
+    			assertEquals("ABC", tableDesc.getValue("UNKNOWN_PROP"));
+    		}
+    	} finally {
+    		conn.close();
+    	}
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
index e3bec28..31abd9b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
@@ -17,7 +17,7 @@
  */
 package org.apache.phoenix.end2end;
 
-import static org.apache.hadoop.hbase.HColumnDescriptor.DEFAULT_TTL;
+import static org.apache.hadoop.hbase.HColumnDescriptor.DEFAULT_REPLICATION_SCOPE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -198,12 +198,12 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
      * Tests that when:
      * 1) DDL has both pk as well as key value columns
      * 2) Key value columns have both default and explicit column family names
-     * 3) TTL specifier has the explicit column family name.
+     * 3) Replication scope specifier has the explicit column family name.
      * 
      * Then:
-     * 1)TTL is set.
-     * 2)The default column family has DEFAULT_TTL.
-     * 3)The explicit column family has the TTL specified in DDL.  
+     * 1)REPLICATION_SCOPE is set.
+     * 2)The default column family has DEFAULT_REPLICATION_SCOPE.
+     * 3)The explicit column family has the REPLICATION_SCOPE specified in DDL.  
      */
     @Test
     public void testCreateTableColumnFamilyHBaseAttribs4() throws Exception {
@@ -213,7 +213,7 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
     			+ " b.col2 bigint,"
     			+ " col3 bigint, "
     			+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)"
-    			+ " ) b.TTL=86400, SALT_BUCKETS = 4";
+    			+ " ) b.REPLICATION_SCOPE=1, SALT_BUCKETS = 4";
     	long ts = nextTimestamp();
     	Properties props = new Properties();
     	props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
@@ -223,20 +223,20 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
     	HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("TEST4")).getColumnFamilies();
     	assertEquals(2, columnFamilies.length);
     	assertEquals("0", columnFamilies[0].getNameAsString());
-    	assertEquals(DEFAULT_TTL, columnFamilies[0].getTimeToLive());
+    	assertEquals(DEFAULT_REPLICATION_SCOPE, columnFamilies[0].getScope());
     	assertEquals("B", columnFamilies[1].getNameAsString());
-    	assertEquals(86400, columnFamilies[1].getTimeToLive());
+    	assertEquals(1, columnFamilies[1].getScope());
     }
     
     /**
      * Tests that when:
      * 1) DDL has both pk as well as key value columns
      * 2) Key value columns have explicit column family names
-     * 3) Different TTL specifiers for different column family names.
+     * 3) Different REPLICATION_SCOPE specifiers for different column family names.
      * 
      * Then:
-     * 1)TTL is set.
-     * 2)Each explicit column family has the TTL as specified in DDL.  
+     * 1)REPLICATION_SCOPE is set.
+     * 2)Each explicit column family has the REPLICATION_SCOPE as specified in DDL.  
      */
     @Test
     public void testCreateTableColumnFamilyHBaseAttribs5() throws Exception {
@@ -246,7 +246,7 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
     			+ " b.col2 bigint,"
     			+ " c.col3 bigint, "
     			+ " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)"
-    			+ " ) b.TTL=86400, c.TTL=10000, SALT_BUCKETS = 4";
+    			+ " ) b.REPLICATION_SCOPE=0, c.REPLICATION_SCOPE=1, SALT_BUCKETS = 4";
     	long ts = nextTimestamp();
     	Properties props = new Properties();
     	props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
@@ -256,9 +256,9 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
     	HColumnDescriptor[] columnFamilies = admin.getTableDescriptor(Bytes.toBytes("TEST5")).getColumnFamilies();
     	assertEquals(2, columnFamilies.length);
     	assertEquals("B", columnFamilies[0].getNameAsString());
-    	assertEquals(86400, columnFamilies[0].getTimeToLive());
+    	assertEquals(0, columnFamilies[0].getScope());
     	assertEquals("C", columnFamilies[1].getNameAsString());
-    	assertEquals(10000, columnFamilies[1].getTimeToLive());
+    	assertEquals(1, columnFamilies[1].getScope());
     }
     
     /**
@@ -363,4 +363,23 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
             assertEquals(SQLExceptionCode.INVALID_NOT_NULL_CONSTRAINT.getErrorCode(),sqle.getErrorCode());
         }
    }
+    
+    @Test
+    public void testSpecifyingColumnFamilyForTTLFails() throws Exception {
+        String ddl = "create table IF NOT EXISTS TESTXYZ ("
+                + " id char(1) NOT NULL,"
+                + " col1 integer NOT NULL,"
+                + " CF.col2 integer,"
+                + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)"
+                + " ) DEFAULT_COLUMN_FAMILY='a', CF.TTL=10000, SALT_BUCKETS = 4";
+        long ts = nextTimestamp();
+        Properties props = new Properties();
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        try {
+            conn.createStatement().execute(ddl);
+        } catch (SQLException sqle) {
+            assertEquals(SQLExceptionCode.COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL.getErrorCode(),sqle.getErrorCode());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/antlr3/PhoenixSQL.g
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g b/phoenix-core/src/main/antlr3/PhoenixSQL.g
index 2223380..c7a84cf 100644
--- a/phoenix-core/src/main/antlr3/PhoenixSQL.g
+++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g
@@ -494,7 +494,7 @@ alter_index_node returns [AlterIndexStatement ret]
 // Parse an alter table statement.
 alter_table_node returns [AlterTableStatement ret]
     :   ALTER (TABLE | v=VIEW) t=from_table_name
-        ( (DROP COLUMN (IF ex=EXISTS)? c=column_names) | (ADD (IF NOT ex=EXISTS)? (d=column_defs) (p=properties)?) | (SET (p=properties)) )
+        ( (DROP COLUMN (IF ex=EXISTS)? c=column_names) | (ADD (IF NOT ex=EXISTS)? (d=column_defs) (p=fam_properties)?) | (SET (p=fam_properties)) )
         { PTableType tt = v==null ? (QueryConstants.SYSTEM_SCHEMA_NAME.equals(t.getSchemaName()) ? PTableType.SYSTEM : PTableType.TABLE) : PTableType.VIEW; ret = ( c == null ? factory.addColumn(factory.namedTable(null,t), tt, d, ex!=null, p) : factory.dropColumn(factory.namedTable(null,t), tt, c, ex!=null) ); }
     ;
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index d23acc0..5035d0c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -28,7 +28,6 @@ import org.apache.phoenix.schema.ColumnAlreadyExistsException;
 import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.schema.ColumnNotFoundException;
 import org.apache.phoenix.schema.ConcurrentTableMutationException;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.ReadOnlyTableException;
 import org.apache.phoenix.schema.SequenceAlreadyExistsException;
 import org.apache.phoenix.schema.SequenceNotFoundException;
@@ -36,6 +35,7 @@ import org.apache.phoenix.schema.StaleRegionBoundaryCacheException;
 import org.apache.phoenix.schema.TableAlreadyExistsException;
 import org.apache.phoenix.schema.TableNotFoundException;
 import org.apache.phoenix.schema.TypeMismatchException;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.util.MetaDataUtil;
 
 import com.google.common.collect.Maps;
@@ -204,8 +204,8 @@ public enum SQLExceptionCode {
     // Table properties exception.
     INVALID_BUCKET_NUM(1021, "42Y80", "Salt bucket numbers should be with 1 and 256."),
     NO_SPLITS_ON_SALTED_TABLE(1022, "42Y81", "Should not specify split points on salted table with default row key order."),
-    SALT_ONLY_ON_CREATE_TABLE(1024, "42Y83", "Salt bucket number may only be specified when creating a table."),
-    SET_UNSUPPORTED_PROP_ON_ALTER_TABLE(1025, "42Y84", "Unsupported property set in ALTER TABLE command."),
+    SALT_ONLY_ON_CREATE_TABLE(1024, "42Y82", "Salt bucket number may only be specified when creating a table."),
+    SET_UNSUPPORTED_PROP_ON_ALTER_TABLE(1025, "42Y83", "Unsupported property set in ALTER TABLE command."),
     CANNOT_ADD_NOT_NULLABLE_COLUMN(1038, "42Y84", "Only nullable columns may be added for a pre-existing table."),
     NO_MUTABLE_INDEXES(1026, "42Y85", "Mutable secondary indexes are only supported for HBase version " + MetaDataUtil.decodeHBaseVersionAsString(PhoenixDatabaseMetaData.MUTABLE_SI_VERSION_THRESHOLD) + " and above."),
     INVALID_FILTER_ON_IMMUTABLE_ROWS(1027, "42Y86", "All columns referenced in a WHERE clause must be available in every index for a table with immutable rows."),
@@ -222,8 +222,13 @@ public enum SQLExceptionCode {
     VIEW_WHERE_IS_CONSTANT(1045, "43A02", "WHERE clause in VIEW should not evaluate to a constant."),
     CANNOT_UPDATE_VIEW_COLUMN(1046, "43A03", "Column updated in VIEW may not differ from value specified in WHERE clause."),
     TOO_MANY_INDEXES(1047, "43A04", "Too many indexes have already been created on the physical table."),
-    NO_LOCAL_INDEX_ON_TABLE_WITH_IMMUTABLE_ROWS(1048,"43A04","Local indexes aren't allowed on tables with immutable rows."),
-        
+    NO_LOCAL_INDEX_ON_TABLE_WITH_IMMUTABLE_ROWS(1048,"43A05","Local indexes aren't allowed on tables with immutable rows."),
+    COLUMN_FAMILY_NOT_ALLOWED_TABLE_PROPERTY(1049, "43A06", "Column family not allowed for table properties."),
+    COLUMN_FAMILY_NOT_ALLOWED_FOR_TTL(1050, "43A07", "Setting TTL for a column family not supported. You can only have TTL for the entire table."),
+    CANNOT_ALTER_PROPERTY(1051, "43A08", "Property can be specified or changed only when creating a table"),
+    CANNOT_SET_PROPERTY_FOR_COLUMN_NOT_ADDED(1052, "43A09", "Property cannot be specified for a column family that is not being added or modified"),
+    CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN(1053, "43A10", "Table level property cannot be set when adding a column"),
+    
     /** Sequence related */
     SEQUENCE_ALREADY_EXIST(1200, "42Z00", "Sequence already exists.", new Factory() {
         @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
index 01fefdd..0bb0b14 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java
@@ -30,7 +30,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Pair;
@@ -726,7 +725,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho
 
     private static class ExecutableAddColumnStatement extends AddColumnStatement implements CompilableStatement {
 
-        ExecutableAddColumnStatement(NamedTableNode table, PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, Map<String, Object> props) {
+        ExecutableAddColumnStatement(NamedTableNode table, PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, ListMultimap<String,Pair<String,Object>> props) {
             super(table, tableType, columnDefs, ifNotExists, props);
         }
 
@@ -851,7 +850,7 @@ public class PhoenixStatement implements Statement, SQLCloseable, org.apache.pho
         }
         
         @Override
-        public AddColumnStatement addColumn(NamedTableNode table,  PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, Map<String,Object> props) {
+        public AddColumnStatement addColumn(NamedTableNode table,  PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, ListMultimap<String,Pair<String,Object>> props) {
             return new ExecutableAddColumnStatement(table, tableType, columnDefs, ifNotExists, props);
         }
         

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java
index d1b2424..1890d31 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AddColumnStatement.java
@@ -17,21 +17,23 @@
  */
 package org.apache.phoenix.parse;
 
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
+import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.schema.PTableType;
 
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.ListMultimap;
+
 public class AddColumnStatement extends AlterTableStatement {
     private final List<ColumnDef> columnDefs;
     private final boolean ifNotExists;
-    private final Map<String,Object> props;
+    private final ListMultimap<String,Pair<String,Object>> props;
     
-    protected AddColumnStatement(NamedTableNode table, PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, Map<String, Object> props) {
+    protected AddColumnStatement(NamedTableNode table, PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, ListMultimap<String,Pair<String,Object>> props) {
         super(table, tableType);
         this.columnDefs = columnDefs;
-        this.props = props == null ? Collections.<String,Object>emptyMap() : props;
+        this.props = props == null ? ImmutableListMultimap.<String,Pair<String,Object>>of()  : props;
         this.ifNotExists = ifNotExists;
     }
 
@@ -43,7 +45,7 @@ public class AddColumnStatement extends AlterTableStatement {
         return ifNotExists;
     }
 
-    public Map<String,Object> getProps() {
+    public ListMultimap<String,Pair<String,Object>> getProps() {
         return props;
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
index 0329ef4..cac36f9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
@@ -41,13 +41,13 @@ import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunction;
 import org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo;
 import org.apache.phoenix.parse.JoinTableNode.JoinType;
 import org.apache.phoenix.parse.LikeParseNode.LikeType;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.PIndexState;
 import org.apache.phoenix.schema.PTable.IndexType;
 import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.schema.SortOrder;
 import org.apache.phoenix.schema.TypeMismatchException;
 import org.apache.phoenix.schema.stats.StatisticsCollectionScope;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.util.SchemaUtil;
 
 import com.google.common.collect.ListMultimap;
@@ -301,7 +301,7 @@ public class ParseNodeFactory {
         return new SequenceValueParseNode(tableName, SequenceValueParseNode.Op.NEXT_VALUE);
     }
 
-    public AddColumnStatement addColumn(NamedTableNode table,  PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, Map<String,Object> props) {
+    public AddColumnStatement addColumn(NamedTableNode table,  PTableType tableType, List<ColumnDef> columnDefs, boolean ifNotExists, ListMultimap<String,Pair<String,Object>> props) {
         return new AddColumnStatement(table, tableType, columnDefs, ifNotExists, props);
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
index 8826b48..f0fbf1d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
@@ -17,10 +17,12 @@
  */
 package org.apache.phoenix.query;
 
+import java.io.IOException;
 import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -110,4 +112,5 @@ public interface ConnectionQueryServices extends QueryServices, MetaDataMutated
     
     public void clearCache() throws SQLException;
     public int getSequenceSaltBuckets();
+    public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException, InterruptedException, TimeoutException;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 2a5ff4a..483bedc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -573,25 +573,25 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
     
     private HTableDescriptor generateTableDescriptor(byte[] tableName, HTableDescriptor existingDesc, PTableType tableType, Map<String,Object> tableProps, List<Pair<byte[],Map<String,Object>>> families, byte[][] splits) throws SQLException {
         String defaultFamilyName = (String)tableProps.remove(PhoenixDatabaseMetaData.DEFAULT_COLUMN_FAMILY_NAME);                
-        HTableDescriptor descriptor = (existingDesc != null) ? new HTableDescriptor(existingDesc) : 
+        HTableDescriptor tableDescriptor = (existingDesc != null) ? new HTableDescriptor(existingDesc) : 
           new HTableDescriptor(TableName.valueOf(tableName));
         for (Entry<String,Object> entry : tableProps.entrySet()) {
             String key = entry.getKey();
             Object value = entry.getValue();
-            descriptor.setValue(key, value == null ? null : value.toString());
+            tableDescriptor.setValue(key, value == null ? null : value.toString());
         }
         if (families.isEmpty()) {
             if (tableType != PTableType.VIEW) {
                 byte[] defaultFamilyByes = defaultFamilyName == null ? QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES : Bytes.toBytes(defaultFamilyName);
                 // Add dummy column family so we have key values for tables that 
                 HColumnDescriptor columnDescriptor = generateColumnFamilyDescriptor(new Pair<byte[],Map<String,Object>>(defaultFamilyByes,Collections.<String,Object>emptyMap()), tableType);
-                descriptor.addFamily(columnDescriptor);
+                tableDescriptor.addFamily(columnDescriptor);
             }
         } else {
             for (Pair<byte[],Map<String,Object>> family : families) {
                 // If family is only in phoenix description, add it. otherwise, modify its property accordingly.
                 byte[] familyByte = family.getFirst();
-                if (descriptor.getFamily(familyByte) == null) {
+                if (tableDescriptor.getFamily(familyByte) == null) {
                     if (tableType == PTableType.VIEW) {
                         String fullTableName = Bytes.toString(tableName);
                         throw new ReadOnlyTableException(
@@ -601,16 +601,16 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                                 Bytes.toString(familyByte));
                     }
                     HColumnDescriptor columnDescriptor = generateColumnFamilyDescriptor(family, tableType);
-                    descriptor.addFamily(columnDescriptor);
+                    tableDescriptor.addFamily(columnDescriptor);
                 } else {
                     if (tableType != PTableType.VIEW) {
-                        modifyColumnFamilyDescriptor(descriptor.getFamily(familyByte), family);
+                        modifyColumnFamilyDescriptor(tableDescriptor.getFamily(familyByte), family);
                     }
                 }
             }
         }
-        addCoprocessors(tableName, descriptor, tableType);
-        return descriptor;
+        addCoprocessors(tableName, tableDescriptor, tableType);
+        return tableDescriptor;
     }
 
     private void addCoprocessors(byte[] tableName, HTableDescriptor descriptor, PTableType tableType) throws SQLException {
@@ -756,6 +756,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
             } else {
                 admin.modifyColumn(tableName, newColumnDesc);
             }
+            admin.enableTable(tableName);
         } else {
             if (oldColumnDesc == null) {
                 admin.addColumn(tableName, newColumnDesc);
@@ -937,7 +938,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                     return existingDesc;
                 }
 
-                modifyTable(tableName, admin, newDesc);
+                modifyTable(tableName, newDesc);
                 return newDesc;
             }
 
@@ -969,15 +970,18 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
         return null; // will never make it here
     }
     
-    private void modifyTable(byte[] tableName, HBaseAdmin admin, HTableDescriptor newDesc) throws IOException,
-            InterruptedException, TimeoutException {
-        if (!allowOnlineTableSchemaUpdate()) {
-            admin.disableTable(tableName);
-            admin.modifyTable(tableName, newDesc);
-            admin.enableTable(tableName);
-        } else {
-            admin.modifyTable(tableName, newDesc);
-            pollForUpdatedTableDescriptor(admin, newDesc, tableName);
+    @Override
+    public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException, InterruptedException,
+            TimeoutException {
+        try (HBaseAdmin admin = new HBaseAdmin(config)) {
+            if (!allowOnlineTableSchemaUpdate()) {
+                admin.disableTable(tableName);
+                admin.modifyTable(tableName, newDesc);
+                admin.enableTable(tableName);
+            } else {
+                admin.modifyTable(tableName, newDesc);
+                pollForUpdatedTableDescriptor(admin, newDesc, tableName);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
index ec10d5f..38c6139 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
@@ -19,11 +19,13 @@ package org.apache.phoenix.query;
 
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE_BYTES;
 
+import java.io.IOException;
 import java.sql.SQLException;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -479,4 +481,9 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices imple
         return getProps().getInt(QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB,
                 QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS);
     }
+
+    @Override
+    public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
+            InterruptedException, TimeoutException {
+    } 
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7578ee92/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
index ae0b689..a76738e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/DelegateConnectionQueryServices.java
@@ -17,10 +17,12 @@
  */
 package org.apache.phoenix.query;
 
+import java.io.IOException;
 import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -249,4 +251,10 @@ public class DelegateConnectionQueryServices extends DelegateQueryServices imple
     public int getSequenceSaltBuckets() {
         return getDelegate().getSequenceSaltBuckets();
     }
+
+    @Override
+    public void modifyTable(byte[] tableName, HTableDescriptor newDesc) throws IOException,
+            InterruptedException, TimeoutException {
+        getDelegate().modifyTable(tableName, newDesc);
+    } 
 }
\ No newline at end of file