You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "aokolnychyi (via GitHub)" <gi...@apache.org> on 2026/06/16 20:08:07 UTC
Re: [PR] [SPARK-56599][SQL] Add scan narrowing for column-level UPDATEs in DSv2 [spark]
aokolnychyi commented on code in PR #55518:
URL: https://github.com/apache/spark/pull/55518#discussion_r3423698058
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/write/RowLevelOperation.java:
##########
@@ -105,4 +105,48 @@ default String description() {
default NamedReference[] requiredMetadataAttributes() {
return new NamedReference[0];
}
+
+ /**
+ * Controls whether to send only the required data columns to the connector rather than the
+ * full row.
+ * <p>
+ * When true, Spark narrows the data column schema ({@link LogicalWriteInfo#schema()}) to only
+ * the columns declared via {@link #requiredDataAttributes()}. Metadata columns (from
+ * {@link #requiredMetadataAttributes()}) and row ID columns (from
+ * {@link SupportsDelta#rowId()}) are unaffected and always projected separately.
+ * <p>
+ * If {@link #requiredDataAttributes()} returns a non-empty array, the write schema is exactly
+ * those columns in declared order. The connector must include all columns it wants to receive,
+ * including the columns being updated. If {@link #requiredDataAttributes()} returns an empty
+ * array, Spark sends only the non-identity assigned columns (heuristic path).
+ * <p>
+ * Currently only consulted for UPDATE operations.
+ *
+ * @since 4.3.0
+ */
+ default boolean supportsColumnUpdates() {
+ return false;
+ }
+
+ /**
+ * Returns data column references required to perform this row-level operation.
+ * <p>
+ * This method is only consulted by Spark when {@link #supportsColumnUpdates()} returns
+ * {@code true}. If {@code supportsColumnUpdates()} returns {@code false}, the returned array
+ * is ignored and the full table row is sent (the default behavior).
+ * <p>
+ * When non-empty, the returned columns become the write schema in declared order.
+ * The connector must declare all columns it wants to receive, including the columns being
+ * updated. Use {@link RowLevelOperationInfo#updatedColumns()} to learn which columns are being
+ * assigned, then add any extra columns needed for row lookup or routing (e.g., primary key).
+ * <p>
+ * When empty (the default), Spark falls back to sending only the non-identity assigned columns.
+ * <p>
+ * Currently only consulted for UPDATE operations.
+ *
+ * @since 4.3.0
+ */
+ default NamedReference[] requiredDataAttributes() {
+ return new NamedReference[0];
Review Comment:
As I commented in the SPIP doc, this is not a good default.
--
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