lundi 17 septembre 2018

Hive: Checking hiveconf ( parameters) in IF/CASE and assigning values dynamically

I am trying to pass in a table name dynamically to hive and then check this value in IF statement to dynamically set a column value. Since table2 doesn't have the column value2, we want to pass a hard coded value.

In the below run, it should assign value 'AAA' to column_A. Somehow hive is checking for column: value2 in table2 passed and returning an error.

select
    IF( '$param1'='table2','AAA',value2) as column_A
from
    $param1;

First parameter passed: $param1=table2

Did any one try such a scenario and it worked out?

Aucun commentaire:

Enregistrer un commentaire