You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/08/20 16:55:58 UTC

svn commit: r1515839 - in /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse: ImportSemanticAnalyzer.java MetaDataExportListener.java

Author: hashutosh
Date: Tue Aug 20 14:55:58 2013
New Revision: 1515839

URL: http://svn.apache.org/r1515839
Log:
HIVE-4299 : exported metadata by HIVE3068 cannot be imported because of wrong file name (Sho Shimauchi & Edward Capriolo via Ashutosh Chauhan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/MetaDataExportListener.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java?rev=1515839&r1=1515838&r2=1515839&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java Tue Aug 20 14:55:58 2013
@@ -64,6 +64,8 @@ import org.apache.hadoop.hive.serde.serd
  */
 public class ImportSemanticAnalyzer extends BaseSemanticAnalyzer {
 
+  public static final String METADATA_NAME="_metadata";
+
   public ImportSemanticAnalyzer(HiveConf conf) throws SemanticException {
     super(conf);
   }
@@ -89,7 +91,7 @@ public class ImportSemanticAnalyzer exte
       Path fromPath = new Path(fromURI.getScheme(), fromURI.getAuthority(),
           fromURI.getPath());
       try {
-        Path metadataPath = new Path(fromPath, "_metadata");
+        Path metadataPath = new Path(fromPath, METADATA_NAME);
         Map.Entry<org.apache.hadoop.hive.metastore.api.Table,
         List<Partition>> rv =  EximUtil.readMetaData(fs, metadataPath);
         dbname = db.getCurrentDatabase();

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/MetaDataExportListener.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/MetaDataExportListener.java?rev=1515839&r1=1515838&r2=1515839&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/MetaDataExportListener.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/MetaDataExportListener.java Tue Aug 20 14:55:58 2013
@@ -38,14 +38,13 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.events.PreEventContext;
 import org.apache.hadoop.hive.metastore.events.PreEventContext.PreEventType;
 import org.apache.hadoop.hive.ql.session.SessionState;
-
+import org.apache.hadoop.hive.ql.parse.ImportSemanticAnalyzer;
 /**
  * This class listens for drop events and, if set, exports the table's metadata as JSON to the trash
  * of the user performing the drop
  */
 public class MetaDataExportListener extends MetaStorePreEventListener {
   public static final Log LOG = LogFactory.getLog(MetaDataExportListener.class);
-  private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
 
   /** Configure the export listener */
   public MetaDataExportListener(Configuration config) {
@@ -65,6 +64,7 @@ public class MetaDataExportListener exte
     Path tblPath = new Path(tbl.getSd().getLocation());
     fs = wh.getFs(tblPath);
     Date now = new Date();
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
     String dateString = sdf.format(now);
     String exportPathString = hiveconf.getVar(HiveConf.ConfVars.METADATA_EXPORT_LOCATION);
     boolean moveMetadataToTrash = hiveconf
@@ -83,7 +83,7 @@ public class MetaDataExportListener exte
     } catch (IOException e) {
       throw new MetaException(e.getMessage());
     }
-    Path outFile = new Path(metaPath, name + ".metadata");
+    Path outFile = new Path(metaPath, name + ImportSemanticAnalyzer.METADATA_NAME);
     try {
       SessionState.getConsole().printInfo("Beginning metadata export");
       EximUtil.createExportDump(fs, outFile, mTbl, null);