You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2015/03/05 19:51:39 UTC

svn commit: r1664455 [4/30] - in /hive/branches/parquet: ./ accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/ accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/predicate/ accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/serde/...

Modified: hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreFilterHook.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreFilterHook.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreFilterHook.java (original)
+++ hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreFilterHook.java Thu Mar  5 18:51:32 2015
@@ -24,6 +24,7 @@ import org.apache.hadoop.hive.common.cla
 import org.apache.hadoop.hive.common.classification.InterfaceStability.Evolving;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.Index;
+import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.PartitionSpec;
@@ -43,7 +44,7 @@ public interface MetaStoreFilterHook {
    * @param dbList
    * @return List of filtered Db names
    */
-  public List<String> filterDatabases(List<String> dbList);
+  public List<String> filterDatabases(List<String> dbList) throws MetaException;
 
   /**
    * filter to given database object if applicable
@@ -51,7 +52,7 @@ public interface MetaStoreFilterHook {
    * @return the same database if it's not filtered out
    * @throws NoSuchObjectException
    */
-  public Database filterDatabase(Database dataBase) throws NoSuchObjectException;
+  public Database filterDatabase(Database dataBase) throws MetaException, NoSuchObjectException;
 
   /**
    * Filter given list of tables
@@ -59,7 +60,7 @@ public interface MetaStoreFilterHook {
    * @param tableList
    * @returnList of filtered table names
    */
-  public List<String> filterTableNames(String dbName, List<String> tableList);
+  public List<String> filterTableNames(String dbName, List<String> tableList) throws MetaException;
 
   /**
    * filter to given table object if applicable
@@ -67,7 +68,7 @@ public interface MetaStoreFilterHook {
    * @return the same table if it's not filtered out
    * @throws NoSuchObjectException
    */
-  public Table filterTable(Table table) throws NoSuchObjectException;
+  public Table filterTable(Table table) throws MetaException, NoSuchObjectException;
 
   /**
    * Filter given list of tables
@@ -75,21 +76,22 @@ public interface MetaStoreFilterHook {
    * @param tableList
    * @returnList of filtered table names
    */
-  public List<Table> filterTables(List<Table> tableList);
+  public List<Table> filterTables(List<Table> tableList) throws MetaException;
 
   /**
    * Filter given list of partitions
    * @param partitionList
    * @return
    */
-  public List<Partition> filterPartitions(List<Partition> partitionList);
+  public List<Partition> filterPartitions(List<Partition> partitionList) throws MetaException;
 
   /**
    * Filter given list of partition specs
    * @param partitionSpecList
    * @return
    */
-  public List<PartitionSpec> filterPartitionSpecs(List<PartitionSpec> partitionSpecList);
+  public List<PartitionSpec> filterPartitionSpecs(List<PartitionSpec> partitionSpecList)
+      throws MetaException;
 
   /**
    * filter to given partition object if applicable
@@ -97,7 +99,7 @@ public interface MetaStoreFilterHook {
    * @return the same partition object if it's not filtered out
    * @throws NoSuchObjectException
    */
-  public Partition filterPartition(Partition partition) throws NoSuchObjectException;
+  public Partition filterPartition(Partition partition) throws MetaException, NoSuchObjectException;
 
   /**
    * Filter given list of partition names
@@ -107,9 +109,9 @@ public interface MetaStoreFilterHook {
    * @return
    */
   public List<String> filterPartitionNames(String dbName, String tblName,
-      List<String> partitionNames);
+      List<String> partitionNames) throws MetaException;
 
-  public Index filterIndex(Index index) throws NoSuchObjectException;
+  public Index filterIndex(Index index) throws MetaException, NoSuchObjectException;
 
   /**
    * Filter given list of index names
@@ -119,13 +121,13 @@ public interface MetaStoreFilterHook {
    * @return
    */
   public List<String> filterIndexNames(String dbName, String tblName,
-      List<String> indexList);
+      List<String> indexList) throws MetaException;
 
   /**
    * Filter given list of index objects
    * @param indexeList
    * @return
    */
-  public List<Index> filterIndexes(List<Index> indexeList);
+  public List<Index> filterIndexes(List<Index> indexeList) throws MetaException;
 }
 

Modified: hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (original)
+++ hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java Thu Mar  5 18:51:32 2015
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.metastore
 import static org.apache.commons.lang.StringUtils.join;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
@@ -161,6 +162,10 @@ public class ObjectStore implements RawS
   private static PersistenceManagerFactory pmf = null;
 
   private static Lock pmfPropLock = new ReentrantLock();
+  /**
+  * Verify the schema only once per JVM since the db connection info is static
+  */
+  private final static AtomicBoolean isSchemaVerified = new AtomicBoolean(false);
   private static final Log LOG = LogFactory.getLog(ObjectStore.class.getName());
 
   private static enum TXN_STATUS {
@@ -168,6 +173,8 @@ public class ObjectStore implements RawS
   }
 
   private static final Map<String, Class> PINCLASSMAP;
+  private static final String HOSTNAME;
+  private static final String USER;
   static {
     Map<String, Class> map = new HashMap<String, Class>();
     map.put("table", MTable.class);
@@ -179,8 +186,22 @@ public class ObjectStore implements RawS
     map.put("fieldschema", MFieldSchema.class);
     map.put("order", MOrder.class);
     PINCLASSMAP = Collections.unmodifiableMap(map);
+    String hostname = "UNKNOWN";
+    try {
+      InetAddress clientAddr = InetAddress.getLocalHost();
+      hostname = clientAddr.getHostAddress();
+    } catch (IOException e) {
+    }
+    HOSTNAME = hostname;
+    String user = System.getenv("USER");
+    if (user == null) {
+      USER = "UNKNOWN";
+    } else {
+      USER = user;
+    }
   }
 
+
   private boolean isInitialized = false;
   private PersistenceManager pm = null;
   private MetaStoreDirectSql directSql = null;
@@ -189,7 +210,6 @@ public class ObjectStore implements RawS
   int openTrasactionCalls = 0;
   private Transaction currentTransaction = null;
   private TXN_STATUS transactionStatus = TXN_STATUS.NO_STATE;
-  private final AtomicBoolean isSchemaVerified = new AtomicBoolean(false);
 
   private Pattern partitionValidationPattern;
 
@@ -6581,6 +6601,10 @@ public class ObjectStore implements RawS
     checkSchema();
   }
 
