Okera Platform Quick Technical Solutions

These “recipes” offer simple solutions and workarounds for common tasks and sticking points.

Administration

Performing a Rolling Restart

When Okera performs a rolling restart of its services, it stops a given instance and then launches a replacement instance based on the same docker image. By stopping the instances one by one, this performs a rolling restart of the service. This can be done for any of the ODAS services.

sudo docker stop [CONTAINER ID]

This will stop the instance and it is automatically restarted. To see its progress, you can run:

sudo docker ps

Note the values in the CREATED column. This is the duration for which the current instance of a given docker container has been running.

Passing Hyphenated Names via REST API

When passing GRANT ROLE to the Catalog REST API, hyphenated usernames will throw an error, due to a limitation in the REST service.

Example: Hyphenated group name with improper syntax

curl -X POST 'http://okera-catalog.example.com:7184/api/hive-ddl?user=usertoken' \
 -H 'content-type: application/json' \
 -d '{"query":"GRANT ROLE winner TO GROUP the-a-team"}'

This will return a syntax error.

The solution is to contain the group name in escaped backticks.

curl -X POST 'http://okera-catalog.example.com:7184/api/hive-ddl?user=usertoken' \
 -H 'content-type: application/json' \
 -d '{"query":"GRANT ROLE winner TO GROUP \`the-a-team\`"}'

Data Access

Working around Hive’s SHOW CREATE VIEW Limitation

Using SHOW CREATE VIEW in Hive fails with a NoViableAltException(303@[]) error due to a limitation in Hive, which does not support external storage handlers. Hive only permits SHOW CREATE TABLE, which shows the resulting (optionally joined) table. To see the definition, you have to use the odb utility.

Using the same commands here should return the expected result.

odb dataset hive-ddl "show create table testdb.sampleview"
Request complete.
Result: ['CREATE VIEW testdb.sampleview AS\nSELECT sample.record FROM okera_sample.sample']

Converting Non-UTF-8 Encoding During Query

If you have data encoded as other than UTF-8, it may not display as you prefer. If the data cannot be converted at its source or upon display, you may convert it at query time using | iconv -f <source_encoding> -t utf-8, where <source_encoding> is the source file’s encoding.

Example: Converting ISO-8859-1 encoding at query time

curl https://odas.example.com:5000/api/scan?user=usertoken&records=1 \
 -H 'Content-Type: application/json;' \
    --data '{"query": "SELECT * from your_table"}' | iconv -f iso8859-1 -t utf-8