Hive 2 is generally available alongside Hive 0.13. Treasure Data recommends that you switch to the conventions of your queries to be compatible with Hive 2 and use Hive 0.13 to test the queries.

You can write Hive queries three different ways in Treasure Data:

Using the TD Console

A new drop-down item exists to run queries with Hive 2.

Using TD Toolbelt from the Command Line

TD Toolbelt supports the --engine-versionoption. The “stable” option is available so that you can test your queries to determine if they are compatible with Hive 2.

The TD query command enables you to run queries with Hive 2 using the following syntax:

$ td query -T hive --engine-version stable --database xxx "select query" ;

 Example - Current

td query -d db -T hive "select time from tablename where td_time_range(time, '-1h','America/Los_Angeles')"

Example - Hive2

td query -d db -T hive --engine-version stable "select time from tablename where td_time_range(time, '-1h','America/Los_Angeles')"

Using the REST API

The REST API also supports the engine_version parameter in a request to run Hive 2.

Example - Current

curl -X POST https://api.treasuredata.com/v3/job/issue/hive/db

  • H 'authorization: TD1 YOUR_APIKEY'

  • H 'content-type: application/json'

  • d '{"query": "select * from test_td_table order by time", "priority": 0}'

Example - Hive2

curl -X POST https://api.treasuredata.com/v3/job/issue/hive/db

  • H 'authorization: TD1 YOUR_APIKEY'

  • H 'content-type: application/json'

  • d '{"query": "select * from test_td_table order by time", "priority": 0, "engine_version":"stable"}'



  • No labels