Maybe use ROW_NUMBER() OVER () AS row_num for each table to create a sequence number and then (full outer) join all tables on row_num

Probably best done outside SQL though


On 15/05/2018 18:32, Sowjanya Kakarala wrote:
I am trying to fetch data from hive for 8tables at a time and save it in a csv, so that our pipeline would read that csv which had 8tables data like:

tb1 tb2 tb3 tb4 tb5 tb6 tb7 tb8
0.1 1.1 2.1 -1.1 -0.1 0.1 0.2 3.2
1.2 0.4 4.1 -2.1 -0.5 0.2 0.3 6.2
and so on....

If I fetch one table at a time it will be hard to append all the 8 tables data in one csv(not sure if we can do that and its time consuming).

On Tue, May 15, 2018 at 12:20 PM, Alan Gates <[email protected] <mailto:[email protected]>> wrote:

    You are correct that Hive does not support "with recursive".  A
    few more details of what you are trying to do would be helpful,
    since it's not clear why you need the iteration provided by "with
    recursive".  If you really need the iteration I don't think Hive
    can do what you want.

    Alan.

    On Tue, May 15, 2018 at 9:34 AM, Sowjanya Kakarala
    <[email protected] <mailto:[email protected]>> wrote:

        ok. but in my usecase join's/union's wont help.
        Here is an example of my usecase from postgres, which I have
        to do it in similar way for hive.
        with recursive
        a as (select col from tb1),
        b as (select col from tb2),
        c as (select col from tb3)

        select a,b,c from a,b,c;

        which output's me in a dataframe which i am writing to a csv
        and it looks like
        a     b    c
        0.1 0.2  0.3

        where hive is not supporting `with rec` in same functionality
        as in postgres and views are also not helping here.

        On Tue, May 15, 2018 at 11:19 AM, Alan Gates
        <[email protected] <mailto:[email protected]>> wrote:

            In general this is done using joins, as in all SQL
            engines.  A google search on "intro to SQL joins" will
            suggest a number of resources, for example
            
https://www.essentialsql.com/get-ready-to-learn-sql-12-introduction-to-database-joins/
            
<https://www.essentialsql.com/get-ready-to-learn-sql-12-introduction-to-database-joins/>

            Alan.

            On Tue, May 15, 2018 at 7:37 AM, Sowjanya Kakarala
            <[email protected] <mailto:[email protected]>> wrote:

                Hi all,

                Is there a way in hive that different tables data, can
                be read as in a single query?

                example:
                (something like)
                select a,b from (select col1 from tbl1)a , (select
                col1 from tb2)b);

                output as :
                a      b
                0.1  0.2

                Any help is appreciated.

                Thanks
                Sowjanya





--




--

--
Uli Bethke
CEO Sonra
p: +353 86 32 83 040
Connect on LinkedIn <https://linkedin.com/in/ulibethke>

Convert complex XML to text, a database, or Hadoop <https://sonra.io/flexter-for-xml/> [Training] Big Data for Data Warehouse Professionals <https://sonra.io/big-data-data-warehouse-business-intelligence-professionals/>

Reply via email to