AnishMahto commented on code in PR #59519:
URL: https://github.com/apache/spark/pull/59519#discussion_r4589914638


##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/autocdc/Scd1FieldToReconcile.scala:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.pipelines.autocdc
+
+import org.apache.spark.sql.catalyst.analysis.Resolver
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.util.ArrayImplicits._
+
+/**
+ * An SCD1 user-data field reconciled independently of all others: either a 
leaf of a column
+ * selected for ignore-null, or a whole top-level column outside the 
selection. It depends only on
+ * the user-data schema and the ignore-null selection.
+ *
+ * @param path The field's name parts within the user-data schema.
+ * @param leafPaths The name parts of every user-data leaf at or beneath 
`path`.
+ * @param isIgnoreNullLeaf Whether the field is a leaf of a column selected 
for ignore-null, which
+ *                         an upsert with a version map authors only when the 
map records the
+ *                         leaf as authored. If not, the field is a whole 
column outside the
+ *                         selection, which an upsert authors in full, nulls 
included, unless the
+ *                         microbatch omits all of its leaves. A column 
without leaves, such as an
+ *                         empty struct, cannot be recorded as omitted, so an 
upsert always
+ *                         authors it.
+ */
+private[autocdc] case class Scd1FieldToReconcile(
+    path: Seq[String],
+    leafPaths: Seq[Seq[String]],
+    isIgnoreNullLeaf: Boolean)
+
+private[autocdc] object Scd1FieldToReconcile {
+
+  /**
+   * Applies `ignoreNullSelection` to `schema` and returns a 
[[Scd1FieldToReconcile]] for each

Review Comment:
   Expanding more on why unselected columns in particular should not be 
reconciled at leaf level:
   - We'd be doing unnecessary work by expanding unselected structs into their 
leaves, adding unnecessarily to plan size
   - An unselected column must take exactly one winning event's value, whereas 
selected columns can have different rows author different leaves (again, goes 
back to ignore-null API's contract)
   - It changes how nulls at the struct-level are reconciled. If an unselected 
struct receives a null, we want the whole struct to be null. If a selected 
struct receives a null, it counts as a null for each of its leaves, and each of 
those is ignored, so the target keeps its leaf values.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to