feat(dsql): parse ALTER TABLE ASYNC - #2
Merged
amaksimo merged 1 commit intoAug 3, 2026
Conversation
Aurora DSQL runs certain ALTER TABLE operations as asynchronous DDL jobs via the ALTER TABLE ASYNC form, e.g. ALTER TABLE ASYNC t VALIDATE CONSTRAINT c which returns a job_id and validates existing rows in the background (same async DDL model as CREATE INDEX ASYNC). Add an `async` flag to the AlterTable AST node, parse an optional ASYNC keyword immediately after TABLE (before IF EXISTS / ONLY), and render it in Display. Non-async ALTER TABLE is unchanged. - ast/ddl.rs: AlterTable.async field + Display - parser/mod.rs: parse_alter_table parses optional ASYNC - dialect/snowflake.rs: set async: false at the two AlterTable sites - tests/sqlparser_postgres.rs: async VALIDATE CONSTRAINT round-trip, incl. ASYNC + IF EXISTS + ONLY Exact round-trip verified; full postgres (180) and common (471) suites pass.
amaksimo
approved these changes
Aug 3, 2026
amaksimo
added a commit
that referenced
this pull request
Aug 3, 2026
The merged ALTER TABLE ASYNC PR (#2) added AlterTable.r#async but missed this fully-destructured pattern (no ..), leaving `cargo test` broken. Published crate excludes tests so 0.62.2 uploads fine; this keeps the branch green.
amaksimo
added a commit
to awslabs/aurora-dsql-tools
that referenced
this pull request
Aug 3, 2026
> [!NOTE] > **Dependency published — unblocked.** `sqlparser-dsql 0.62.2` (adds `ALTER TABLE ASYNC` parsing) is live on crates.io. Parser PR: amaksimo/datafusion-sqlparser-rs#2. Full suite builds and passes against it (115 unit tests + fix/integration/snapshot suites, 0 failures). ## Summary Follow-up to #112. That PR made `VALIDATE CONSTRAINT` emit a guidance-only `Unfixable` diagnostic because the parser couldn't represent the `ALTER TABLE ASYNC` form. With parser support in place, this upgrades the `ValidateConstraintAsync` rule to a real **auto-fix**, matching how `CREATE INDEX ASYNC` is handled. ## Behavior - `ALTER TABLE t VALIDATE CONSTRAINT c` (no ASYNC) → `FixedWithWarning`; the fix rewrites to `ALTER TABLE ASYNC t VALIDATE CONSTRAINT c`. - `ALTER TABLE ASYNC t VALIDATE CONSTRAINT c` now lints **clean**. The `async` flag lives on the `AlterTable` statement (not the operation), so the fix is captured during the per-op scan and applied to the statement after the loop. The warning tells users validation runs as a background DDL job (wait via `sys.jobs`; can still fail on dirty data). ## Changes - `src/rules/errors.rs`: auto-fix logic for `ValidateConstraintAsync`. - `tests/`: `FIX_TIER` + `SNAPSHOT` cases (`validate-constraint-async`) and a clean-pass test for the ASYNC form. - `Cargo.toml`: bump `dsql-lint` `0.2.12` → `0.2.13`; require `sqlparser-dsql` `0.62.2` (kept the `visitor` feature added on main). Merged `main` and resolved the `Cargo.toml` conflict (0.2.12 shipped on main in the meantime, hence 0.2.13). ## Testing Verified locally against the parser branch via a temporary `[patch.crates-io]` (**not committed**): full suite green — 115 unit tests + fix/integration/snapshot suites, 0 failures. CI here will fail to build until `sqlparser-dsql 0.62.2` is on crates.io. ## Rollout dependency chain 1. Parser: amaksimo/datafusion-sqlparser-rs#2 → publish `sqlparser-dsql 0.62.2` 2. **This PR** (bump pin + auto-fix) Part of the DSQL `VALIDATE CONSTRAINT ASYNC` ecosystem rollout (agent-plugins #238, mcp #4300, aurora-dsql-orms #528, aurora-dsql-tools #112). --- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the [project license](https://github.com/awslabs/aurora-dsql-tools/blob/main/LICENSE). Co-authored-by: Aleksandar Maksimovic <amaksimovic3@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aurora DSQL runs certain
ALTER TABLEoperations as asynchronous DDL jobs via theALTER TABLE ASYNCform — most notably:which returns a
job_idand validates existing rows in the background (the same async DDL model asCREATE INDEX ASYNC, already supported on this branch). The parser currently rejectsALTER TABLE ASYNC ...becauseASYNCis not recognized afterTABLE.This adds an
asyncflag to theAlterTableAST node and parses the optionalASYNCkeyword, following the existingCREATE INDEX ASYNCprecedent.Changes
ast/ddl.rs: addAlterTable.async: bool+ renderASYNCinDisplay(afterALTER TABLE, beforeIF EXISTS/ONLY).parser/mod.rs:parse_alter_tableparses an optionalASYNCkeyword. Non-asyncALTER TABLEis unchanged.dialect/snowflake.rs: setasync: falseat the twoAlterTableconstruction sites.tests/sqlparser_postgres.rs: round-trip tests forALTER TABLE ASYNC ... VALIDATE CONSTRAINT, includingASYNC+IF EXISTS+ONLY.Cargo.toml: bumpsqlparser-dsql0.62.1→0.62.2and noteALTER TABLE ASYNCin the description.Testing
ALTER TABLE ASYNC t VALIDATE CONSTRAINT candALTER TABLE ASYNC IF EXISTS ONLY public.t VALIDATE CONSTRAINT c.sqlparser_postgres(180) andsqlparser_common(471).Why
Unblocks
dsql-lint(awslabs/aurora-dsql-tools) from upgrading itsVALIDATE CONSTRAINTrule from "guide to ASYNC" to full auto-fix + clean-pass of the validALTER TABLE ASYNCform, matching howCREATE INDEX ASYNCis handled. Part of the DSQLVALIDATE CONSTRAINT ASYNCecosystem rollout (agent-plugins, mcp, aurora-dsql-orms, aurora-dsql-tools).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.