Skip to content

[SPARK-58008][SQL] Support dynamic table options for DELETE#57161

Open
brijrajk wants to merge 1 commit into
apache:masterfrom
brijrajk:SPARK-58008-delete-with-options
Open

[SPARK-58008][SQL] Support dynamic table options for DELETE#57161
brijrajk wants to merge 1 commit into
apache:masterfrom
brijrajk:SPARK-58008-delete-with-options

Conversation

@brijrajk

@brijrajk brijrajk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Extends the per-statement WITH (key = value) options clause to DELETE statements, consistent with the support already present for SELECT (SPARK-36680), INSERT (SPARK-49098), and UPDATE (SPARK-57681).

Example syntax:

DELETE FROM catalog.db.table WITH (`write.split-size` = 10) WHERE id < 100

DELETE FROM catalog.db.table AS t WITH (`k` = 'v') WHERE t.id < 100

The options are forwarded through the DataSourceV2Relation, RowLevelOperationInfo, and LogicalWriteInfo so that DataSource V2 connectors receive them at every layer of the write path.

Why are the changes needed?

DELETE was the only DML statement missing this capability. Adding it completes the feature set across all row-level write operations and allows connectors to accept per-statement tuning options (e.g. split size, isolation level) on deletes without requiring separate configuration.

Does this PR introduce any user-facing change?

Yes — new SQL syntax. DELETE FROM tbl WITH (k = v) WHERE ... is now valid.

How was this patch tested?

  • DDLParserSuite: two new parser tests covering DELETE ... WITH (...) without and with an alias.
  • DeleteFromTableSuiteBase: two new end-to-end tests verifying that options reach the DataSourceV2Relation, RowLevelOperationInfo, and LogicalWriteInfo layers.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Sonnet 4.6

Extends the per-statement WITH (key=value) options clause to DELETE,
consistent with SELECT (SPARK-36680), INSERT (SPARK-49098), and
UPDATE (SPARK-57681).

Changes:
- Grammar: add optionsClause? to the deleteFromTable rule
- AstBuilder: pass Option(ctx.optionsClause()) to createUnresolvedRelation
- RewriteDeleteFromTable: use r.options instead of CaseInsensitiveStringMap.empty()
- DDLParserSuite: two parser tests for DELETE WITH options (with and without alias)
- DeleteFromTableSuiteBase: end-to-end tests verifying options reach the
  row-level operation; use salary < 200 (LessThan) rather than pk = 1
  (EqualTo) to prevent OptimizeMetadataOnlyDeleteFromTable from replacing
  the row-level plan with a filter-only deleteWhere call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brijrajk brijrajk force-pushed the SPARK-58008-delete-with-options branch from 947040a to 212020e Compare July 9, 2026 17:50
@dongjoon-hyun

Copy link
Copy Markdown
Member

cc @anuragmantri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants