peter-toth commented on code in PR #60373:
URL: https://github.com/apache/spark/pull/60373#discussion_r4548100009
##########
sql/core/src/test/scala/org/apache/spark/sql/DataFrameWriterV2Suite.scala:
##########
@@ -279,6 +279,19 @@ class DataFrameWriterV2Suite extends SharedSparkSession
with BeforeAndAfter {
Seq(Row(1L, "a"), Row(2L, "b"), Row(4L, "d"), Row(5L, "e"), Row(6L,
"f")))
}
+ test("SPARK-61504: Overwrite: overwrite by expression on a CHAR column") {
+ spark.sql(
+ "CREATE TABLE testcat.table_name (id bigint, dep char(8)) USING foo
PARTITIONED BY (dep)")
+ spark.sql("INSERT INTO testcat.table_name VALUES (1L, 'hr'), (2L,
'software')")
+
+ // the query is not resolved when the command is created, unlike the query
of a SQL INSERT
+ Seq((3L, "hr")).toDF("id",
"dep").writeTo("testcat.table_name").overwrite($"dep" === "hr")
Review Comment:
**Finding 1.** What I ran: this test's table, with row 1 inserted under
`spark.sql.legacy.charVarcharAsString=true`, so it is stored as `hr` without
padding. A read still returns `hr `.
- On master the overwrite deletes row 1, because the literal stays unpadded
too.
- On this head row 1 stays next to `(3, hr )`.
- `INSERT INTO ... REPLACE WHERE dep = 'hr'` keeps it on both.
#60380 pads the column for every `OverwriteByExpression`, so it covers this
path only on top of this PR. Its tests use only SQL. Could one of the two PRs
add this case to `DataFrameWriterV2Suite`?
--
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]