Four Stars

Run Multiple Queries in Thive Row Component

Hi Team,

 

Could someone please help me through understand, how to run the sequential SQL queries in Thive Row Component?

 

For Example: 

 

DROP TABLE IF EXISTS abcd.table1;

CREATE TABLE abcd.table1;

 

Something like this, which we generally do. 

 

Thanks,
Santosh

5 REPLIES
Seven Stars sgv
Seven Stars

Re: Run Multiple Queries in Thive Row Component

Hello ,

Can you try this

 

"BEGIN

DROP TABLE... ;

CREATE TABLE ;

DROP TABLE ;

CREATE TABLE ;

DROP TABLE ;

CREATE TABLE ; [...]

COMMIT;

END;"

 

Good luck,

SGV

Four Stars

Re: Run Multiple Queries in Thive Row Component

Thanks for your help, but it is still throwing an error. Please find below for the error.

ERROR:
Error while compiling statement: FAILED: ParseException line 1:0 cannot recognize input near 'BEGIN' 'drop' 'table'
at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:235)
at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:221)
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:244)
at
Seven Stars sgv
Seven Stars

Re: Run Multiple Queries in Thive Row Component

What the type of you db source ?

Four Stars

Re: Run Multiple Queries in Thive Row Component

Hue-Hive.

I am able to execute single statements but not in combination with multiple queries separated by ';'
Highlighted
Six Stars

Re: Run Multiple Queries in Thive Row Component

You can always hook up either a tForEach or a tFixedFlowInput in front of the tHiveRow, where each value is a separate query then just pass that object (row.column for tFixedFlowInput, or ((String)globalMap.get("tForeach_1_CURRENT_VALUE") for tForEach) into the tHiveRow query block.