I want to write a Hive UDF which takes variable number of parameters (of different types) and output it as a JSON blob (with column name to column values mapping).
Select userId, myudf(col2, col3) from TABLE 2; // the output of udf should be {"col2":50, "col3":"Y" }
Select userId, myudf(col2, col3, col4) from TABLE 1; // the output of udf should be {"col2":"s", "col3":5, "col4":"Y"}
Select userId, myudf(col2, col3, col4, col6, col7) from TABLE 3; //the output of udf should be {"col2":"M", "col3":"A", "col4":2.5, "col6":"D", "col7":99 }
Each table has different columns with different types (userId is common in all of them). I am ok to pass column names separately, if that helps: myudf("col2", col2, "col3", col3). Any idea would be greatly appreciated.