Return-Path: X-Original-To: apmail-hive-dev-archive@www.apache.org Delivered-To: apmail-hive-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3719017E1E for ; Fri, 13 Feb 2015 03:22:35 +0000 (UTC) Received: (qmail 7405 invoked by uid 500); 13 Feb 2015 03:22:13 -0000 Delivered-To: apmail-hive-dev-archive@hive.apache.org Received: (qmail 7327 invoked by uid 500); 13 Feb 2015 03:22:12 -0000 Mailing-List: contact dev-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list dev@hive.apache.org Received: (qmail 7307 invoked by uid 500); 13 Feb 2015 03:22:12 -0000 Delivered-To: apmail-hadoop-hive-dev@hadoop.apache.org Received: (qmail 7304 invoked by uid 99); 13 Feb 2015 03:22:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2015 03:22:12 +0000 Date: Fri, 13 Feb 2015 03:22:12 +0000 (UTC) From: "Hive QA (JIRA)" To: hive-dev@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HIVE-9481) allow column list specification in INSERT statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-9481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14319513#comment-14319513 ] Hive QA commented on HIVE-9481: ------------------------------- {color:green}Overall{color}: +1 all checks pass Here are the results of testing the latest attachment: https://issues.apache.org/jira/secure/attachment/12698516/HIVE-9481.6.patch {color:green}SUCCESS:{color} +1 7550 tests passed Test results: http://ec2-174-129-184-35.compute-1.amazonaws.com/jenkins/job/PreCommit-HIVE-TRUNK-Build/2784/testReport Console output: http://ec2-174-129-184-35.compute-1.amazonaws.com/jenkins/job/PreCommit-HIVE-TRUNK-Build/2784/console Test logs: http://ec2-174-129-184-35.compute-1.amazonaws.com/logs/PreCommit-HIVE-TRUNK-Build-2784/ Messages: {noformat} Executing org.apache.hive.ptest.execution.PrepPhase Executing org.apache.hive.ptest.execution.ExecutionPhase Executing org.apache.hive.ptest.execution.ReportingPhase {noformat} This message is automatically generated. ATTACHMENT ID: 12698516 - PreCommit-HIVE-TRUNK-Build > allow column list specification in INSERT statement > --------------------------------------------------- > > Key: HIVE-9481 > URL: https://issues.apache.org/jira/browse/HIVE-9481 > Project: Hive > Issue Type: Bug > Components: Parser, Query Processor, SQL > Affects Versions: 0.14.0 > Reporter: Eugene Koifman > Assignee: Eugene Koifman > Attachments: HIVE-9481.2.patch, HIVE-9481.4.patch, HIVE-9481.5.patch, HIVE-9481.6.patch, HIVE-9481.patch > > > Given a table FOO(a int, b int, c int), ANSI SQL supports insert into FOO(c,b) select x,y from T. The expectation is that 'x' is written to column 'c' and 'y' is written column 'b' and 'a' is set to NULL, assuming column 'a' is NULLABLE. > Hive does not support this. In Hive one has to ensure that the data producing statement has a schema that matches target table schema. > Since Hive doesn't support DEFAULT value for columns in CREATE TABLE, when target schema is explicitly provided, missing columns will be set to NULL if they are NULLABLE, otherwise an error will be raised. > If/when DEFAULT clause is supported, this can be enhanced to set default value rather than NULL. > Thus, given {noformat} > create table source (a int, b int); > create table target (x int, y int, z int); > create table target2 (x int, y int, z int); > {noformat} > {noformat}insert into target(y,z) select * from source;{noformat} > will mean > {noformat}insert into target select null as x, a, b from source;{noformat} > and > {noformat}insert into target(z,y) select * from source;{noformat} > will meant > {noformat}insert into target select null as x, b, a from source;{noformat} > Also, > {noformat} > from source > insert into target(y,z) select null as x, * > insert into target2(y,z) select null as x, source.*; > {noformat} > and for partitioned tables, given > {noformat} > Given: > CREATE TABLE pageviews (userid VARCHAR(64), link STRING, "from" STRING) > PARTITIONED BY (datestamp STRING) CLUSTERED BY (userid) INTO 256 BUCKETS STORED AS ORC; > INSERT INTO TABLE pageviews PARTITION (datestamp = '2014-09-23')(userid,link) > VALUES ('jsmith', 'mail.com'); > {noformat} > And dynamic partitioning > {noformat} > INSERT INTO TABLE pageviews PARTITION (datestamp)(userid,datestamp,link) > VALUES ('jsmith', '2014-09-23', 'mail.com'); > {noformat} > In all cases, the schema specification contains columns of the target table which are matched by position to the values produced by VALUES clause/SELECT statement. If the producer side provides values for a dynamic partition column, the column should be in the specified schema. Static partition values are part of the partition spec and thus are not produced by the producer and should not be part of the schema specification. -- This message was sent by Atlassian JIRA (v6.3.4#6332)