Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive update with subquery

Tags:

sql

hive

I'm trying to update a Hive table from subquery and I know hive doesn't support such updates. Is there any work-around for this?

My update looks like this

UPDATE tmp_aka
    SET guid = (SELECT mguid FROM tmp_maxs
                                        WHERE tmp_maxs.guid = tmp_aka.guid);
like image 870
hlagvankar Avatar asked Aug 19 '16 06:08

hlagvankar


People also ask

Does Hive support subquery?

Hive supports subqueries in FROM clauses and in WHERE clauses of SQL statements. A subquery is a SQL expression that is evaluated and returns a result set. Then that result set is used to evaluate the parent query. The parent query is the outer query that contains the child subquery.

How can I update one table from another table in hive?

You can create a new table and drop the old one thereafter as updating tables isn't possible unless the table has transactional properties set.

Does Hive support with clause?

A Hive WITH Clause can be added before a SELECT statement of you query, to define aliases for complex and complicated expressions that are referenced multiple times within the body of the SELECT statements.


1 Answers

May be you can create a table for your select statement result and insert a new value with insert into table select values from newly created table

like image 191
user3837299 Avatar answered Sep 20 '22 12:09

user3837299