You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2026/08/05 01:57:29 UTC
Re: [PR] [SPARK-58118][SDP] Allow user-specified AUTO CDC schema to omit the reserved metadata column [spark]
HyukjinKwon commented on code in PR #57644:
URL: https://github.com/apache/spark/pull/57644#discussion_r3717403120
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/DatasetManager.scala:
##########
@@ -284,9 +284,18 @@ object DatasetManager extends Logging {
val (catalog, identifier) =
PipelinesCatalogUtils.resolveTableCatalog(context.spark, table.identifier)
- val outputSchema = table.specifiedSchema.getOrElse(
- resolvedDataflowGraph.inferredSchema(table.identifier).asNullable
- )
+ val outputSchema = table.specifiedSchema match {
+ case Some(ss) =>
+ // The user schema describes the logical table; the engine owns the reserved AUTO CDC
+ // metadata column(s). Append any that the incoming flows produce but the user omitted,
+ // so the created table matches what the AUTO CDC MERGE writes at runtime.
+ val omittedReservedFields = AutoCdcMergeFlow
+ .reservedFields(resolvedDataflowGraph.inferredSchema(table.identifier))
+ .filterNot(f => ss.fieldNames.contains(f.name))
Review Comment:
Optional micro-nit: `ss.fieldNames` is recomputed (fresh Array) with a linear `contains` per reserved field. `val specifiedNames = ss.fieldNames.toSet` before the `filterNot` makes membership O(1). Materialization-time only, so take-it-or-leave-it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org