CLI

Prev Next

Available in VPC

It describes how to use the CLI provided by Data Query.

Note

NAVER Cloud Platform's Data Query CLI currently does not support authentication methods other than User&Password.

  • Authenticate a user by entering User AccessKey for the user and User SecretKey for the password.

Preparations

Java 8 or later must be installed in the environment where you will be using CLI.

How to use

It describes how to use Data Query CLI.

1. Download

Download the CLI executable file for Data Query from the following link:

dataquery-cli-101-437.zip

Note

Data Query CLI is based on trinodb/trino, an open source. For more information on relevant licenses, see the NOTICE file.

2. Run CLI

Run the downloaded file using the following instructions.

2.1. Basic usage instructions

dataquery-cli --user $ACCESS_KEY --password --server $DATAQUERY_ENDPOINT
Caution

The secretKey information is not entered after the --password option when the commands are run. After running the commands, enter the information when the Password: prompt appears.

Caution

If you're using the CLI in a Windows environment, keep the following in mind.

  • You can run the provided CLI binary file through the JAVA commands or by creating the following command file.
  • Because the pager settings to page query results on the CLI are not built-in on Windows, you must run the pager option as an empty string to avoid causing an error (warning) message in the terminal.
  • For example,
    • dataquery-cli.bat file
      @echo off
      java -jar dataquery-cli --pager="" %*
      
    • Run
      dataquery-cli.bat --user {ACCESS_KEY} --password --server {DATAQUERY_ENDPOINT}
      

2.2. Available options

Use the dataquery-cli --옵션명 type.

Option name Data type Input values Required Note
user String User accessKey Y
password String User secretKey Y
server String Data Query Endpoint Y For more information, see Data Query Service Endpoint by Region
reuse-query-result Boolean true or false N * default : false
reuse-query-max-age Integer 1 ~ 10,080 N * default : 60
* Used only if the value of reuse-query-result is true. (Unit: time)

Data Query Service Endpoint by Region
Currently, only the KR Region is available, with more Regions to be provided later.

Region Endpoint
KR https://kr.dataquery.naverncp.com
Note

dataquery-cli is provided based on trino-cli. For more information beyond the options above, see Trino documentation.

2.3. Method of use, including options for reusing query results

Example: run the CLI to reuse the same request query within the last 1 hour as the query result to submit.

dataquery-cli --user $ACCESS_KEY \
--password \
--server $DATAQUERY_ENDPOINT \
--reuse-query-result \
--reuse-query-max-age 60

3. Submit queries and view results

At the executed CLI query prompt, submit the query and view the results.

dataquery> SELECT movieId, COUNT(*) AS ratingCount
        -> FROM public_data.the_movies_dataset.ratings_small
        -> GROUP BY movieId
        -> ORDER BY ratingCount DESC
        -> LIMIT 10;
//Result examples
 movieId | ratingCount
---------+-------------
     356 |         341
     296 |         324
     318 |         311
     593 |         304
     260 |         291
     480 |         274
    2571 |         259
       1 |         247
     527 |         244
     589 |         237
(10 rows)

Query 20240304_152527_00139_zuari, FINISHED, 3 nodes
Splits: 30 total, 30 done (100.00%)
0.49 [100K rows, 2.33 MB] [204K rows/s, 4.75 MB/s]
Note

Pagination works if the CLI query result information exceeds the user's terminal window size. You can use the following input keys to view the query result:

Input key Description
CTRL + f Move to the next page.
CTRL + b Move to the previous page.
g Move to the first page.
G Move to the last page.
Up/down arrow Move up/down by 1 row.
Left/right arrow Move left/right by column.
q Stop viewing results and move to the query prompt.

4. Exit CLI

Enter quit at the query prompt.

dataquery> quit