Created on 02-22-2017 03:56 PM - edited 09-16-2022 04:08 AM
Hi,
Can Hadoop/Hive support data access over a REST API? Any examples? Thanks
Created 02-22-2017 04:08 PM
yes via WebHCAT and WebHDFS
# this will execute a hive query and save result to hdfs file in your home directory called output
curl -s -d execute="select+*+from+sample_08;" \
-d statusdir="output" \
'http://localhost:50111/templeton/v1/hive?user.name=root'
# if you ls on the directory, it will have two files, stderr and stdout
hdfs dfs -ls output
# if the job succeeded, you can cat the stdout file and view the results
hdfs dfs -cat output/stdout
WebHDFS
# list the output directory, notice the webhdfs port
curl -i "http://sandbox.hortonworks.com:50070/webhdfs/v1/user/root/output/?op=LISTSTATUS"
# read the output file
curl -i -L "http://sandbox.hortonworks.com:50070/webhdfs/v1/user/root/output/stdout?op=OPEN"
# rename a file, if you get dr. who error, add &user.name=root or any other user in the context
curl -i -X PUT "sandbox.hortonworks.com:50070/webhdfs/v1/user/root/output/stdout?op=RENAME&user.name=root&destination=/user/root/newname"
# read the output of the new file
curl -i -L "http://sandbox.hortonworks.com:50070/webhdfs/v1/user/root/newname?op=OPEN"
Created 06-12-2025 11:21 AM
WebHCat is no longer a supported feature in Cloudera CDP.
[+] https://docs.cloudera.com/cdp-private-cloud-upgrade/latest/upgrade-cdh/topics/hive-unsupported.html
[+] https://docs.cloudera.com/cdp-private-cloud-base/7.3.1/hive-introduction/topics/hive-unsupported.htm...