Index: conf/hive-default.xml.template
===================================================================
--- conf/hive-default.xml.template (revision 1234053)
+++ conf/hive-default.xml.template (working copy)
@@ -244,6 +244,12 @@
+ hive.metastore.partition.inherit.table.properties
+
+ list of comma seperated keys occurring in table properties which will get inherited to newly created partitions
+
+
+
hive.metastore.end.function.listeners
list of comma separated listeners for the end of metastore functions.
Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
===================================================================
--- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision 1234053)
+++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (working copy)
@@ -26,14 +26,17 @@
import java.io.IOException;
import java.util.AbstractMap;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Formatter;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import java.util.Set;
import java.util.Timer;
import java.util.regex.Pattern;
@@ -1562,7 +1565,23 @@
part.getParameters().get(Constants.DDL_TIME) == null) {
part.putToParameters(Constants.DDL_TIME, Long.toString(time));
}
+
+ Map tblParams = tbl.getParameters();
+ String inheritProps = hiveConf.getVar(ConfVars.METASTORE_PART_INHERIT_TBL_PROPS).trim();
+ // Default value is empty string in which case no properties will be inherited.
+ // * implies all properties needs to be inherited
+ Set inheritKeys = new HashSet(Arrays.asList(inheritProps.split(",")));
+ if(inheritKeys.contains("*")){
+ inheritKeys = tblParams.keySet();
+ }
+ for (String key : inheritKeys) {
+ String paramVal = tblParams.get(key);
+ if(null != paramVal){ // add the property only if it exists in table properties
+ part.putToParameters(key, paramVal);
+ }
+ }
+
success = ms.addPartition(part);
} finally {
Index: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
===================================================================
--- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (revision 1234053)
+++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (working copy)
@@ -119,6 +119,7 @@
HiveConf.ConfVars.METASTORE_EVENT_EXPIRY_DURATION,
HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL,
HiveConf.ConfVars.METASTORE_END_FUNCTION_LISTENERS,
+ HiveConf.ConfVars.METASTORE_PART_INHERIT_TBL_PROPS,
};
/**
@@ -296,6 +297,7 @@
METASTORE_NON_TRANSACTIONAL_READ("javax.jdo.option.NonTransactionalRead", true),
METASTORE_CONNECTION_USER_NAME("javax.jdo.option.ConnectionUserName", "APP"),
METASTORE_END_FUNCTION_LISTENERS("hive.metastore.end.function.listeners", ""),
+ METASTORE_PART_INHERIT_TBL_PROPS("hive.metastore.partition.inherit.table.properties",""),
// CLI
CLIIGNOREERRORS("hive.cli.errors.ignore", false),
Index: ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java
===================================================================
--- ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java (revision 1234053)
+++ ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java (working copy)
@@ -360,7 +360,7 @@
db.dropDatabase(dbName);
}
}
- db.setCurrentDatabase(DEFAULT_DATABASE_NAME);
+ Hive.get().setCurrentDatabase(DEFAULT_DATABASE_NAME);
List roleNames = db.getAllRoleNames();
for (String roleName : roleNames) {