hive - Insert data in HDFS -


i need create tables in hive , want insert data in hdfs hive table created automatically.

i consider example: hive table

i need information stored in hive. tell me example of how have insert data in hdfs this?

hive tables not created atomatically when upload data hdfs. have manually, or programmatically app. command creating (external) hive tables basically:

hive> create external table <table_name> (param_1_name param_1_type, ...) row format delimited fields terminated ',' location '/user/<your_hdfs_user>/path/to/the/data/directory/'; 

the above structured data in csv-like format. if data written in json, need use serde.

being said that, once hive tables created easy way add new data tables upload such data hdfs directly. can done through webhdfs. instance, if want add file hdfs folder hive table pointing (using curl http cient):

$ curl -i -x put "http://<host>:<port>/webhdfs/v1/<path>?op=create                 [&overwrite=<true |false>][&blocksize=<long>][&replication=<short>]                 [&permission=<octal>][&buffersize=<int>]" 

you receive redirection must followed:

http/1.1 307 temporary_redirect location: http://<datanode>:<port>/webhdfs/v1/<path>?op=create... content-length: 0  

thus, perform put on redirection url:

curl -i -x put -t <local_file> "http://<datanode>:<port>/webhdfs/v1/<path>?op=create..." 

(btw, curl can automatically follow redirections if use -l option).

once file created, can append new data existent file using post method (op=append stated in teh documentation).

hth


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -