Category Archives: Hive

Hive UDF with testNG test case – concatenate two strings

Hive UDF class package org.puneetha.hive.udf; import org.apache.hadoop.hive.ql.exec.UDF; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.udf.UDFType; import; import org.apache.log4j.Logger; import org.apache.hadoop.hive.ql.exec.Description; /*** * * * @author Puneetha * */ @Description(name = “udf_concat” , value = “_FUNC_(STRING, STRING) – RETURN_TYPE(STRING)\n” + “Description: Concatenate two strings, separated by spaces” , extended = “Example:\n” + ” > SELECT udf_concat(‘hello’,’world’) FROM src;\n” +… Read More »

Hive Commands

Run hive one shot command in background $nohup hive -f sample.hql > output1.out 2>&1 & $nohup hive –database “default” -e “select * from tablename;” > output1.out 2>&1 & Replace delimiter in hive output from default delimiter to the character you wish ( In this example I am replacing it with comma(,) hive –database “database_name” -f… Read More »

Query Hive table from Pig – using HCatalog

Querying hive table from PIG using HCatalog $cat hcatScript.pig A = LOAD ‘db1.tablename’ USING org.apache.hcatalog.pig.HCatLoader(); B = LIMIT A 10; dump B; $pig -useHCatalog -f hcatScript.pig Comment below if you find this blog useful.

Hive Cheat Sheet

Hive CLI will soon be deprecated in favor of Beeline. Check here for beeline commands. Enter into hive shell by typing $hive hive> Hive Shell Commands Description Command Autocomplete hive> Press Tab key Display all 436 possibilities? (y or n) If you enter y, you’ll get a long list of all the keywords Navigation Keystrokes… Read More »