You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Buntu Dev <bu...@gmail.com> on 2014/12/22 20:07:14 UTC

Insert into partitioned table from unpartitioned table

Hi -- I got the destination table with partition on columns that are not in
the source table and get this error when attempting to do an INSERT
OVERWRITE, how to go about fixing this? Thanks:


SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
INSERT OVERWRITE TABLE dest_table PARTITION (year, month, day)
SELECT *
FROM source_table

Cannot insert into target table because column number/types are different
'day': Table insclause-0 has 42 columns, but query has 39 columns.

Re: Insert into partitioned table from unpartitioned table

Posted by Stéphane Verlet <ka...@gmail.com>.
sorry I did not see that the partitions columns were not in the source
table

You need  to set the values for the partititons

INSERT OVERWRITE TABLE dest_table PARTITION (year='2014', month='12',
day='22')
SELECT
....

On Mon, Dec 22, 2014 at 3:37 PM, Stéphane Verlet <ka...@gmail.com>
wrote:

> Specify the cols with the partition cols last in the select statement
>
> INSERT OVERWRITE TABLE dest_table PARTITION (year, month, day)
> SELECT
>
> field1 ,
> field2,
> ...
> year,
> month,
> day
>
> FROM source_table
>
> On Mon, Dec 22, 2014 at 12:07 PM, Buntu Dev <bu...@gmail.com> wrote:
>
>> Hi -- I got the destination table with partition on columns that are not
>> in the source table and get this error when attempting to do an INSERT
>> OVERWRITE, how to go about fixing this? Thanks:
>>
>>
>> SET hive.exec.dynamic.partition = true;
>> SET hive.exec.dynamic.partition.mode = nonstrict;
>> INSERT OVERWRITE TABLE dest_table PARTITION (year, month, day)
>> SELECT *
>> FROM source_table
>>
>> Cannot insert into target table because column number/types are different
>> 'day': Table insclause-0 has 42 columns, but query has 39 columns.
>>
>>
>

Re: Insert into partitioned table from unpartitioned table

Posted by Stéphane Verlet <ka...@gmail.com>.
Specify the cols with the partition cols last in the select statement

INSERT OVERWRITE TABLE dest_table PARTITION (year, month, day)
SELECT

field1 ,
field2,
...
year,
month,
day

FROM source_table

On Mon, Dec 22, 2014 at 12:07 PM, Buntu Dev <bu...@gmail.com> wrote:

> Hi -- I got the destination table with partition on columns that are not
> in the source table and get this error when attempting to do an INSERT
> OVERWRITE, how to go about fixing this? Thanks:
>
>
> SET hive.exec.dynamic.partition = true;
> SET hive.exec.dynamic.partition.mode = nonstrict;
> INSERT OVERWRITE TABLE dest_table PARTITION (year, month, day)
> SELECT *
> FROM source_table
>
> Cannot insert into target table because column number/types are different
> 'day': Table insclause-0 has 42 columns, but query has 39 columns.
>
>