[SPARK-57402][SQL][SDP] Register AUTO CDC SQL syntax with the dataflow graph#57176
[SPARK-57402][SQL][SDP] Register AUTO CDC SQL syntax with the dataflow graph#57176anew wants to merge 1 commit into
Conversation
### What changes were proposed in this pull request? Hook up the two AUTO CDC SQL constructs introduced in SPARK-56249 to the Spark Declarative Pipelines dataflow graph in `SqlGraphRegistrationContext`: 1. `CREATE STREAMING TABLE <name> FLOW AUTO CDC FROM <source> ...`, parsed into `CreateStreamingTableAutoCdc`, now registers the streaming table and an `AutoCdcFlow` that targets it. 2. `CREATE FLOW <name> AS AUTO CDC INTO <target> FROM <source> ...`, parsed into a `CreateFlowCommand` wrapping an `AutoCdcIntoCommand`, now registers an `AutoCdcFlow` from the named flow into the target dataset. A shared `buildChangeArgs` helper converts the parse-time expressions and unresolved attributes into the `ChangeArgs` consumed by `AutoCdcFlow` (keys, sequencing, delete condition, include/exclude column selection). SQL AUTO CDC only supports SCD Type 1, matching the Connect/proto path. ### Why are the changes needed? Before this change the AUTO CDC SQL syntax parsed successfully but was rejected during graph registration, so it could not be used to define pipeline datasets or flows. ### Does this PR introduce _any_ user-facing change? Yes. AUTO CDC SQL statements now register datasets and flows in a pipeline. ### How was this patch tested? Added registration and end-to-end execution tests to `SqlPipelineSuite` covering both syntaxes, the optional clauses (APPLY AS DELETE WHEN, COLUMNS, COLUMNS * EXCEPT), and the multipart-flow-name error. Full `SqlPipelineSuite` passes (50 tests). ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Opus 4.8 Co-authored-by: Isaac
| identifier = stIdentifier, | ||
| comment = cst.tableSpec.comment, | ||
| specifiedSchema = | ||
| Option.when(cst.columns.nonEmpty)(StructType(cst.columns.map(_.toV1Column))), |
There was a problem hiding this comment.
If users write CREATE STREAMING TABLE target (id INT, name STRING) FLOW AUTO CDC ..., this stores the listed columns as the table’s full specified schema. But Auto CDC later appends _cdc_metadata to the flow schema, so validation can reject an otherwise natural data-column-only declaration. Could we either reject column lists for this SQL form, or interpret them as the data schema and add the metadata field internally before validation?
| case createStreamingTableCommand: CreateStreamingTable => | ||
| // CREATE STREAMING TABLE [ streaming_table_name ] [ options ] | ||
| CreateStreamingTableHandler.handle(createStreamingTableCommand, queryOrigin) | ||
| case createStreamingTableAutoCdcCommand: CreateStreamingTableAutoCdc => |
There was a problem hiding this comment.
This registers CreateStreamingTableAutoCdc in the pipeline graph path, but the normal Spark execution guard in SparkStrategies.Pipelines only rejects CreateFlowCommand and CreateStreamingTableAsSelect today. If someone runs this statement through regular spark.sql outside pipeline registration, it may miss the curated unsupported STREAMING TABLE error. Can we add a matching CreateStreamingTableAutoCdc case there?
What changes were proposed in this pull request? Hook up the two AUTO CDC SQL constructs introduced in SPARK-56249 to the Spark Declarative Pipelines dataflow graph in
SqlGraphRegistrationContext:CREATE STREAMING TABLE <name> FLOW AUTO CDC FROM <source> ..., parsed intoCreateStreamingTableAutoCdc, now registers the streaming table and anAutoCdcFlowthat targets it.CREATE FLOW <name> AS AUTO CDC INTO <target> FROM <source> ..., parsed into aCreateFlowCommandwrapping anAutoCdcIntoCommand, now registers anAutoCdcFlowfrom the named flow into the target dataset.A shared
buildChangeArgshelper converts the parse-time expressions and unresolved attributes into theChangeArgsconsumed byAutoCdcFlow(keys, sequencing, delete condition, include/exclude column selection). SQL AUTO CDC only supports SCD Type 1, matching the Connect/proto path.Why are the changes needed?
Before this change the AUTO CDC SQL syntax parsed successfully but was rejected during graph registration, so it could not be used to define pipeline datasets or flows.
Does this PR introduce any user-facing change?
Yes. AUTO CDC SQL statements now register datasets and flows in a pipeline.
How was this patch tested?
Added registration and end-to-end execution tests to
SqlPipelineSuitecovering both syntaxes, the optional clauses (APPLY AS DELETE WHEN, COLUMNS, COLUMNS * EXCEPT), and the multipart-flow-name error. FullSqlPipelineSuitepasses (50 tests).Was this patch authored or co-authored using generative AI tooling?
Generated-by: Opus 4.8