You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Kaufman Ng <ka...@cloudera.com> on 2012/09/13 22:36:13 UTC

insert into table not working with tables prefixed with database name

Does anyone know if insert into statement is supposed to work across
databases/schemas?

For instance if I do this the target table gets appended correctly:

insert into table target select * from source;

However, if I have another target table in a different database, the
target table simply gets overwritten instead of appended:

insert into table my_database.target select * from source;

To get around this, one needs to switch to the target database first,
then run the insert into statement like this:

insert into table target select * from default.source;

Just wanna confirm if this is a bug.  Thx.

Kaufman

Re: insert into table not working with tables prefixed with database name

Posted by Kaufman Ng <ka...@cloudera.com>.
I have created HIVE-3465 for this issue.

On Mon, Sep 17, 2012 at 1:17 AM, MiaoMiao <li...@gmail.com> wrote:
> Yes, same problem here, sorry I missed your point and tested only once.
>
> On Fri, Sep 14, 2012 at 10:13 PM, Kaufman Ng <ka...@cloudera.com> wrote:
>> Did you run the insert into query twice?  And did it append?
>>
>> From what I observred the query will complete successfully, but it
>> overwrites instead of append.  That's the problem.
>>
>>
>> On Thu, Sep 13, 2012 at 11:07 PM, MiaoMiao <li...@gmail.com> wrote:
>>> This query works on my hive 0.8
>>>
>>> insert into table tmp.testtest select user,city from source;
>>>
>>> On Fri, Sep 14, 2012 at 4:36 AM, Kaufman Ng <ka...@cloudera.com> wrote:
>>>> Does anyone know if insert into statement is supposed to work across
>>>> databases/schemas?
>>>>
>>>> For instance if I do this the target table gets appended correctly:
>>>>
>>>> insert into table target select * from source;
>>>>
>>>> However, if I have another target table in a different database, the
>>>> target table simply gets overwritten instead of appended:
>>>>
>>>> insert into table my_database.target select * from source;
>>>>
>>>> To get around this, one needs to switch to the target database first,
>>>> then run the insert into statement like this:
>>>>
>>>> insert into table target select * from default.source;
>>>>
>>>> Just wanna confirm if this is a bug.  Thx.
>>>>
>>>> Kaufman

Re: insert into table not working with tables prefixed with database name

Posted by MiaoMiao <li...@gmail.com>.
Yes, same problem here, sorry I missed your point and tested only once.

On Fri, Sep 14, 2012 at 10:13 PM, Kaufman Ng <ka...@cloudera.com> wrote:
> Did you run the insert into query twice?  And did it append?
>
> From what I observred the query will complete successfully, but it
> overwrites instead of append.  That's the problem.
>
>
> On Thu, Sep 13, 2012 at 11:07 PM, MiaoMiao <li...@gmail.com> wrote:
>> This query works on my hive 0.8
>>
>> insert into table tmp.testtest select user,city from source;
>>
>> On Fri, Sep 14, 2012 at 4:36 AM, Kaufman Ng <ka...@cloudera.com> wrote:
>>> Does anyone know if insert into statement is supposed to work across
>>> databases/schemas?
>>>
>>> For instance if I do this the target table gets appended correctly:
>>>
>>> insert into table target select * from source;
>>>
>>> However, if I have another target table in a different database, the
>>> target table simply gets overwritten instead of appended:
>>>
>>> insert into table my_database.target select * from source;
>>>
>>> To get around this, one needs to switch to the target database first,
>>> then run the insert into statement like this:
>>>
>>> insert into table target select * from default.source;
>>>
>>> Just wanna confirm if this is a bug.  Thx.
>>>
>>> Kaufman

Re: insert into table not working with tables prefixed with database name

Posted by Kaufman Ng <ka...@cloudera.com>.
Did you run the insert into query twice?  And did it append?

>From what I observred the query will complete successfully, but it
overwrites instead of append.  That's the problem.


On Thu, Sep 13, 2012 at 11:07 PM, MiaoMiao <li...@gmail.com> wrote:
> This query works on my hive 0.8
>
> insert into table tmp.testtest select user,city from source;
>
> On Fri, Sep 14, 2012 at 4:36 AM, Kaufman Ng <ka...@cloudera.com> wrote:
>> Does anyone know if insert into statement is supposed to work across
>> databases/schemas?
>>
>> For instance if I do this the target table gets appended correctly:
>>
>> insert into table target select * from source;
>>
>> However, if I have another target table in a different database, the
>> target table simply gets overwritten instead of appended:
>>
>> insert into table my_database.target select * from source;
>>
>> To get around this, one needs to switch to the target database first,
>> then run the insert into statement like this:
>>
>> insert into table target select * from default.source;
>>
>> Just wanna confirm if this is a bug.  Thx.
>>
>> Kaufman

Re: insert into table not working with tables prefixed with database name

Posted by MiaoMiao <li...@gmail.com>.
This query works on my hive 0.8

insert into table tmp.testtest select user,city from source;

On Fri, Sep 14, 2012 at 4:36 AM, Kaufman Ng <ka...@cloudera.com> wrote:
> Does anyone know if insert into statement is supposed to work across
> databases/schemas?
>
> For instance if I do this the target table gets appended correctly:
>
> insert into table target select * from source;
>
> However, if I have another target table in a different database, the
> target table simply gets overwritten instead of appended:
>
> insert into table my_database.target select * from source;
>
> To get around this, one needs to switch to the target database first,
> then run the insert into statement like this:
>
> insert into table target select * from default.source;
>
> Just wanna confirm if this is a bug.  Thx.
>
> Kaufman

Re: insert into table not working with tables prefixed with database name

Posted by Aniket Mokashi <an...@gmail.com>.
I haven't used insert into but i observed a similar problem earlier-
https://issues.apache.org/jira/browse/HIVE-2617

You can check against the trunk or open a jira.

~Aniket

On Thu, Sep 13, 2012 at 1:36 PM, Kaufman Ng <ka...@cloudera.com> wrote:

> Does anyone know if insert into statement is supposed to work across
> databases/schemas?
>
> For instance if I do this the target table gets appended correctly:
>
> insert into table target select * from source;
>
> However, if I have another target table in a different database, the
> target table simply gets overwritten instead of appended:
>
> insert into table my_database.target select * from source;
>
> To get around this, one needs to switch to the target database first,
> then run the insert into statement like this:
>
> insert into table target select * from default.source;
>
> Just wanna confirm if this is a bug.  Thx.
>
> Kaufman
>



-- 
"...:::Aniket:::... Quetzalco@tl"