Skip to content

Instantly share code, notes, and snippets.

@jayunit100
Last active January 1, 2016 19:09
Show Gist options
  • Save jayunit100/8188647 to your computer and use it in GitHub Desktop.
Save jayunit100/8188647 to your computer and use it in GitHub Desktop.
a quick example of instantiating a hive server for simple tests.
//create a simple server
HiveConf conf = new HiveConf();
HiveServerHandler server = new HiveServerHandler(conf){};
//create a table
String create = "CREATE EXTERNAL TABLE InputData (code STRING, transaction STRING) ROW FORMAT DELIMTED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE LOCATION '/tmp/myinput.txt' ); ";
;
server.execute(create);
//load data into it
server.execute("LOAD DATA INPATH '<rawInput>' INTO TABLE hive_bigpetstore_etl".replaceAll("<rawInput>", input.toString()));
//exec a mapreduce job to query it
server.execute("select e7 from hive_bigpetstore_etl");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment