Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spark][TEST-ONLY] Test identity high water mark inserts when target table has no high water mark #4049

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,42 @@ trait IdentityColumnIngestionSuiteBase extends IdentityColumnTestUtils {
}
}

test("Appending from a source table with a high water mark should not update" +
" the target table's high water mark") {
withSrcAndDestTables(
isSrcDataSubsetOfTgt = false,
positiveStep = true,
expectValidHighWaterMark = false) { (srcTblName, tgtTblName) =>
val tgtDeltaLog = DeltaLog.forTable(spark, TableIdentifier(tgtTblName))
// dataframe v2
spark.table(srcTblName).writeTo(tgtTblName).append()
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")

// v1
spark.table(srcTblName).write.format("delta").mode("append").saveAsTable(tgtTblName)
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")

spark.table(srcTblName).write.insertInto(tgtTblName)
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")

// SQL
sql(s"INSERT INTO $tgtTblName SELECT * FROM $srcTblName")
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")

sql(s"INSERT INTO $tgtTblName BY NAME SELECT * FROM $srcTblName")
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")

sql(s"INSERT INTO $tgtTblName(id, value) SELECT id, value FROM $srcTblName")
assert(getHighWaterMark(tgtDeltaLog.update(), colName = "id").isEmpty,
"High watermark should not be set for user inserted data.")
}
}

for {
cdfEnabled <- DeltaTestUtils.BOOLEAN_DOMAIN
isSrcDataSubsetOfTgt <- DeltaTestUtils.BOOLEAN_DOMAIN
Expand Down
Loading