Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F8DB11317 for ; Sun, 6 Apr 2014 18:34:40 +0000 (UTC) Received: (qmail 33209 invoked by uid 500); 6 Apr 2014 18:34:38 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 33152 invoked by uid 500); 6 Apr 2014 18:34:38 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 33144 invoked by uid 99); 6 Apr 2014 18:34:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Apr 2014 18:34:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Apr 2014 18:34:37 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4BDAA2388993; Sun, 6 Apr 2014 18:34:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1585326 - /hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java Date: Sun, 06 Apr 2014 18:34:17 -0000 To: commits@hive.apache.org From: rhbutani@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140406183417.4BDAA2388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rhbutani Date: Sun Apr 6 18:34:16 2014 New Revision: 1585326 URL: http://svn.apache.org/r1585326 Log: HIVE-6848 importing into an existing table fails (Harish Butani via Ashutosh Chauhan) Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java?rev=1585326&r1=1585325&r2=1585326&view=diff ============================================================================== --- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java (original) +++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java Sun Apr 6 18:34:16 2014 @@ -23,6 +23,7 @@ import org.apache.commons.lang.ObjectUti import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hive.common.JavaUtils; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.Warehouse; @@ -35,6 +36,8 @@ import org.apache.hadoop.hive.ql.exec.Ta import org.apache.hadoop.hive.ql.exec.TaskFactory; import org.apache.hadoop.hive.ql.exec.Utilities; import org.apache.hadoop.hive.ql.hooks.WriteEntity; +import org.apache.hadoop.hive.ql.io.HiveFileFormatUtils; +import org.apache.hadoop.hive.ql.io.HiveOutputFormat; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.metadata.InvalidTableException; import org.apache.hadoop.hive.ql.metadata.Table; @@ -437,6 +440,22 @@ public class ImportSemanticAnalyzer exte String importedifc = tableDesc.getInputFormat(); String existingofc = table.getOutputFormatClass().getName(); String importedofc = tableDesc.getOutputFormat(); + /* + * substitute OutputFormat name based on HiveFileFormatUtils.outputFormatSubstituteMap + */ + try { + Class origin = Class.forName(importedofc, true, JavaUtils.getClassLoader()); + Class replaced = HiveFileFormatUtils + .getOutputFormatSubstitute(origin,false); + if (replaced == null) { + throw new SemanticException(ErrorMsg.INVALID_OUTPUT_FORMAT_TYPE + .getMsg()); + } + importedofc = replaced.getCanonicalName(); + } catch(Exception e) { + throw new SemanticException(ErrorMsg.INVALID_OUTPUT_FORMAT_TYPE + .getMsg()); + } if ((!existingifc.equals(importedifc)) || (!existingofc.equals(importedofc))) { throw new SemanticException( @@ -454,6 +473,11 @@ public class ImportSemanticAnalyzer exte .getSerdeParam(serdeConstants.SERIALIZATION_FORMAT); String importedSerdeFormat = tableDesc.getSerdeProps().get( serdeConstants.SERIALIZATION_FORMAT); + /* + * If Imported SerdeFormat is null, then set it to "1" just as + * metadata.Table.getEmptyTable + */ + importedSerdeFormat = importedSerdeFormat == null ? "1" : importedSerdeFormat; if (!ObjectUtils.equals(existingSerdeFormat, importedSerdeFormat)) { throw new SemanticException( ErrorMsg.INCOMPATIBLE_SCHEMA