+  public static void setSchemaVerified(boolean val) {
+    isSchemaVerified.set(val);
+  }
+
   private synchronized void checkSchema() throws MetaException {
     // recheck if it got verified by another thread while we were waiting
     if (isSchemaVerified.get()) {
@@ -6592,32 +6616,33 @@ public class ObjectStore implements RawS
     // read the schema version stored in metastore db
     String schemaVer = getMetaStoreSchemaVersion();
     if (schemaVer == null) {
-      // metastore has no schema version information
       if (strictValidation) {
-            throw new MetaException("Version information not found in metastore. ");
-          } else {
-            LOG.warn("Version information not found in metastore. "
-                + HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString() +
-                " is not enabled so recording the schema version " +
-                MetaStoreSchemaInfo.getHiveSchemaVersion());
-            setMetaStoreSchemaVersion(MetaStoreSchemaInfo.getHiveSchemaVersion(),
-                "Set by MetaStore");
-        }
+        throw new MetaException("Version information not found in metastore. ");
+      } else {
+        LOG.warn("Version information not found in metastore. "
+            + HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString() +
+            " is not enabled so recording the schema version " +
+            MetaStoreSchemaInfo.getHiveSchemaVersion());
+        setMetaStoreSchemaVersion(MetaStoreSchemaInfo.getHiveSchemaVersion(),
+          "Set by MetaStore " + USER + "@" + HOSTNAME);
+      }
     } else {
       // metastore schema version is different than Hive distribution needs
-      if (strictValidation) {
-        if (!schemaVer.equalsIgnoreCase(MetaStoreSchemaInfo.getHiveSchemaVersion())) {
+      if (schemaVer.equalsIgnoreCase(MetaStoreSchemaInfo.getHiveSchemaVersion())) {
+        LOG.debug("Found expected HMS version of " + schemaVer);
+      } else {
+        if (strictValidation) {
           throw new MetaException("Hive Schema version "
               + MetaStoreSchemaInfo.getHiveSchemaVersion() +
               " does not match metastore's schema version " + schemaVer +
               " Metastore is not upgraded or corrupt");
         } else {
-          LOG.warn("Metastore version was " + schemaVer + " " +
-              HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION.toString() +
-              " is not enabled so recording the new schema version " +
-              MetaStoreSchemaInfo.getHiveSchemaVersion());
+          LOG.error("Version information found in metastore differs " + schemaVer +
+              " from expected schema version " + MetaStoreSchemaInfo.getHiveSchemaVersion() +
+              ". Schema verififcation is disabled " +
+              HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION + " so setting version.");
           setMetaStoreSchemaVersion(MetaStoreSchemaInfo.getHiveSchemaVersion(),
-              "Set by MetaStore");
+            "Set by MetaStore " + USER + "@" + HOSTNAME);
         }
       }
     }
@@ -6669,7 +6694,11 @@ public class ObjectStore implements RawS
       throw new NoSuchObjectException("No matching version found");
     }
     if (mVerTables.size() > 1) {
-      throw new MetaException("Metastore contains multiple versions");
+      String msg = "Metastore contains multiple versions (" + mVerTables.size() + ") ";
+      for (MVersionTable version : mVerTables) {
+        msg += "[ version = " + version.getSchemaVersion() + ", comment = " + version.getVersionComment() + " ] ";
+      }
+      throw new MetaException(msg.trim());
     }
     return mVerTables.get(0);
   }
