You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Gary Clark <gc...@neces.com> on 2015/06/09 15:44:55 UTC

creating a table based on where column=x

Hello,

I would like to create a table based on a selection in hive. Currently I am creating a table based on a location which contains the source csv files and then deriving other tables from that table.

I.e:

create EXTERNAL TABLE initialtable (deployment_id tinyint,
                                             A  bigint,
                                             sample_date string,
                                             charge smallint,
                                             discharge smallint)
             ROW FORMAT DELIMITED
                                             FIELDS TERMINATED BY ',' LOCATION '/user/hue/data';

CREATE TABLE derivedtable AS SELECT * FROM initialtable WHERE deployment_id='22’;

I would just like to create a table where the deployment_id is 22 and not have to create the initial table.

If someone can shed some light on how to do this I would appreciate it. The only example I have seen seem to follow the above?


Thanks,
Gary C

RE: creating a table based on where column=x

Posted by Gary Clark <gc...@neces.com>.
Thankyou so much.

From: Devopam Mittra [mailto:devopam@gmail.com]
Sent: Tuesday, June 09, 2015 12:25 PM
To: user@hive.apache.org
Subject: Re: creating a table based on where column=x

Please evaluate using unix file operations to simply select what you want from the csv and use that extract in your external table.
A simple grep command should do the trick I suppose, but you will need to test it out to suit your needs.

Hope it helps.
regards
Devopam


On Tue, Jun 9, 2015 at 9:50 PM, Abe Weinograd <ab...@flonet.com>> wrote:
Does a view not work for you?

You create your external table as you described and a view which looks like the 2nd table.

Abe

On Tue, Jun 9, 2015 at 9:44 AM, Gary Clark <gc...@neces.com>> wrote:
Hello,

I would like to create a table based on a selection in hive. Currently I am creating a table based on a location which contains the source csv files and then deriving other tables from that table.

I.e:

create EXTERNAL TABLE initialtable (deployment_id tinyint,
                                             A  bigint,
                                             sample_date string,
                                             charge smallint,
                                             discharge smallint)
             ROW FORMAT DELIMITED
                                             FIELDS TERMINATED BY ',' LOCATION '/user/hue/data';

CREATE TABLE derivedtable AS SELECT * FROM initialtable WHERE deployment_id='22’;

I would just like to create a table where the deployment_id is 22 and not have to create the initial table.

If someone can shed some light on how to do this I would appreciate it. The only example I have seen seem to follow the above?


Thanks,
Gary C




--
Devopam Mittra
Life and Relations are not binary

Re: creating a table based on where column=x

Posted by Devopam Mittra <de...@gmail.com>.
Please evaluate using unix file operations to simply select what you want
from the csv and use that extract in your external table.
A simple grep command should do the trick I suppose, but you will need to
test it out to suit your needs.

Hope it helps.
regards
Devopam


On Tue, Jun 9, 2015 at 9:50 PM, Abe Weinograd <ab...@flonet.com> wrote:

> Does a view not work for you?
>
> You create your external table as you described and a view which looks
> like the 2nd table.
>
> Abe
>
> On Tue, Jun 9, 2015 at 9:44 AM, Gary Clark <gc...@neces.com> wrote:
>
>>  Hello,
>>
>>
>>
>> I would like to create a table based on a selection in hive. Currently I
>> am creating a table based on a location which contains the source csv files
>> and then deriving other tables from that table.
>>
>>
>>
>> I.e:
>>
>>
>>
>> create EXTERNAL TABLE initialtable (deployment_id tinyint,
>>
>>                                              A  bigint,
>>
>>                                              sample_date string,
>>
>>                                              charge smallint,
>>
>>                                              discharge smallint)
>>
>>              ROW FORMAT DELIMITED
>>
>>                                              FIELDS TERMINATED BY ','
>> LOCATION '/user/hue/data';
>>
>>
>>
>> CREATE TABLE derivedtable AS SELECT * FROM initialtable WHERE
>> deployment_id='22’;
>>
>>
>>
>> I would just like to create a table where the deployment_id is 22 and not
>> have to create the initial table.
>>
>>
>>
>> If someone can shed some light on how to do this I would appreciate it.
>> The only example I have seen seem to follow the above?
>>
>>
>>
>>
>>
>> Thanks,
>>
>> Gary C
>>
>
>


-- 
Devopam Mittra
Life and Relations are not binary

Re: creating a table based on where column=x

Posted by Abe Weinograd <ab...@flonet.com>.
Does a view not work for you?

You create your external table as you described and a view which looks like
the 2nd table.

Abe

On Tue, Jun 9, 2015 at 9:44 AM, Gary Clark <gc...@neces.com> wrote:

>  Hello,
>
>
>
> I would like to create a table based on a selection in hive. Currently I
> am creating a table based on a location which contains the source csv files
> and then deriving other tables from that table.
>
>
>
> I.e:
>
>
>
> create EXTERNAL TABLE initialtable (deployment_id tinyint,
>
>                                              A  bigint,
>
>                                              sample_date string,
>
>                                              charge smallint,
>
>                                              discharge smallint)
>
>              ROW FORMAT DELIMITED
>
>                                              FIELDS TERMINATED BY ','
> LOCATION '/user/hue/data';
>
>
>
> CREATE TABLE derivedtable AS SELECT * FROM initialtable WHERE
> deployment_id='22’;
>
>
>
> I would just like to create a table where the deployment_id is 22 and not
> have to create the initial table.
>
>
>
> If someone can shed some light on how to do this I would appreciate it.
> The only example I have seen seem to follow the above?
>
>
>
>
>
> Thanks,
>
> Gary C
>