0

Am trying to write a Union All query in hive. Below is my query

Create table test.Final_Union_Table as
    Select xyz.column_1,xyz.column_2,xyz.column_3
        From (
        Select a.column_1, a.column_2, a.column_3
                From test.Union_table1 a
                Union All
                Select b.column_1, b.column_2, b.column_3
                From test.Final_Table b)xyz;

Am getting the error below

ParseException line 2:0 cannot recognize input near 'z' '.' 'Column_1' in select clause

Would appreciate some help and guidance here.

Thanks.

1 Answer 1

0

I think your query is right,try this

Create table test.Final_Union_Table as
    Select column1,column2,column3
        From (
        Select a.column_1 as column1, a.column_2 as column2, a.column_3 as column3
                From test.Union_table1 a
                Union All
                Select b.column_1 as column1, b.column_2 as column2, b.column_3 as column3
                From test.Final_Table b)xyz;

Note- Data type should be same for particular column in both tables example a.column_1 and b.column_1 should have same data type;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.