peter-toth commented on code in PR #60731:
URL: https://github.com/apache/spark/pull/60731#discussion_r4644564838
##########
sql/core/src/main/scala/org/apache/spark/sql/classic/DataFrameWriterV2.scala:
##########
@@ -55,7 +55,9 @@ final class DataFrameWriterV2[T] private[sql](table: String,
ds: Dataset[T])
private val tableName =
sparkSession.sessionState.sqlParser.parseMultipartIdentifier(table)
- private val logicalPlan = df.queryExecution.logical
+ // Use the analyzed plan like `DataFrameWriter`. Re-analyzing an unanalyzed
plan resolves the
+ // write output before `UpdateAttributeNullability` updates the stale
nullability of the query.
+ private val logicalPlan = df.logicalPlan
Review Comment:
**Finding 1.** With the analyzed plan, `writeTo` writes the DataFrame as it
was analyzed when it was created, like any other action on it. The dropped and
re-added column in the description is one case of that. A temporary view that
is replaced in between is another:
```scala
spark.range(3).createOrReplaceTempView("v")
val df = spark.table("v")
spark.range(10, 12).createOrReplaceTempView("v")
df.writeTo("testcat.t").append()
```
`df.collect()` returns `0, 1, 2` on both master and this head. The append
writes `10, 11` on master and `0, 1, 2` on this head. The new behavior matches
`collect()` and `DataFrameWriter`, so I would keep it. But it changes what an
existing job writes, so please add it to the user-facing section of the
description.
--
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]