Last active
January 1, 2016 19:09
-
-
Save jayunit100/8188647 to your computer and use it in GitHub Desktop.
a quick example of instantiating a hive server for simple tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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