Skip to content

Commit fa9b09a

Browse files
committed
docs(dsql): document CREATE INDEX ASYNC and sys.jobs dialect (DOC-319)
Document LocalStack support for DSQL-specific async index DDL and the sys.jobs view from localstack-pro#7590, and clarify remaining dialect limits.
1 parent c20165c commit fa9b09a

1 file changed

Lines changed: 61 additions & 2 deletions

File tree

src/content/docs/aws/services/dsql.mdx

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Aurora DSQL is a serverless, distributed, PostgreSQL-compatible database service
1313
It offers active-active high availability and is designed for transactional workloads that require scalability without the operational overhead of managing database infrastructure.
1414

1515
LocalStack allows you to use the Aurora DSQL APIs to create and manage clusters, tags, resource policies, and streams in your local environment.
16-
The data plane is backed by an embedded PostgreSQL instance, so you can connect to a cluster and run SQL against it.
16+
The data plane is backed by an embedded PostgreSQL instance, so you can connect to a cluster and run SQL against it, including DSQL-specific dialect such as `CREATE INDEX ASYNC` and the `sys.jobs` system view.
1717
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Aurora DSQL's integration with LocalStack.
1818

1919
## Getting started
@@ -266,11 +266,70 @@ awslocal dsql get-vpc-endpoint-service-name --identifier 8a71d298-c086-4fb4-a698
266266
}
267267
```
268268

269+
## SQL dialect
270+
271+
Aurora DSQL is PostgreSQL wire-compatible but adds dialect-specific DDL that vanilla Postgres rejects.
272+
LocalStack accepts the DSQL-specific statements that applications commonly rely on so DSQL-targeted apps can run against the emulator.
273+
274+
### Asynchronous indexes
275+
276+
On real Aurora DSQL, [`CREATE INDEX ASYNC`](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-create-index-async.html) (and `CREATE UNIQUE INDEX ASYNC`) submits a background index build, returns a `job_id` immediately, and records the job in the [`sys.jobs`](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-systems-tables.html) system view for the application to poll.
277+
278+
LocalStack accepts the same syntax.
279+
The index is built synchronously under the hood; the observable result matches AWS: a `job_id` is returned, the index exists afterwards, and `sys.jobs` reports the job as `completed` with `job_type` `INDEX_BUILD`.
280+
281+
Connect to the cluster as shown in [Connect to the cluster](#connect-to-the-cluster), then run:
282+
283+
```sql
284+
CREATE TABLE departments (name varchar(255) PRIMARY KEY, manager varchar(255));
285+
INSERT INTO departments (name, manager) VALUES ('HR', 'John Doe');
286+
287+
CREATE INDEX ASYNC idx_dept_name_manager ON departments (name, manager);
288+
```
289+
290+
```bash title="Output"
291+
job_id
292+
------------------------------------
293+
a1b2c3d4e5f6g7h8i9j0k1l2m3
294+
(1 row)
295+
```
296+
297+
Query `sys.jobs` to inspect the job, or call `sys.wait_for_job` to wait until it reports completion:
298+
299+
```sql
300+
SELECT job_id, status, job_type, object_name FROM sys.jobs;
301+
SELECT sys.wait_for_job('a1b2c3d4e5f6g7h8i9j0k1l2m3');
302+
```
303+
304+
```bash title="Output"
305+
job_id | status | job_type | object_name
306+
----------------------------------+-----------+-------------+---------------------
307+
a1b2c3d4e5f6g7h8i9j0k1l2m3 | completed | INDEX_BUILD | idx_dept_name_manager
308+
(1 row)
309+
310+
wait_for_job
311+
--------------
312+
t
313+
(1 row)
314+
```
315+
316+
`CREATE UNIQUE INDEX ASYNC` works the same way and enforces uniqueness once the index exists:
317+
318+
```sql
319+
CREATE UNIQUE INDEX ASYNC uidx_dept_manager ON departments (manager);
320+
```
321+
322+
:::note
323+
Index builds run synchronously under the hood.
324+
Async timing (background processing, `submitted`/`processing` statuses) and the AWS 30-minute auto-cleanup of completed or failed jobs from `sys.jobs` are not modelled.
325+
:::
326+
269327
## Current Limitations
270328

271329
- CloudFormation is not yet supported for Aurora DSQL resources.
272330
- The data plane is backed by a standard embedded PostgreSQL instance rather than the real Aurora DSQL distributed engine.
273-
DSQL-specific SQL dialect restrictions are not enforced, so behaviour may differ from AWS for unsupported statements.
331+
- LocalStack accepts DSQL-specific `CREATE [UNIQUE] INDEX ASYNC` and exposes `sys.jobs` / `sys.wait_for_job`, but broader DSQL dialect restrictions (for example rejecting foreign keys or `TRUNCATE`) are not enforced, so behaviour may differ from AWS for unsupported statements.
332+
- Asynchronous index builds complete synchronously; timing semantics and automatic cleanup of old `sys.jobs` rows are not modelled.
274333
- Multi-region clusters are tracked at the control-plane level only.
275334
Peering metadata is recorded, but there is no real cross-region replication.
276335
- Data-plane data is not persisted yet. Cluster metadata survives restarts when persistence is enabled, but the data written through the embedded PostgreSQL backend (tables, rows) is not retained.

0 commit comments

Comments
 (0)