›Developer guide

Get started

  • Introduction to Imply Polaris
  • Quickstart
  • Navigate the console
  • Key concepts

Data

  • Overview
  • Create a schema
  • Data partitioning
  • Introduction to rollup
  • Replace data
  • Supported data formats

Analytics

  • Overview
  • Manage data cubes
  • Visualize data
  • Dimensions
  • Measures
  • Dashboards
  • Visualizations reference
  • Query data

Monitoring

  • Overview

Management

  • Overview

Billing

  • Overview
  • Polaris plans
  • Estimate project costs
  • Manage billing and payments

Security

  • Overview
  • Add users to an organization
  • User roles reference
  • Manage user groups
  • Enable SSO
  • SSO settings reference

Developer guide

  • Overview
  • Authenticate API requests
  • Create a table
  • Get table ID
  • Define a schema
  • Upload files
  • Ingest to table
  • Push event data
  • Query data
  • Link to BI tools
  • Connect over JDBC

API reference

  • Overview
  • Reference index
  • Events API
  • Files API
  • Ingestion Jobs API
  • Ingestion Templates API
  • Performance API
  • Query API
  • Tables API
  • Common object definitions

    • Table
    • TableRequest
    • RollupSchema
    • IngestionJobSpec
    • CsvFormatSettings
    • JsonFormatSettings
    • TimestampMapping

Product info

  • Release notes
  • Known limitations

Query data by API

After you have created one or more tables and ingested data, you can use the Query API to run queries against your data. For information on how to write SQL queries in Imply Polaris, see Querying data.

This topic shows how to query a table in Polaris using Druid SQL.

Prerequisites

This topic assumes you have an OAuth token with the ReadDataSources role. In the examples below, the token value is stored in the variable named IMPLY_TOKEN. See Authenticate API requests if you need to configure an OAuth-based client and obtain an access token. Visit User roles reference for more information on roles and their permissions.

Get project ID

All queries to Polaris sent via API must specify the project ID. To obtain the project ID, make a GET request to the projects endpoint.

Sample request

The following example shows how to obtain project information from your Polaris environment:

cURL
Python
curl --location --request GET 'https://api.imply.io/v1/projects' \
--header "Authorization: Bearer $IMPLY_TOKEN"
import requests

url = "https://api.imply.io/v1/projects"

headers = {
'Authorization': 'Bearer {token}'.format(token=IMPLY_TOKEN)
}

response = requests.get(url, headers=headers)

print(response.text)

Sample response

The following example shows a successful response for project information. The project ID is displayed in the uid field of the JSON response.

[
   {
      "metadata":{
         "uid":"677b1203-fe4c-4d63-b01c-90254e104jcs",
         "name":"default"
      },
      "spec":{
         "plan":"a.02",
         "desiredState":"RUNNING"
      },
      "status":{
         "maxBytes":200000000000,
         "currentBytes":240081263,
         "state":"RUNNING"
      }
   }
]

Query using Druid SQL

To submit a Druid SQL query via the API, send a POST request along with a JSON body containing your query. Replace {project_id} with your project ID. Change the SQL statement in the query field to modify the query.

Sample request

The following example shows how to submit a query using the API:

cURL
Python
curl --location --request POST 'https://api.imply.io/v1/projects/{project_id}/query/sql' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $IMPLY_TOKEN" \
--data-raw '{
"query": "SELECT continent, COUNT(*) AS counts FROM \"Koalas to the Max\" GROUP BY 1 ORDER BY counts DESC"
}'
import requests
import json

url = "https://api.imply.io/v1/projects/{project_id}/query/sql"

payload = json.dumps({
"query": "SELECT continent, COUNT(*) AS counts FROM \"Koalas to the Max\" GROUP BY 1 ORDER BY counts DESC"
})
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer {token}'.format(token=IMPLY_TOKEN)
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Sample response

The following example shows a successful response containing the query result:

[
    {
        "continent": "North America",
        "counts": 241671
    },
    {
        "continent": "Europe",
        "counts": 169433
    },
    {
        "continent": "Oceania",
        "counts": 35905
    },
    {
        "continent": "Asia",
        "counts": 29902
    },
    {
        "continent": "South America",
        "counts": 25336
    },
    {
        "continent": "Africa",
        "counts": 2263
    },
    {
        "continent": "",
        "counts": 922
    }
]

Learn more

See the following topics for more information:

  • Query API for details on the Polaris Query API.
  • Druid SQL documentation for reference on Druid SQL queries.
  • Query using JDBC for querying data in Polaris using JDBC.
← Push event dataLink to BI tools →
  • Prerequisites
  • Get project ID
    • Sample request
    • Sample response
  • Query using Druid SQL
    • Sample request
    • Sample response
  • Learn more
Key links
Try ImplyApache Druid siteImply GitHub
Get help
Stack OverflowSupportContact us
Learn more
BlogApache Druid docs
Copyright © 2022 Imply Data, Inc