# Infor Data Lake Compass API: Submit a Query, Poll and Fetch Results

> Source: https://netray.co/erp-help/infor-data-lake-compass-api-async-query-how-to
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: ERP Help

## Short answer

The Compass API in Infor Data Fabric runs SQL against Data Lake objects asynchronously. You POST the SQL to start a job, poll the job until it reports finished, and then request the results in pages. Authentication is the same ION API token you use for other Infor OS services.

## Kind

advanced

## System

infor-os

## Erp

Infor Data Lake (Data Fabric)

## Module

Compass API / Data Fabric

## Query

Infor Data Lake Compass API run query and fetch results

## Alternate Queries

- Infor Compass REST API submit query job
- Data Fabric compass jobs queryId status result
- run Compass SQL from Python Infor Data Lake
- Infor Compass API pagination results offset

## Applies To

Infor OS Data Fabric with Data Lake and Compass; endpoint paths and limits can differ by release, so confirm against the ION API documentation for your tenant

## Steps

### Run a Compass query from a script

**Items:**

- Create a backend service Authorized App and a service account with access to Data Lake, then download the .ionapi file.
- Request an OAuth token from the token endpoint in the file using the password grant.
- POST the SQL text as the body to the Compass jobs resource under the Data Fabric path of your tenant. The response returns a query id and a status.
- Poll the job by its query id every few seconds. Stop on a finished status, and treat failed or cancelled statuses as errors that carry a message.
- When finished, GET the result resource for that query id with an offset and a limit, and repeat until you have all rows or the reported row count.
- Delete or let expire the job according to your retention practice, and log the query id with your run so a failure can be traced.
- Wrap token refresh, retries and a timeout around the loop so a long query does not leave a script polling forever.

## Sections

### Why the API is asynchronous

**Body:**

Compass is built on a distributed query engine over files stored in the Data Lake, so a query can take from a second to many minutes depending on the volume scanned. The API therefore returns immediately with a job reference instead of holding an HTTP connection open. This is also why a naive script that expects rows in the first response sees an empty body or a status field and nothing else.

Because the job is separate from the result, you can submit several queries, poll them in parallel and fetch results as each finishes. Keep concurrency modest. Compass shares capacity with other users of the tenant, and bursts of heavy queries show up as queued jobs rather than errors.

**Code:**

import time, requests

BASE = 'https://mingle-ionapi.inforcloudsuite.com/ACME_PRD/DATAFABRIC/compass/v2'
H = {'Authorization': 'Bearer ' + token, 'Content-Type': 'text/plain'}

r = requests.post(BASE + '/jobs/', data=sql, headers=H)
r.raise_for_status()
qid = r.json()['queryId']

while True:
    s = requests.get(BASE + '/jobs/' + qid + '/', headers=H).json()
    if s['status'] == 'FINISHED':
        break
    if s['status'] in ('FAILED', 'CANCELED'):
        raise RuntimeError(s)
    time.sleep(3)

### Paging results and typing

**Body:**

Result pages are requested with offset and limit parameters, and the job status reports the total row count when it finishes. Page until the count is reached. Do not stop on an empty page without checking the count, because a transient failure can look the same.

Values arrive as text in JSON. Cast dates and numerics in your own code or in the SQL itself, and keep an eye on null handling when you load into pandas or a warehouse. Data Lake objects loaded from ERP through Data Flows may carry audit columns and variations such as a deleted flag, so filter those explicitly if you want current records only.

### Common failures

**Body:**

A 401 means the token expired or the account lacks Data Lake roles, a failed job usually carries a SQL error such as an unknown object or column, and a job that stays queued suggests capacity pressure or a very large scan. Select only the columns you need and filter on a partition-friendly or indexed column to cut scan time.

If a script works at night but fails in the morning, check whether other scheduled loads were running. For recurring exports, consider whether the Data Lake is the right source at all: a one-off scheduled query to a file may be simpler than a custom polling script.

## Pitfalls

- Expecting rows in the POST response. The first response is a job reference, not data.
- Polling with no timeout or backoff, which leaves jobs and scripts running when a query hangs.
- Selecting every column with no filter on large objects, which turns a quick check into a full scan.
- Ignoring the reported row count and treating one empty page as the end of the data.
- Assuming ERP deletes are reflected as removed rows. Check how the object marks deleted records.

## Ai Angle

An assistant that answers analytical questions from the Data Lake does the same three steps: build a SQL statement, submit the job, and read the pages. Grounded behaviour means it shows the SQL, runs under a read-only service account and states which Data Lake objects it used. ERPray is ERP-agnostic in its connectors and can be pointed at live ERP data directly when the Data Lake copy is too stale for the question.

## Faq

### Is the Compass API synchronous?

**Answer:** No. You submit SQL and receive a job reference, then poll for completion and fetch the results in pages. Treat it like any asynchronous job API, with a timeout, retries on transient errors and logging of the query id.

### How do I authenticate to Compass from Python?

**Answer:** Use the .ionapi file from a backend service app to request a token with the password grant, then send it as a Bearer token on every Compass call. Refresh before expiry on long running scripts.

### Can I use JDBC instead of the REST API?

**Answer:** Yes, Infor provides a Compass JDBC driver for BI and SQL tools, which is usually easier for interactive work. The REST API suits scripts and services that need to submit jobs and control paging themselves.

### Why does my query stay in a queued state?

**Answer:** The tenant queues work when capacity is busy. Reduce scan size, run outside peak load windows and avoid submitting many large jobs at once. If it stays queued for long periods, raise it with Infor support.

## Search terms

Infor Compass API, Infor Data Lake query API, Data Fabric compass jobs, Compass SQL Python, Infor Data Lake REST, Compass query id status, Infor Data Lake export, Compass JDBC driver, Infor Data Fabric API, Infor Data Lake paging results

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
