Return-Path: X-Original-To: apmail-hive-user-archive@www.apache.org Delivered-To: apmail-hive-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3428FE3FE for ; Wed, 13 Feb 2013 22:53:14 +0000 (UTC) Received: (qmail 46664 invoked by uid 500); 13 Feb 2013 22:53:12 -0000 Delivered-To: apmail-hive-user-archive@hive.apache.org Received: (qmail 46611 invoked by uid 500); 13 Feb 2013 22:53:12 -0000 Mailing-List: contact user-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hive.apache.org Delivered-To: mailing list user@hive.apache.org Received: (qmail 46602 invoked by uid 99); 13 Feb 2013 22:53:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Feb 2013 22:53:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of edlinuxguru@gmail.com designates 209.85.215.49 as permitted sender) Received: from [209.85.215.49] (HELO mail-la0-f49.google.com) (209.85.215.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Feb 2013 22:53:07 +0000 Received: by mail-la0-f49.google.com with SMTP id fs13so1677570lab.8 for ; Wed, 13 Feb 2013 14:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=BKdQkDWGwr7poArXm+SNHxephR5XiGEQbtaFh5ONv/o=; b=a/J7ZbcP14dM83qcaZtLkagBnY9iQbGf0ZK4cPI4KuegQScb+/b4Hco6z4G2R82Gh3 spqyQ7CJ8EUueB8ttledmcbAowvKx9s4TgfwDBT+Cw7pYnj+f+ZKOWLlkSkN6F8TFLwu MXa+WyVwCjA6bnJ/WDlKhEUR37mzniEdf+XelojuYBopCTXxWuP3qTg7mbEYpwZ7PVno XBvTLu9KxEWaLq5pWCwM12Cx/DNoTDRHYw5zd+yekUL+rgHyf7M/7JnA1cFdXDs1aOVJ OO3gR/KS8rYKotCrnZ0GNHhMClNpKbGesEp/nw7KEFm6UlGzKEeW6fv0i0QyTgyl/NUa fQLQ== MIME-Version: 1.0 X-Received: by 10.112.98.71 with SMTP id eg7mr9450324lbb.133.1360795780025; Wed, 13 Feb 2013 14:49:40 -0800 (PST) Received: by 10.194.61.137 with HTTP; Wed, 13 Feb 2013 14:49:39 -0800 (PST) In-Reply-To: References: <1360783570.58051.YahooMailClassic@web160801.mail.bf1.yahoo.com> Date: Wed, 13 Feb 2013 17:49:39 -0500 Message-ID: Subject: Re: INSERT INTO table with STRUCT, SELECT FROM From: Edward Capriolo To: user@hive.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org I developed the inline udtf. Seems to work: http://svn.apache.org/repos/asf/hive/trunk/ql/src/test/queries/clientpositive/udf_inline.q as (id, text) FROM SRC limit 2; SELECT inline( ARRAY( STRUCT (1,'dude!'), STRUCT (2,'Wheres'), STRUCT (3,'my car?') ) ) as (id, text) FROM SRC limit 2; On Wed, Feb 13, 2013 at 2:47 PM, Dean Wampler wrote: > Hmm. I tried the following hacks, but all wouldn't parse. Ideas? > > I changed: > > ... select struct(x,y) ... > > to > > ... select struct(x,y) as struct ... > ... select cast(struct(x,y) as struct) ... > ... select struct(x as a,y as b) ... > > Okay, but there is a hack that does work; By pass INSERT INTO and just write > to the directory: > > INSERT DIRECTORY '/path/to/table/directory' SELECT ...; > > Just be careful it doesn't clobber any files already there. I'm paranoid, so > I would write to a different directory and then move the files over... > > dean > > On Wed, Feb 13, 2013 at 1:26 PM, Michael Malak > wrote: >> >> Is it possible to INSERT INTO TABLE t SELECT FROM where t has a column >> with a STRUCT? >> >> Based on >> >> http://grokbase.com/t/hive/user/109r87hh3e/insert-data-into-a-column-of-complex-type >> >> I thought perhaps the following would work: >> >> echo 1,2 >twovalues.csv >> hive >> CREATE TABLE tc (x INT, y INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY >> ','; >> LOAD DATA LOCAL INPATH 'twovalues.csv' INTO TABLE tc; >> CREATE TABLE oc (z STRUCT); >> INSERT INTO TABLE oc SELECT struct(x,y) FROM tc; >> >> but when I do the above I get: >> >> FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into >> target table because column number/types are different 'oc': Cannot convert >> column 0 from struct to struct. >> > > > > -- > Dean Wampler, Ph.D. > thinkbiganalytics.com > +1-312-339-1330 >