WebHCat
- The following uses the service IP address of WebHCat and the WebHCat HTTP port configured during the installation as an example.
- You can perform the example operations only after kinit authentication is implemented on the installed client.
- The examples of the HTTPS protocol are as follows. To use the HTTP protocol, you need to perform the following operations:
- Switch the RESTful API to the HTTP protocol. For details, see Configuring HTTPS/HTTP-based REST APIs.
- Delete --insecure from the example and replace HTTPS with HTTP, for example:
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/status'
is changed to
curl -i -u : --negotiate 'http://10.64.35.144:9111/templeton/v1/status'
- Before performing the operation, ensure that the curl in use is later than 7.34.0.
You can run the following command to view the curl version:
curl -V
- :version(GET)
- Description
- URL
- Parameter
Parameter
Description
:version
WebHCat version number. Currently, the version number must be v1.
- Returned result
Parameter
Description
responseTypes
List of response types supported by WebHCat.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1'
- status (GET)
- Description
- URL
- Parameter
- Returned result
Parameter
Description
status
If the WebHCat connection is normal, OK is returned.
version
Character string, including the version number, for example, v1.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/status'
- version (GET)
- Description
- URL
- Parameter
- Returned result
Parameter
Description
supportedVersions
All supported versions.
version
WebHCat version of the server.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/version'
- version/hive (GET)
- Description
- URL
- Parameter
- Returned result
Parameter
Description
module
Hive.
version
Hive version.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/version/hive'
- version/hadoop (GET)
- Description
- URL
- Parameter
- Returned result
Parameter
Description
module
Hadoop.
version
Hadoop version.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/version/hadoop'
- ddl (POST)
- Description
- URL
- Parameter
Parameter
Description
exec
HCatalog DDL statement to be executed.
group
User group used when DDL is used to create a table.
permissions
Permission used when DDL is used to create a table. The format is rwxr-xr-x.
- Returned result
Parameter
Description
stdout
Standard output value during HCatalog execution. The value may be empty.
stderr
Error output during HCatalog execution. The value may be empty.
exitcode
Return value of HCatalog.
- Example
curl -i -u : --insecure --negotiate -d exec="show tables" 'https://10.64.35.144:9111/templeton/v1/ddl'
- ddl/database (GET)
- Description
- URL
- Parameter
Parameter
Description
like
Regular expression used to match the database name.
- Returned result
Parameter
Description
databases
Database name.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/ddl/database'
- ddl/database/:db (GET)
- Description
- URL
- Parameter
Parameter
Description
:db
Database name.
- Returned result
Parameter
Description
location
Database location.
comment
Database remarks. If there are no database remarks, the value is null.
database
Database name.
owner
Database owner.
owertype
Type of the database owner.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/ddl/database/default'
- ddl/database/:db (PUT)
- Description
- URL
- Parameter
Parameter
Description
:db
Database name.
group
User group used for creating the database.
permission
Permission used for creating the database.
location
Database location.
comment
Database remarks, for example, description.
properties
Database properties.
- Returned result
Parameter
Description
database
Name of the newly created database.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{"location": "/tmp/a", "comment": "my db", "properties": {"a": "b"}}' 'https://10.64.35.144:9111/templeton/v1/ddl/database/db2'
- ddl/database/:db (DELETE)
- Description
- URL
- Parameter
Parameter
Description
:db
Database name.
ifExists
If the specified database does not exist, Hive returns an error unless ifExists is set to true.
option
Set the parameter to cascade or restrict. If you set it to cascade, all data and definitions are cleared. If you set it to restrict, the table content is empty and the mode does not exist.
- Returned result
Parameter
Description
database
Name of the deleted database.
- Example
curl -i -u : --insecure --negotiate -X DELETE 'https://10.64.35.144:9111/templeton/v1/ddl/database/db3?ifExists=true'
- ddl/database/:db/table (GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table
- Parameter
Parameter
Description
:db
Database name.
like
Regular expression used to match a table name.
- Returned result
Parameter
Description
database
Database name.
tables
List of tables in the database.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/ddl/database/default/table'
- ddl/database/:db/table/:table (GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
format
The format is "format=extended". If you want to see additional information, use "table extended like".
- Returned result
Parameter
Description
columns
Column name and type.
database
Database name.
table
Table name.
partitioned
Whether a table is a partition table. This parameter is available only when the table format is extended.
location
Table location. This parameter is available only when the table format is extended.
outputformat
Output format. This parameter is available only when the table format is extended.
inputformat
Input format. This parameter is available only when the table format is extended.
owner
Table owner. This parameter is available only when the table format is extended.
partitionColumns
Partition column. This parameter is available only when the table format is extended.
- Example
curl -i -u : --insecure --negotiate 'https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1?format=extended'
- ddl/database/:db/table/:table (PUT)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table
- Parameter
Parameter
Description
:db
Database name.
:table
New table name.
group
User group used for creating the table.
permissions
Permission used for creating the table.
external
Allows you to specify a location so that Hive does not use the default location for this table.
ifNotExists
If this parameter is set to true, no error is reported if a table exists.
comment
Remarks.
columns
Column description, including the column name, type, and optional remarks.
partitionedBy
Partition column description, which is used to partition tables. The columns parameter is used to list the column name, type, and optional remarks.
clusteredBy
Bucket column description, including the columnNames, sortedBy, and numberOfBuckets parameters. The columnNames parameter includes columnName and sorting sequence (ASC indicates an ascending order, and DESC indicates a descending order).
format
Storage format. The parameters include rowFormat, storedAs, and storedBy.
location
HDFS path.
tableProperties
Table property names and values (name-value pairs).
- Returned result
Parameter
Description
database
Database name.
table
Table name.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{"columns": [{"name": "id", "type": "int"}, {"name": "name","type": "string"}], "comment": "hello","format": {"storedAs": "orc"} }' 'https://10.64.35.144:9111/templeton/v1/ddl/database/db3/table/tbl1'
- ddl/database/:db/table/:table (POST)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table
- Parameter
Parameter
Description
:db
Database name.
:table
Existing table name.
rename
New table name.
- Returned result
Parameter
Description
database
Database name.
table
New table name.
- Example
curl -i -u : --insecure --negotiate -d rename=table1 'https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/tbl1'
- ddl/database/:db/table/:table (DELETE)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
ifExists
If this parameter is set to true, no error is reported.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
- Example
curl -i -u : --insecure --negotiate -X DELETE 'https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/table2?ifExists=true'
- ddl/database/:db/table/:existingtable/like/:newtable (PUT)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:existingtable/like/:newtable
- Parameter
Parameter
Description
:db
Database name.
:existingtable
Existing table name.
:newtable
New table name.
group
User group used for creating the table.
permissions
Permission used for creating the table.
external
Allows you to specify a location so that Hive does not use the default location for this table.
ifNotExists
If this parameter is set to true, the Hive does not report an error if a table already exists.
location
HDFS path.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{"ifNotExists": "true"}' 'https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/like/tt1'
- ddl/database/:db/table/:table/partition(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/partition
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
partitions
List of partition attribute values and partition names.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/x1/partition
- ddl/database/:db/table/:table/partition/:partition(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/partition/:partition
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
:partition
Partition name. Exercise caution when decoding HTTP quote, for example, country=%27algeria%27.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
partition
Partition name.
partitioned
If this parameter is set to true, the table is a partitioned table.
location
Storage path of the table.
outputFormat
Output format.
columns
Column name, type, and remarks.
owner
Owner.
partitionColumns
Partition column.
inputFormat
Input format.
totalNumberFiles
Number of files in a partition.
totalFileSize
Total size of files in a partition.
maxFileSize
Maximum file size.
minFileSize
Minimum file size.
lastAccessTime
Last access time.
lastUpdateTime
Last update time.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/x1/partition/dt=1
- ddl/database/:db/table/:table/partition/:partition(PUT)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/partition/:partition
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
group
User group used for creating a partition.
permissions
User permission used for creating a partition.
location
Storage location of the new partition.
ifNotExists
If this parameter is set to true, the system reports an error when the partition already exists.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
partitions
Partition name.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{}' https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/x1/partition/dt=10
- ddl/database/:db/table/:table/partition/:partition(DELETE)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/partition/:partition
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
group
User group used for deleting a new partition.
permissions
User permission used for deleting a new partition. The format is rwxrw-r-x.
ifExists
If the specified partition does not exist, the Hive reports an error, unless this parameter is set to true.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
partitions
Partition name.
- Example
curl -i -u : --insecure --negotiate -X DELETE -HContent-type:application/json -d '{}' https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/x1/partition/dt=10
- ddl/database/:db/table/:table/column(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/column
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
columns
Column name and type.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/column
- ddl/database/:db/table/:table/column/:column(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/column/:column
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
:column
Column name.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
column
Column name and type.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/column/id
- ddl/database/:db/table/:table/column/:column(PUT)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/column/:column
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
:column
Column name.
type
Column type, for example, string and int.
comment
Column remarks, for example, description.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
column
Column name.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{"type": "string", "comment": "new column"}' https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/column/name
- ddl/database/:db/table/:table/property(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/property
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
properties
Property.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/property
- ddl/database/:db/table/:table/property/:property(GET)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/property/:property
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
:property
Property name.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
property
Property list.
- Example
curl -i -u : --insecure --negotiate https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/property/last_modified_by
- ddl/database/:db/table/:table/property/:property(PUT)
- Description
- URL
https://www.myserver.com/templeton/v1/ddl/database/:db/table/:table/property/:property
- Parameter
Parameter
Description
:db
Database name.
:table
Table name.
:property
Property name.
value
Property value.
- Returned result
Parameter
Description
database
Database name.
table
Table name.
property
Property name.
- Example
curl -i -u : --insecure --negotiate -X PUT -HContent-type:application/json -d '{"value": "my value"}' https://10.64.35.144:9111/templeton/v1/ddl/database/default/table/t1/property/mykey
- mapreduce/jar(POST)
- Description
Executes a MapReduce job. Before executing a MapReduce job, upload the JAR file of the MapReduce job to HDFS.
- URL
- Parameter
Parameter
Description
jar
JAR file of the MapReduce job to be executed.
class
Class of the MapReduce job to be executed.
libjars
JAR file names of classpath to be added, separated by commas (,).
files
Names of files to be copied to the MapReduce cluster, separated by commas (,).
arg
Input parameter received by the Main class.
define
This parameter is used to configure Hadoop in the define=NAME=VALUE format.
statusdir
WebHCat writes the status of the MapReduce task to statusdir. If this parameter is set, you need to manually delete it.
enablelog
If statusdir is set and enablelog is set to true, Hadoop task configurations and logs are collected to $statusdir/logs. Then, successful and failed attempts are recorded in the logs. The layout of the subdirectories in $statusdir/logs is as follows:
logs/$job_id (directory for $job_id)
logs/$job_id/job.xml.html
logs/$job_id/$attempt_id (directory for $attempt_id)
logs/$job_id/$attempt_id/stderr
logs/$job_id/$attempt_id/stdout
logs/$job_id/$attempt_id/syslog
Only Hadoop 1.X is supported.
callback
Callback address after MapReduce job execution. Use $jobId to embed the job ID in the callback address. In the callback address, replace the $jobId with the job ID.
- Returned result
Parameter
Description
id
Job ID, similar to job_201110132141_0001.
- Example
curl -i -u : --insecure --negotiate -d jar="/tmp/word.count-0.0.1-SNAPSHOT.jar" -d class=com.huawei.word.count.WD -d statusdir="/output" -d enablelog=true "https://10.64.35.144:9111/templeton/v1/mapreduce/jar"
- Description
- mapreduce/streaming(POST)
- Description
- URL
- Parameter
Parameter
Description
input
Input path of Hadoop.
output
Output save path. If this parameter is not specified, WebHCat will store the output in a path that can be found by using queue resources.
mapper
Location of the mapper program.
reducer
Location of the reducer program.
files
Add HDFS files to the distributed cache.
arg
Set an argument.
define
Set Hadoop configuration variables in the define=NAME=VALUE format.
cmdenv
Set environment variables in the cmdenv=NAME=VALUE format.
statusdir
WebHCat writes the status of the MapReduce task to statusdir. If this parameter is set, you need to manually delete it.
enablelog
If statusdir is set and enablelog is set to true, Hadoop task configurations and logs are collected to $statusdir/logs. Then, successful and failed attempts are recorded in the logs. The layout of the subdirectories in $statusdir/logs is as follows:
logs/$job_id (directory for $job_id)
logs/$job_id/job.xml.html
logs/$job_id/$attempt_id (directory for $attempt_id)
logs/$job_id/$attempt_id/stderr
logs/$job_id/$attempt_id/stdout
logs/$job_id/$attempt_id/syslog
Only Hadoop 1.X is supported.
callback
Callback address after MapReduce job execution. Use $jobId to embed the job ID in the callback address. In the callback address, replace the $jobId with the job ID.
- Returned result
Parameter
Description
id
Job ID, similar to job_201110132141_0001.
- Example
curl -i -u : --insecure --negotiate -d input=/input -d output=/oooo -d mapper=/bin/cat -d reducer="/usr/bin/wc -w" -d statusdir="/output" 'https://10.64.35.144:9111/templeton/v1/mapreduce/streaming'
Before using this API, ensure that the prerequisites are met. For details, see Rules.
- /hive(POST)
- Description
- URL
- Parameter
Parameter
Description
execute
Hive commands, including entire and short Hive commands.
file
HDFS file containing Hive commands.
files
Names of files to be copied to the MapReduce cluster, separated by commas (,).
arg
Set an argument.
define
Hive configuration. The format is define=key=value. When using the post statement, you need to configure the scratch dir of the instance. The WebHCat instance uses define=hive.exec.scratchdir=/tmp/hive-scratch, and the WebHCat1 instance uses define=hive.exec.scratchdir=/tmp/hive1-scratch. The same rule applies to other instances.
statusdir
WebHCat writes the status of the MapReduce task to statusdir. If this parameter is set, you need to manually delete it.
enablelog
If statusdir is set and enablelog is set to true, Hadoop task configurations and logs are collected to $statusdir/logs. Then, successful and failed attempts are recorded in the logs. The layout of the subdirectories in $statusdir/logs is as follows:
logs/$job_id (directory for $job_id)
logs/$job_id/job.xml.html
logs/$job_id/$attempt_id (directory for $attempt_id)
logs/$job_id/$attempt_id/stderr
logs/$job_id/$attempt_id/stdout
logs/$job_id/$attempt_id/syslog
callback
Callback address after MapReduce job execution. Use $jobId to embed the job ID in the callback address. In the callback address, replace the $jobId with the job ID.
- Returned result
Parameter
Description
id
Job ID, similar to job_201110132141_0001.
- Example
curl -i -u : --insecure --negotiate -d execute="select count(*) from t1" -d define=hive.exec.scratchdir=/tmp/hive-scratch -d statusdir="/output" "https://10.64.35.144:9111/templeton/v1/hive"
- jobs(GET)
- Description
- URL
- Parameter
Parameter
Description
fields
If this parameter is set to *, details about each job are returned. If this parameter is not set, only a job ID is returned. The parameter can only be set to *. If the parameter is set to another value, an exception occurs.
jobid
If jobid is set, only jobs whose lexicographic order is greater than jobid are returned. For example, if the value of jobid is job_201312091733_0001, only the job whose value is greater than the value can be returned. The number of returned jobs depends on the value of numrecords.
numrecords
If numrecords and jobid are set, the jobid list is sorted lexicographically. After jobid is returned, the maximum value of numrecords can be obtained. If jobid is not set but numrecords is set, the maximum value of numrecords can be obtained after the jobid list is sorted lexicographically. In contrast, if numrecords is not set but jobid is set, all jobs whose lexicographic orders are greater than jobid will be returned.
showall
If showall is set to true, the request will return all jobs the user has permission to view, not only the jobs belonging to the user.
- Returned result
Parameter
Description
id
Job id
detail
If the value of showall is true, details are displayed. Otherwise, the value is null.
- Example
curl -i -u : --insecure --negotiate "https://10.64.35.144:9111/templeton/v1/jobs"
- jobs/:jobid(GET)
- Description
- URL
- Parameter
Parameter
Description
jobid
Job ID, received after a job is created.
- Returned result
Parameter
Description
status
JSON object containing job status information.
profile
JSON object containing job information. WebHCat parses information in the JobProfile object. The object varies according to the Hadoop version.
id
Job ID.
percentComplete
Job completion percentage, for example, 75%. If the job is complete, the value is null.
user
User who created the job.
callback
Callback URL (if any).
userargs
Parameter argument and parameter value when a user submits a job.
exitValue
Exit value of the job.
- Example
curl -i -u : --insecure --negotiate "https://10.64.35.144:9111/templeton/v1/jobs/job_1440386556001_0255"
- jobs/:jobid(DELETE)
- Description
- URL
- Parameter
Parameter
Description
:jobid
ID of the job to be deleted.
- Returned result
Parameter
Description
user
User who submits a job.
status
JSON object containing job status information.
profile
JSON object containing job information. WebHCat parses information in the JobProfile object. The object varies according to the Hadoop version.
id
Job ID.
callback
Callback URL (if any).
- Example
curl -i -u : --insecure --negotiate -X DELETE "https://10.64.35.143:9111/templeton/v1/jobs/job_1440386556001_0265"
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.