For NQL syntax and language features, see the NQL Reference.
Prerequisites
- SDK installed and configured (see SDK Quickstart)
- Familiarity with NQL syntax
- An API key with query permissions
Running a query
Basic execution
UseexecuteNql() to run a query and retrieve results:
Query input options
TheexecuteNql() method accepts the following options:
| Option | Type | Required | Description |
|---|---|---|---|
nql | string | Yes | The NQL query to execute |
data_plane_id | string | null | Yes | Target data plane ID, or null for default |
execution_cluster | object | No | Cluster configuration (shared or dedicated) |
create_as_view | boolean | No | Create the query as a view |
Understanding the result
TheNqlResult object contains execution metadata:
Validating a query
UsevalidateNql() to check query syntax without execution:
Compiling a query
UsecompileNql() to see the transpiled SQL without executing:
- Debugging query issues
- Understanding how NQL maps to the underlying SQL dialect
- Verifying Rosetta Stone mappings
Parsing a query
UseparseNql() to get the abstract syntax tree (AST):
Retrieving a previous query
If you have a job ID from a previous query, retrieve its results:Query patterns
Filtering data
Aggregations
Using Rosetta Stone attributes
Query normalized data across datasets:Error handling
Wrap query execution in try-catch to handle errors:Best practices
| Practice | Description |
|---|---|
| Always use LIMIT | Prevent unbounded result sets |
| Validate before executing | Use compileNql() to catch errors early |
| Handle errors gracefully | Wrap calls in try-catch |
| Use appropriate timeouts | Long-running queries may need monitoring |
| Filter at the source | Apply WHERE clauses to reduce data scanned |