@@ -6678,6 +6707,13 @@ public class ObjectStore implements RawS
   public void setMetaStoreSchemaVersion(String schemaVersion, String comment) throws MetaException {
     MVersionTable mSchemaVer;
     boolean commited = false;
+    boolean recordVersion =
+      HiveConf.getBoolVar(getConf(), HiveConf.ConfVars.METASTORE_SCHEMA_VERIFICATION_RECORD_VERSION);
+    if (!recordVersion) {
+      LOG.warn("setMetaStoreSchemaVersion called but recording version is disabled: " +
+        "version = " + schemaVersion + ", comment = " + comment);
+      return;
+    }
 
     try {
       mSchemaVer = getMSchemaVersion();

Modified: hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java (original)
+++ hive/branches/parquet/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java Thu Mar  5 18:51:32 2015
@@ -86,6 +86,10 @@ public class RetryingHMSHandler implemen
         HiveConf.ConfVars.HMSHANDLERINTERVAL, TimeUnit.MILLISECONDS);
     int retryLimit = HiveConf.getIntVar(origConf,
         HiveConf.ConfVars.HMSHANDLERATTEMPTS);
+    long timeout = HiveConf.getTimeVar(origConf,
+        HiveConf.ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
+
+    Deadline.registerIfNot(timeout);
 
     if (reloadConf) {
       MetaStoreInit.updateConnectionURL(origConf, getActiveConf(),
@@ -99,7 +103,10 @@ public class RetryingHMSHandler implemen
         if (reloadConf || gotNewConnectUrl) {
           baseHandler.setConf(getActiveConf());
         }
-        return method.invoke(baseHandler, args);
+        Deadline.startTimer(method.getName());
+        Object object = method.invoke(baseHandler, args);
+        Deadline.stopTimer();
+        return object;
 
       } catch (javax.jdo.JDOException e) {
         caughtException = e;
@@ -132,11 +139,21 @@ public class RetryingHMSHandler implemen
             LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
           }
           throw e.getCause();
-        } else if (e.getCause() instanceof MetaException && e.getCause().getCause() != null
-            && (e.getCause().getCause() instanceof javax.jdo.JDOException || 
-            	e.getCause().getCause() instanceof NucleusException)) {
-          // The JDOException or the Nucleus Exception may be wrapped further in a MetaException
-          caughtException = e.getCause().getCause();
+        } else if (e.getCause() instanceof MetaException && e.getCause().getCause() != null) {
+          if (e.getCause().getCause() instanceof javax.jdo.JDOException ||
+              e.getCause().getCause() instanceof NucleusException) {
+            // The JDOException or the Nucleus Exception may be wrapped further in a MetaException
+            caughtException = e.getCause().getCause();
+          } else if (e.getCause().getCause() instanceof DeadlineException) {
+            // The Deadline Exception needs no retry and be thrown immediately.
+            Deadline.clear();
+            LOG.error("Error happens in method " + method.getName() + ": " +
+                ExceptionUtils.getStackTrace(e.getCause()));
+            throw e.getCause();
+          } else {
+            LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
+            throw e.getCause();
+          }
         } else {
           LOG.error(ExceptionUtils.getStackTrace(e.getCause()));
           throw e.getCause();

Modified: hive/branches/parquet/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java (original)
+++ hive/branches/parquet/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java Thu Mar  5 18:51:32 2015
@@ -18,9 +18,9 @@
 
 package org.apache.hadoop.hive.metastore;
 
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.SortedSet;
 
 import junit.framework.Assert;
 
@@ -28,7 +28,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.AggrStats;
 import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
 import org.apache.hadoop.hive.metastore.api.CurrentNotificationEventId;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.Function;
@@ -44,12 +43,10 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.NotificationEventResponse;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.PartitionEventType;
-import org.apache.hadoop.hive.metastore.api.PartitionsStatsRequest;
 import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
 import org.apache.hadoop.hive.metastore.api.Role;
-import org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.Type;
 import org.apache.hadoop.hive.metastore.api.UnknownDBException;
@@ -145,13 +142,13 @@ public class DummyRawStoreForJdoConnecti
   @Override
   public List<String> getDatabases(String pattern) throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> getAllDatabases() throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -214,7 +211,7 @@ public class DummyRawStoreForJdoConnecti
   public List<Partition> getPartitions(String dbName, String tableName, int max)
       throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -227,41 +224,41 @@ public class DummyRawStoreForJdoConnecti
   @Override
   public List<String> getTables(String dbName, String pattern) throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<Table> getTableObjectsByName(String dbname, List<String> tableNames)
       throws MetaException, UnknownDBException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> getAllTables(String dbName) throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> listTableNamesByFilter(String dbName, String filter, short max_tables)
       throws MetaException, UnknownDBException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> listPartitionNames(String db_name, String tbl_name, short max_parts)
       throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> listPartitionNamesByFilter(String db_name, String tbl_name, String filter,
       short max_parts) throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -310,7 +307,7 @@ public class DummyRawStoreForJdoConnecti
   public List<String> listIndexNames(String dbName, String origTableName, short max)
       throws MetaException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -324,14 +321,14 @@ public class DummyRawStoreForJdoConnecti
   public List<Partition> getPartitionsByFilter(String dbName, String tblName, String filter,
       short maxParts) throws MetaException, NoSuchObjectException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<Partition> getPartitionsByNames(String dbName, String tblName,
       List<String> partNames) throws MetaException, NoSuchObjectException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -425,35 +422,35 @@ public class DummyRawStoreForJdoConnecti
   public List<MGlobalPrivilege> listPrincipalGlobalGrants(String principalName,
       PrincipalType principalType) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MDBPrivilege> listPrincipalDBGrants(String principalName,
       PrincipalType principalType, String dbName) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MTablePrivilege> listAllTableGrants(String principalName,
       PrincipalType principalType, String dbName, String tableName) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MPartitionPrivilege> listPrincipalPartitionGrants(String principalName,
       PrincipalType principalType, String dbName, String tableName, String partName) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MTableColumnPrivilege> listPrincipalTableColumnGrants(String principalName,
       PrincipalType principalType, String dbName, String tableName, String columnName) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -461,7 +458,7 @@ public class DummyRawStoreForJdoConnecti
       PrincipalType principalType, String dbName, String tableName, String partName,
       String columnName) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -487,18 +484,18 @@ public class DummyRawStoreForJdoConnecti
   @Override
   public List<String> listRoleNames() {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MRoleMap> listRoles(String principalName, PrincipalType principalType) {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<MRoleMap> listRoleMembers(String roleName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -514,14 +511,14 @@ public class DummyRawStoreForJdoConnecti
       String userName, List<String> groupNames) throws MetaException, NoSuchObjectException,
       InvalidObjectException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<String> listPartitionNamesPs(String db_name, String tbl_name, List<String> part_vals,
       short max_parts) throws MetaException, NoSuchObjectException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -529,7 +526,7 @@ public class DummyRawStoreForJdoConnecti
       List<String> part_vals, short max_parts, String userName, List<String> groupNames)
       throws MetaException, InvalidObjectException, NoSuchObjectException {
 
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -555,7 +552,7 @@ public class DummyRawStoreForJdoConnecti
 
   @Override
   public List<String> getAllTokenIdentifiers() {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -574,67 +571,67 @@ public class DummyRawStoreForJdoConnecti
 
   @Override
   public String[] getMasterKeys() {
-    return null;
+    return new String[0];
   }
 
   @Override
   public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(
       String principalName, PrincipalType principalType) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPrincipalTableGrantsAll(
       String principalName, PrincipalType principalType) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPrincipalPartitionGrantsAll(
       String principalName, PrincipalType principalType) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPrincipalTableColumnGrantsAll(
       String principalName, PrincipalType principalType) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPrincipalPartitionColumnGrantsAll(
       String principalName, PrincipalType principalType) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listGlobalGrantsAll() {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listDBGrantsAll(String dbName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPartitionColumnGrantsAll(String dbName, String tableName, String partitionName, String columnName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listTableGrantsAll(String dbName, String tableName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listPartitionGrantsAll(String dbName, String tableName, String partitionName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
   public List<HiveObjectPrivilege> listTableColumnGrantsAll(String dbName, String tableName, String columnName) {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -689,7 +686,7 @@ public class DummyRawStoreForJdoConnecti
   public List<ColumnStatistics> getPartitionColumnStatistics(String dbName,
       String tblName, List<String> colNames, List<String> partNames)
       throws MetaException, NoSuchObjectException {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -738,7 +735,7 @@ public class DummyRawStoreForJdoConnecti
   @Override
   public List<String> getFunctions(String dbName, String pattern)
       throws MetaException {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override

Modified: hive/branches/parquet/packaging/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/parquet/packaging/pom.xml?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/packaging/pom.xml (original)
+++ hive/branches/parquet/packaging/pom.xml Thu Mar  5 18:51:32 2015
@@ -86,28 +86,6 @@
               </execution>
             </executions>
           </plugin>
-          <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>build-helper-maven-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>attach-jdbc-driver</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>attach-artifact</goal>
-                </goals>
-                <configuration>
-                  <artifacts>
-                    <artifact>
-                      <file>${project.build.directory}/${hive.jdbc.driver.jar}</file>
-                      <type>jar</type>
-                      <classifier>${hive.jdbc.driver.classifier}</classifier>
-                    </artifact>
-                  </artifacts>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
         </plugins>
       </build>
     </profile>

Modified: hive/branches/parquet/packaging/src/main/assembly/src.xml
URL: http://svn.apache.org/viewvc/hive/branches/parquet/packaging/src/main/assembly/src.xml?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/packaging/src/main/assembly/src.xml (original)
+++ hive/branches/parquet/packaging/src/main/assembly/src.xml Thu Mar  5 18:51:32 2015
@@ -40,6 +40,7 @@
         <exclude>**/.project</exclude>
         <exclude>**/.settings/**</exclude>
         <exclude>itests/thirdparty/**</exclude>
+        <exclude>testutils/ptest2/velocity.log*</exclude>
       </excludes>
 
       <includes>
@@ -74,6 +75,8 @@
         <include>jdbc/**/*</include>
         <include>contrib/**/*</include>
         <include>metastore/**/*</include>
+        <include>lib/**/*</include>
+        <include>findbugs/**/*</include>
         <include>odbc/**/*</include>
         <include>packaging/pom.xml</include>
         <include>packaging/src/**/*</include>
@@ -83,7 +86,6 @@
         <include>service/**/*</include>
         <include>shims/**/*</include>
         <include>spark-client/**/*</include>
-        <include>testlibs/**/*</include>
         <include>testutils/**/*</include>
       </includes>
       <outputDirectory>/</outputDirectory>

Modified: hive/branches/parquet/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/parquet/pom.xml?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/pom.xml (original)
+++ hive/branches/parquet/pom.xml Thu Mar  5 18:51:32 2015
@@ -121,8 +121,8 @@
     <hadoop-20S.version>1.2.1</hadoop-20S.version>
     <hadoop-23.version>2.6.0</hadoop-23.version>
     <hadoop.bin.path>${basedir}/${hive.path.to.root}/testutils/hadoop</hadoop.bin.path>
-    <hbase.hadoop1.version>0.98.3-hadoop1</hbase.hadoop1.version>
-    <hbase.hadoop2.version>0.98.3-hadoop2</hbase.hadoop2.version>
+    <hbase.hadoop1.version>0.98.9-hadoop1</hbase.hadoop1.version>
+    <hbase.hadoop2.version>0.98.9-hadoop2</hbase.hadoop2.version>
     <!-- httpcomponents are not always in version sync -->
     <httpcomponents.client.version>4.2.5</httpcomponents.client.version>
     <httpcomponents.core.version>4.2.5</httpcomponents.core.version>
@@ -487,10 +487,20 @@
       </dependency>
       <dependency>
         <groupId>org.apache.curator</groupId>
+        <artifactId>curator-client</artifactId>
+        <version>${curator.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.curator</groupId>
         <artifactId>curator-framework</artifactId>
         <version>${curator.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.curator</groupId>
+        <artifactId>curator-recipes</artifactId>
+        <version>${curator.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.codehaus.groovy</groupId>
         <artifactId>groovy-all</artifactId>
         <version>${groovy.version}</version>

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/Driver.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/Driver.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/Driver.java Thu Mar  5 18:51:32 2015
@@ -47,7 +47,6 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.ql.exec.ConditionalTask;
 import org.apache.hadoop.hive.ql.exec.ExplainTask;
 import org.apache.hadoop.hive.ql.exec.FetchTask;
-import org.apache.hadoop.hive.ql.exec.MoveTask;
 import org.apache.hadoop.hive.ql.exec.Operator;
 import org.apache.hadoop.hive.ql.exec.TableScanOperator;
 import org.apache.hadoop.hive.ql.exec.Task;
@@ -64,8 +63,8 @@ import org.apache.hadoop.hive.ql.hooks.H
 import org.apache.hadoop.hive.ql.hooks.PostExecute;
 import org.apache.hadoop.hive.ql.hooks.PreExecute;
 import org.apache.hadoop.hive.ql.hooks.ReadEntity;
-import org.apache.hadoop.hive.ql.hooks.WriteEntity;
 import org.apache.hadoop.hive.ql.hooks.Redactor;
+import org.apache.hadoop.hive.ql.hooks.WriteEntity;
 import org.apache.hadoop.hive.ql.lockmgr.HiveLock;
 import org.apache.hadoop.hive.ql.lockmgr.HiveLockMode;
 import org.apache.hadoop.hive.ql.lockmgr.HiveLockObj;
@@ -153,6 +152,9 @@ public class Driver implements CommandPr
 
   private String userName;
 
+  // HS2 operation handle guid string
+  private String operationId;
+
   private boolean checkConcurrency() {
     boolean supportConcurrency = conf.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY);
     if (!supportConcurrency) {
@@ -1328,7 +1330,8 @@ public class Driver implements CommandPr
       resStream = null;
 
       SessionState ss = SessionState.get();
-      HookContext hookContext = new HookContext(plan, conf, ctx.getPathToCS(), ss.getUserName(), ss.getUserIpAddress());
+      HookContext hookContext = new HookContext(plan, conf, ctx.getPathToCS(), ss.getUserName(),
+          ss.getUserIpAddress(), operationId);
       hookContext.setHookType(HookContext.HookType.PRE_EXEC_HOOK);
 
       for (Hook peh : getHooks(HiveConf.ConfVars.PREEXECHOOKS)) {
@@ -1625,8 +1628,7 @@ public class Driver implements CommandPr
 
     cxt.launching(tskRun);
     // Launch Task
-    if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.EXECPARALLEL)
-        && (tsk.isMapRedTask() || (tsk instanceof MoveTask))) {
+    if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.EXECPARALLEL) && tsk.isMapRedTask()) {
       // Launch it in the parallel mode, as a separate thread only for MR tasks
       if (LOG.isInfoEnabled()){
         LOG.info("Starting task [" + tsk + "] in parallel");
@@ -1784,4 +1786,12 @@ public class Driver implements CommandPr
     return errorMessage;
   }
 
+  /**
+   * Set the HS2 operation handle's guid string
+   * @param opId base64 encoded guid string
+   */
+  public void setOperationId(String opId) {
+    this.operationId = opId;
+  }
+
 }

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java Thu Mar  5 18:51:32 2015
@@ -428,6 +428,7 @@ public enum ErrorMsg {
   ALTER_TABLE_PARTITION_CASCADE_NOT_SUPPORTED(10300,
       "Alter table partition type {0} does not support cascade", true),
 
+  DROP_NATIVE_FUNCTION(10301, "Cannot drop native function"),
 
   //========================== 20000 range starts here ========================//
   SCRIPT_INIT_ERROR(20000, "Unable to initialize custom script."),

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java Thu Mar  5 18:51:32 2015
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hive.ql;
 
+
 /**
  *
  * QueryProperties.
@@ -25,16 +26,26 @@ package org.apache.hadoop.hive.ql;
  * A structure to contain features of a query that are determined
  * during parsing and may be useful for categorizing a query type
  *
- * These inlucde whether the query contains:
+ * These include whether the query contains:
  * a join clause, a group by clause, an order by clause, a sort by
  * clause, a group by clause following a join clause, and whether
  * the query uses a script for mapping/reducing
  */
 public class QueryProperties {
 
+  boolean query;
+  boolean analyzeCommand;
+  boolean partialScanAnalyzeCommand;
+  boolean noScanAnalyzeCommand;
+  boolean analyzeRewrite;
+  boolean ctas;
+  boolean insertToTable;
+  int outerQueryLimit;
+
   boolean hasJoin = false;
   boolean hasGroupBy = false;
   boolean hasOrderBy = false;
+  boolean hasOuterOrderBy = false;
   boolean hasSortBy = false;
   boolean hasJoinFollowedByGroupBy = false;
   boolean hasPTF = false;
@@ -51,10 +62,75 @@ public class QueryProperties {
   private int noOfJoins = 0;
   private int noOfOuterJoins = 0;
   private boolean hasLateralViews;
-  
+
   private boolean multiDestQuery;
   private boolean filterWithSubQuery;
-  
+
+
+  public boolean isQuery() {
+    return query;
+  }
+
+  public void setQuery(boolean query) {
+    this.query = query;
+  }
+
+  public boolean isAnalyzeCommand() {
+    return analyzeCommand;
+  }
+
+  public void setAnalyzeCommand(boolean analyzeCommand) {
+    this.analyzeCommand = analyzeCommand;
+  }
+
+  public boolean isPartialScanAnalyzeCommand() {
+    return partialScanAnalyzeCommand;
+  }
+
+  public void setPartialScanAnalyzeCommand(boolean partialScanAnalyzeCommand) {
+    this.partialScanAnalyzeCommand = partialScanAnalyzeCommand;
+  }
+
+  public boolean isNoScanAnalyzeCommand() {
+    return noScanAnalyzeCommand;
+  }
+
+  public void setNoScanAnalyzeCommand(boolean noScanAnalyzeCommand) {
+    this.noScanAnalyzeCommand = noScanAnalyzeCommand;
+  }
+
+  public boolean isAnalyzeRewrite() {
+    return analyzeRewrite;
+  }
+
+  public void setAnalyzeRewrite(boolean analyzeRewrite) {
+    this.analyzeRewrite = analyzeRewrite;
+  }
+
+  public boolean isCTAS() {
+    return ctas;
+  }
+
+  public void setCTAS(boolean ctas) {
+    this.ctas = ctas;
+  }
+
+  public boolean isInsertToTable() {
+    return insertToTable;
+  }
+
+  public void setInsertToTable(boolean insertToTable) {
+    this.insertToTable = insertToTable;
+  }
+
+  public int getOuterQueryLimit() {
+    return outerQueryLimit;
+  }
+
+  public void setOuterQueryLimit(int outerQueryLimit) {
+    this.outerQueryLimit = outerQueryLimit;
+  }
+
   public boolean hasJoin() {
     return (noOfJoins > 0);
   }
@@ -97,6 +173,14 @@ public class QueryProperties {
     this.hasOrderBy = hasOrderBy;
   }
 
+  public boolean hasOuterOrderBy() {
+    return hasOuterOrderBy;
+  }
+
+  public void setHasOuterOrderBy(boolean hasOuterOrderBy) {
+    this.hasOuterOrderBy = hasOuterOrderBy;
+  }
+
   public boolean hasSortBy() {
     return hasSortBy;
   }
@@ -186,9 +270,19 @@ public class QueryProperties {
   }
 
   public void clear() {
+    query = false;
+    analyzeCommand = false;
+    partialScanAnalyzeCommand = false;
+    noScanAnalyzeCommand = false;
+    analyzeRewrite = false;
+    ctas = false;
+    insertToTable = false;
+    outerQueryLimit = -1;
+
     hasJoin = false;
     hasGroupBy = false;
     hasOrderBy = false;
+    hasOuterOrderBy = false;
     hasSortBy = false;
     hasJoinFollowedByGroupBy = false;
     hasPTF = false;
@@ -204,8 +298,9 @@ public class QueryProperties {
 
     noOfJoins = 0;
     noOfOuterJoins = 0;
-    
+
     multiDestQuery = false;
     filterWithSubQuery = false;
   }
+
 }

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AbstractMapJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AbstractMapJoinOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AbstractMapJoinOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AbstractMapJoinOperator.java Thu Mar  5 18:51:32 2015
@@ -48,9 +48,6 @@ public abstract class AbstractMapJoinOpe
 
   transient int numMapRowsRead;
 
-  transient boolean firstRow;
-
-
   public AbstractMapJoinOperator() {
   }
 
@@ -72,7 +69,6 @@ public abstract class AbstractMapJoinOpe
     super.initializeOp(hconf);
 
     numMapRowsRead = 0;
-    firstRow = true;
 
     // all other tables are small, and are cached in the hash table
     posBigTable = (byte) conf.getPosBigTable();

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AppMasterEventOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AppMasterEventOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AppMasterEventOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/AppMasterEventOperator.java Thu Mar  5 18:51:32 2015
@@ -81,7 +81,9 @@ public class AppMasterEventOperator exte
       Writable writableRow = serializer.serialize(row, rowInspector);
       writableRow.write(buffer);
       if (buffer.getLength() > MAX_SIZE) {
-        LOG.info("Disabling AM events. Buffer size too large: " + buffer.getLength());
+	if (isLogInfoEnabled) {
+	  LOG.info("Disabling AM events. Buffer size too large: " + buffer.getLength());
+	}
         hasReachedMaxSize = true;
         buffer = null;
       }
@@ -89,7 +91,7 @@ public class AppMasterEventOperator exte
       throw new HiveException(e);
     }
 
-    if (LOG.isDebugEnabled()) {
+    if (isLogDebugEnabled) {
       LOG.debug("AppMasterEvent: " + row);
     }
     forward(row, rowInspector);
@@ -116,8 +118,10 @@ public class AppMasterEventOperator exte
           InputInitializerEvent.create(vertexName, inputName,
               ByteBuffer.wrap(payload, 0, payload.length));
 
-      LOG.info("Sending Tez event to vertex = " + vertexName + ", input = " + inputName
-          + ". Payload size = " + payload.length);
+      if (isLogInfoEnabled) {
+	LOG.info("Sending Tez event to vertex = " + vertexName + ", input = " + inputName
+	    + ". Payload size = " + payload.length);
+      }
 
       context.getTezProcessorContext().sendEvents(Collections.singletonList(event));
     }

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonJoinOperator.java Thu Mar  5 18:51:32 2015
@@ -316,7 +316,9 @@ public abstract class CommonJoinOperator
       }
     }
 
-    LOG.info("JOIN " + outputObjInspector.getTypeName() + " totalsz = " + totalSz);
+    if (isLogInfoEnabled) {
+      LOG.info("JOIN " + outputObjInspector.getTypeName() + " totalsz = " + totalSz);
+    }
   }
 
   transient boolean newGroupStarted = false;

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/CommonMergeJoinOperator.java Thu Mar  5 18:51:32 2015
@@ -500,8 +500,11 @@ public class CommonMergeJoinOperator ext
     }
     Map<Integer, DummyStoreOperator> dummyOps = parent.getTagToOperatorTree();
     for (Entry<Integer, DummyStoreOperator> connectOp : dummyOps.entrySet()) {
-      parentOperators.add(connectOp.getKey(), connectOp.getValue());
-      connectOp.getValue().getChildOperators().add(this);
+      if (connectOp.getValue().getChildOperators() == null
+	  || connectOp.getValue().getChildOperators().isEmpty()) {
+	parentOperators.add(connectOp.getKey(), connectOp.getValue());
+	connectOp.getValue().getChildOperators().add(this);
+      }
     }
     super.initializeLocalWork(hconf);
     return;

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java Thu Mar  5 18:51:32 2015
@@ -61,6 +61,7 @@ import org.apache.hadoop.hive.common.typ
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.MetaStoreUtils;
+import org.apache.hadoop.hive.metastore.PartitionDropOptions;
 import org.apache.hadoop.hive.metastore.ProtectMode;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.Warehouse;
@@ -3679,8 +3680,14 @@ public class DDLTask extends Task<DDLWor
 
   private void dropPartitions(Hive db, Table tbl, DropTableDesc dropTbl) throws HiveException {
     // ifExists is currently verified in DDLSemanticAnalyzer
-    List<Partition> droppedParts = db.dropPartitions(dropTbl.getTableName(),
-        dropTbl.getPartSpecs(), true, dropTbl.getIgnoreProtection(), true);
+    List<Partition> droppedParts
+        = db.dropPartitions(dropTbl.getTableName(),
+                            dropTbl.getPartSpecs(),
+                            PartitionDropOptions.instance()
+                                                .deleteData(true)
+                                                .ignoreProtection(dropTbl.getIgnoreProtection())
+                                                .ifExists(true)
+                                                .purgeData(dropTbl.getIfPurge()));
     for (Partition partition : droppedParts) {
       console.printInfo("Dropped the partition " + partition.getName());
       // We have already locked the table, don't lock the partitions.

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/DemuxOperator.java Thu Mar  5 18:51:32 2015
@@ -176,7 +176,9 @@ public class DemuxOperator extends Opera
       }
       newChildOperatorsTag[i] = toArray(childOperatorTags);
     }
-    LOG.info("newChildOperatorsTag " + newChildOperatorsTag);
+    if (isLogInfoEnabled) {
+      LOG.info("newChildOperatorsTag " + newChildOperatorsTag);
+    }
     initializeChildren(hconf);
   }
 
@@ -200,12 +202,16 @@ public class DemuxOperator extends Opera
   @Override
   protected void initializeChildren(Configuration hconf) throws HiveException {
     state = State.INIT;
-    LOG.info("Operator " + id + " " + getName() + " initialized");
-    LOG.info("Initializing children of " + id + " " + getName());
+    if (isLogInfoEnabled) {
+      LOG.info("Operator " + id + " " + getName() + " initialized");
+      LOG.info("Initializing children of " + id + " " + getName());
+    }
     for (int i = 0; i < childOperatorsArray.length; i++) {
-      LOG.info("Initializing child " + i + " " + childOperatorsArray[i].getIdentifier() + " " +
-          childOperatorsArray[i].getName() +
-          " " + childInputObjInspectors[i].length);
+      if (isLogInfoEnabled) {
+	LOG.info("Initializing child " + i + " " + childOperatorsArray[i].getIdentifier() + " " +
+	    childOperatorsArray[i].getName() +
+	    " " + childInputObjInspectors[i].length);
+      }
       // We need to initialize those MuxOperators first because if we first
       // initialize other operators, the states of all parents of those MuxOperators
       // are INIT (including this DemuxOperator),
@@ -229,9 +235,11 @@ public class DemuxOperator extends Opera
       }
     }
     for (int i = 0; i < childOperatorsArray.length; i++) {
-      LOG.info("Initializing child " + i + " " + childOperatorsArray[i].getIdentifier() + " " +
-          childOperatorsArray[i].getName() +
-          " " + childInputObjInspectors[i].length);
+      if (isLogInfoEnabled) {
+	LOG.info("Initializing child " + i + " " + childOperatorsArray[i].getIdentifier() + " " +
+	    childOperatorsArray[i].getName() +
+	    " " + childInputObjInspectors[i].length);
+      }
       if (!(childOperatorsArray[i] instanceof MuxOperator)) {
         childOperatorsArray[i].initialize(hconf, childInputObjInspectors[i]);
       } else {
@@ -255,10 +263,10 @@ public class DemuxOperator extends Opera
     endGroupIfNecessary(currentChildIndex);
 
     int oldTag = newTagToOldTag[tag];
-    if (isLogInfoEnabled) {
+    if (isLogDebugEnabled) {
       cntrs[tag]++;
       if (cntrs[tag] == nextCntrs[tag]) {
-        LOG.info(id + " (newTag, childIndex, oldTag)=(" + tag + ", " + currentChildIndex + ", "
+        LOG.debug(id + " (newTag, childIndex, oldTag)=(" + tag + ", " + currentChildIndex + ", "
             + oldTag + "), forwarding " + cntrs[tag] + " rows");
         nextCntrs[tag] = getNextCntr(cntrs[tag]);
       }
@@ -291,8 +299,10 @@ public class DemuxOperator extends Opera
       int newTag = i;
       int oldTag = newTagToOldTag[i];
       int childIndex = newTagToChildIndex[newTag];
-      LOG.info(id + " (newTag, childIndex, oldTag)=(" + newTag + ", " + childIndex + ", "
-          + oldTag + "),  forwarded " + cntrs[newTag] + " rows");
+      if (isLogInfoEnabled) {
+	LOG.info(id + " (newTag, childIndex, oldTag)=(" + newTag + ", " + childIndex + ", "
+	    + oldTag + "),  forwarded " + cntrs[newTag] + " rows");
+      }
     }
   }
 

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java Thu Mar  5 18:51:32 2015
@@ -33,7 +33,6 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -478,11 +477,11 @@ public class ExplainTask extends Task<Ex
           json.put(ent.getKey().toString(), ent.getValue().toString());
         }
       }
-      else if (ent.getValue() instanceof Serializable) {
+      else if (ent.getValue() != null) {
         if (out != null) {
           out.println();
         }
-        JSONObject jsonOut = outputPlan((Serializable) ent.getValue(), out,
+        JSONObject jsonOut = outputPlan(ent.getValue(), out,
             extended, jsonOutput, jsonOutput ? 0 : indent + 2);
         if (jsonOutput) {
           json.put(ent.getKey().toString(), jsonOut);
@@ -518,11 +517,11 @@ public class ExplainTask extends Task<Ex
         }
         nl = true;
       }
-      else if (o instanceof Serializable) {
+      else {
         if (first_el && (out != null) && hasHeader) {
           out.println();
         }
-        JSONObject jsonOut = outputPlan((Serializable) o, out, extended,
+        JSONObject jsonOut = outputPlan(o, out, extended,
             jsonOutput, jsonOutput ? 0 : (hasHeader ? indent + 2 : indent));
         if (jsonOutput) {
           outputArray.put(jsonOut);
@@ -553,12 +552,12 @@ public class ExplainTask extends Task<Ex
     return false;
   }
 
-  private JSONObject outputPlan(Serializable work,
+  private JSONObject outputPlan(Object work,
       PrintStream out, boolean extended, boolean jsonOutput, int indent) throws Exception {
     return outputPlan(work, out, extended, jsonOutput, indent, "");
   }
 
-  private JSONObject outputPlan(Serializable work, PrintStream out,
+  private JSONObject outputPlan(Object work, PrintStream out,
       boolean extended, boolean jsonOutput, int indent, String appendToHeader) throws Exception {
     // Check if work has an explain annotation
     Annotation note = AnnotationUtils.getAnnotation(work.getClass(), Explain.class);
@@ -678,7 +677,7 @@ public class ExplainTask extends Task<Ex
           }
 
           // Try this as a map
-          try {
+          if (val instanceof Map) {
             // Go through the map and print out the stuff
             Map<?, ?> mp = (Map<?, ?>) val;
 
@@ -692,22 +691,10 @@ public class ExplainTask extends Task<Ex
             }
             continue;
           }
-          catch (ClassCastException ce) {
-            // Ignore - all this means is that this is not a map
-          }
 
           // Try this as a list
-          try {
-            List l;
-
-            try {
-              l = (List) val;
-            } catch (ClassCastException e) {
-              Set s = (Set) val;
-              l = new LinkedList();
-              l.addAll(s);
-            }
-
+          if (val instanceof List || val instanceof Set) {
+            List l = val instanceof List ? (List)val : new ArrayList((Set)val);
             if (out != null && !skipHeader && l != null && !l.isEmpty()) {
               out.print(header);
             }
@@ -720,18 +707,13 @@ public class ExplainTask extends Task<Ex
 
             continue;
           }
-          catch (ClassCastException ce) {
-            // Ignore
-          }
 
           // Finally check if it is serializable
           try {
-            Serializable s = (Serializable) val;
-
             if (!skipHeader && out != null) {
               out.println(header);
             }
-            JSONObject jsonOut = outputPlan(s, out, extended, jsonOutput, ind);
+            JSONObject jsonOut = outputPlan(val, out, extended, jsonOutput, ind);
             if (jsonOutput) {
               if (!skipHeader) {
                 json.put(header, jsonOut);
@@ -779,7 +761,7 @@ public class ExplainTask extends Task<Ex
     return true;
   }
 
-  private JSONObject outputPlan(Task<? extends Serializable> task,
+  private JSONObject outputPlan(Task<?> task,
       PrintStream out, JSONObject parentJSON, boolean extended,
       boolean jsonOutput, int indent) throws Exception {
 
@@ -805,7 +787,7 @@ public class ExplainTask extends Task<Ex
     return null;
   }
 
-  private JSONObject outputDependencies(Task<? extends Serializable> task,
+  private JSONObject outputDependencies(Task<?> task,
       PrintStream out, JSONObject parentJson, boolean jsonOutput, boolean taskType, int indent)
       throws Exception {
 
@@ -830,7 +812,7 @@ public class ExplainTask extends Task<Ex
     else {
       StringBuffer s = new StringBuffer();
       first = true;
-      for (Task<? extends Serializable> parent : task.getParentTasks()) {
+      for (Task<?> parent : task.getParentTasks()) {
         if (!first) {
           s.append(", ");
         }
@@ -847,7 +829,7 @@ public class ExplainTask extends Task<Ex
       }
     }
 
-    Task<? extends Serializable> currBackupTask = task.getBackupTask();
+    Task<?> currBackupTask = task.getBackupTask();
     if (currBackupTask != null) {
       if (out != null) {
         out.print(" has a backup stage: ");
@@ -862,7 +844,7 @@ public class ExplainTask extends Task<Ex
         && ((ConditionalTask) task).getListTasks() != null) {
       StringBuffer s = new StringBuffer();
       first = true;
-      for (Task<? extends Serializable> con : ((ConditionalTask) task).getListTasks()) {
+      for (Task<?> con : ((ConditionalTask) task).getListTasks()) {
         if (!first) {
           s.append(", ");
         }

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java Thu Mar  5 18:51:32 2015
@@ -391,7 +391,7 @@ public class FileSinkOperator extends Te
           valToPaths.put("", fsp); // special entry for non-DP case
         }
       }
-      
+
       final StoragePolicyValue tmpStorage = StoragePolicyValue.lookup(HiveConf
                                             .getVar(hconf, HIVE_TEMPORARY_TABLE_STORAGE));
       if (isTemporary && fsp != null
@@ -418,11 +418,13 @@ public class FileSinkOperator extends Te
 
       numRows = 0;
 
-      String context = jc.get(Operator.CONTEXT_NAME_KEY, "");
-      if (context != null && !context.isEmpty()) {
-        context = "_" + context.replace(" ","_");
+      String suffix = Integer.toString(conf.getDestTableId());
+      String fullName = conf.getTableInfo().getTableName();
+      if (fullName != null) {
+        suffix = suffix + "_" + fullName.toLowerCase();
       }
-      statsMap.put(Counter.RECORDS_OUT + context, row_count);
+
+      statsMap.put(Counter.RECORDS_OUT + "_" + suffix, row_count);
 
       initializeChildren(hconf);
     } catch (HiveException e) {
@@ -700,7 +702,7 @@ public class FileSinkOperator extends Te
         fpaths.stat.addToStat(StatsSetupConst.ROW_COUNT, 1);
       }
 
-      if (++numRows == cntr) {
+      if ((++numRows == cntr) && isLogInfoEnabled) {
         cntr *= 10;
         LOG.info(toString() + ": records written - " + numRows);
       }
@@ -965,7 +967,7 @@ public class FileSinkOperator extends Te
   public void closeOp(boolean abort) throws HiveException {
 
     row_count.set(numRows);
-    LOG.info(toString() + ": records written - " + numRows);    
+    LOG.info(toString() + ": records written - " + numRows);
 
     if (!bDynParts && !filesCreated) {
       createBucketFiles(fsp);

Modified: hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java
URL: http://svn.apache.org/viewvc/hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java?rev=1664455&r1=1664454&r2=1664455&view=diff
==============================================================================
--- hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java (original)
+++ hive/branches/parquet/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionInfo.java Thu Mar  5 18:51:32 2015
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hive.ql.exec;
 
+import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFBridge;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
@@ -27,18 +28,28 @@ import org.apache.hadoop.hive.ql.udf.ptf
 import org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction;
 import org.apache.hive.common.util.AnnotationUtils;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  * FunctionInfo.
  *
  */
-public class FunctionInfo implements CommonFunctionInfo {
+public class FunctionInfo {
+
+  public static enum FunctionType {
+    BUILTIN, PERSISTENT, TEMPORARY;
+  }
 
-  private final boolean isNative;
+  private final FunctionType functionType;
 
   private final boolean isInternalTableFunction;
 
   private final String displayName;
 
+  private final FunctionResource[] resources;
+
+  private String className;
+
   private GenericUDF genericUDF;
 
   private GenericUDTF genericUDTF;
@@ -49,38 +60,55 @@ public class FunctionInfo implements Com
 
   private boolean blockedFunction;
 
+  // for persistent function
+  // if the function is dropped, all functions registered to sessions are needed to be reloaded
+  private AtomicBoolean discarded;
+
+  public FunctionInfo(String displayName, String className, FunctionResource... resources) {
+    this.functionType = FunctionType.PERSISTENT;
+    this.displayName = displayName;
+    this.className = className;
+    this.isInternalTableFunction = false;
+    this.resources = resources;
+    this.discarded = new AtomicBoolean(false);  // shared to all session functions
+  }
+
   public FunctionInfo(boolean isNative, String displayName,
-      GenericUDF genericUDF) {
-    this.isNative = isNative;
+      GenericUDF genericUDF, FunctionResource... resources) {
+    this.functionType = isNative ? FunctionType.BUILTIN : FunctionType.TEMPORARY;
     this.displayName = displayName;
     this.genericUDF = genericUDF;
     this.isInternalTableFunction = false;
+    this.resources = resources;
   }
 
   public FunctionInfo(boolean isNative, String displayName,
-      GenericUDAFResolver genericUDAFResolver) {
-    this.isNative = isNative;
+      GenericUDAFResolver genericUDAFResolver, FunctionResource... resources) {
+    this.functionType = isNative ? FunctionType.BUILTIN : FunctionType.TEMPORARY;
     this.displayName = displayName;
     this.genericUDAFResolver = genericUDAFResolver;
     this.isInternalTableFunction = false;
+    this.resources = resources;
   }
 
   public FunctionInfo(boolean isNative, String displayName,
-      GenericUDTF genericUDTF) {
-    this.isNative = isNative;
+      GenericUDTF genericUDTF, FunctionResource... resources) {
+    this.functionType = isNative ? FunctionType.BUILTIN : FunctionType.TEMPORARY;
     this.displayName = displayName;
     this.genericUDTF = genericUDTF;
     this.isInternalTableFunction = false;
+    this.resources = resources;
   }
 
-  public FunctionInfo(String displayName, Class<? extends TableFunctionResolver> tFnCls)
-  {
+  public FunctionInfo(boolean isNative, String displayName, Class<? extends TableFunctionResolver> tFnCls,
+      FunctionResource... resources) {
+    this.functionType = isNative ? FunctionType.BUILTIN : FunctionType.TEMPORARY;
     this.displayName = displayName;
     this.tableFunctionResolver = tFnCls;
     PartitionTableFunctionDescription def = AnnotationUtils.getAnnotation(
         tableFunctionResolver, PartitionTableFunctionDescription.class);
-    this.isNative = (def == null) ? false : def.isInternal();
-    this.isInternalTableFunction = isNative;
+    this.isInternalTableFunction = def != null && def.isInternal();
+    this.resources = resources;
   }
 
   /**
@@ -154,7 +182,7 @@ public class FunctionInfo implements Com
    * Native functions cannot be unregistered.
    */
   public boolean isNative() {
-    return isNative;
+    return functionType == FunctionType.BUILTIN || functionType == FunctionType.PERSISTENT;
   }
 
   /**
@@ -201,4 +229,56 @@ public class FunctionInfo implements Com
     this.blockedFunction = blockedFunction;
   }
 
+  public boolean isBuiltIn() {
+    return functionType == FunctionType.BUILTIN;
+  }
+
+  public boolean isPersistent() {
+    return functionType == FunctionType.PERSISTENT;
+  }
+
+  public String getClassName() {
+    return className;
+  }
+
+  public FunctionResource[] getResources() {
+    return resources;
+  }
+
+  public void discarded() {
+    if (discarded != null) {
+      discarded.set(true);
+    }
+  }
+
+  // for persistent function
+  public boolean isDiscarded() {
+    return discarded != null && discarded.get();
+  }
+
+  // for persistent function
+  public void shareStateWith(FunctionInfo function) {
+    if (function != null) {
+      function.discarded = discarded;
+    }
+  }
+
+  public static class FunctionResource {
+    private final SessionState.ResourceType resourceType;
+    private final String resourceURI;
+    public FunctionResource(SessionState.ResourceType resourceType, String resourceURI) {
+      this.resourceType = resourceType;
+      this.resourceURI = resourceURI;
+    }
+    public SessionState.ResourceType getResourceType() {
+      return resourceType;
+    }
+    public String getResourceURI() {
+      return resourceURI;
+    }
+    @Override
+    public String toString() {
+      return resourceType + ":" + resourceURI;
+    }
+  }
 }