The simplest way to make Druid SQL queries from the command line is using the dsql tool included with the Imply distribution:
Welcome to dsql, the command-line client for Druid SQL.
Connected to [http://localhost:8082/].
Type "\h" for help.
dsql> SELECT COUNT(*) from wikipedia;
│ EXPR$0 │
│ 24433 │
Retrieved 1 row in 0.05s.
By default, the dsql tool connects to a broker on localhost without security enabled. If you need to connect to another broker, use a command like:
bin/dsql -H http://your-broker:8082/
If you need to connect to a broker with security enabled, try the following (Imply 2.8 or later required):
bin/dsql -H https://your-broker:8282/ -u admin:yourpassword
You can also make Druid SQL queries using Pivot through the "SQL" tab.
Native Druid queries
To issue native Druid JSON queries from the command line, run:
curl -XPOST -firstname.lastname@example.org -H'Content-Type: application/json' http://your-broker:8082/druid/v2/
Where query.json is a file containing the query JSON you wish to issue. Refer to the Druid querying documentation for details about the kinds of queries you can issue.