Skip to content

Commit c5ff236

Browse files
authored
[Spark][Test-Only] Add Row Tracking Clone tests with empty source table (delta-io#2742)
## Description Add Materialized Row Tracking columns CLONE tests, making sure we have enough Row Tracking test coverage necessary to gear us towards [enabling Row Tracking outside of testing](delta-io#2059). ## How was this patch tested? Existing + added UTs. ## Does this PR introduce _any_ user-facing changes? No.
1 parent d4ffc42 commit c5ff236

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

spark/src/test/scala/org/apache/spark/sql/delta/rowid/RowIdCloneSuite.scala

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,49 @@ class RowIdCloneSuite
8686
}
8787
}
8888

89+
for {
90+
rowIdsEnabledOnSource <- BOOLEAN_DOMAIN
91+
targetTableState <- Seq(TableState.EMPTY, TableState.NON_EXISTING)
92+
} {
93+
test("clone from empty source into an empty or non-existing target " +
94+
s"does not assign row IDs, rowIdsEnabledOnSource=$rowIdsEnabledOnSource, " +
95+
s"targetTableState=$targetTableState") {
96+
withTables(
97+
TableSetupInfo(tableName = "source",
98+
rowIdsEnabled = rowIdsEnabledOnSource, tableState = TableState.EMPTY),
99+
TableSetupInfo(tableName = "target",
100+
rowIdsEnabled = false, tableState = targetTableState)) {
101+
cloneTable(targetTableName = "target", sourceTableName = "source")
102+
103+
val (targetLog, snapshot) = DeltaLog.forTableWithSnapshot(spark, TableIdentifier("target"))
104+
assertRowIdsAreNotSet(targetLog)
105+
assert(RowId.isSupported(snapshot.protocol) === rowIdsEnabledOnSource)
106+
assert(RowId.isEnabled(snapshot.protocol, snapshot.metadata) === rowIdsEnabledOnSource)
107+
}
108+
}
109+
}
110+
111+
for (targetTableState <- Seq(TableState.EMPTY, TableState.NON_EXISTING))
112+
test("clone from empty source into an empty or non-existing target " +
113+
s"using property override does not assign row IDs, targetTableState=$targetTableState") {
114+
withTables(
115+
TableSetupInfo(tableName = "source",
116+
rowIdsEnabled = false, tableState = TableState.EMPTY),
117+
TableSetupInfo(tableName = "target",
118+
rowIdsEnabled = false, tableState = targetTableState)) {
119+
120+
cloneTable(
121+
targetTableName = "target",
122+
sourceTableName = "source",
123+
tblProperties = s"'${DeltaConfigs.ROW_TRACKING_ENABLED.key}' = true" :: Nil)
124+
125+
val (targetLog, snapshot) = DeltaLog.forTableWithSnapshot(spark, TableIdentifier("target"))
126+
assertRowIdsAreNotSet(targetLog)
127+
assert(RowId.isSupported(snapshot.protocol))
128+
assert(RowId.isEnabled(snapshot.protocol, snapshot.metadata))
129+
}
130+
}
131+
89132
test("clone that add row ID feature using table property override " +
90133
"doesn't enable row IDs on target") {
91134
withTables(

0 commit comments

Comments
 (0)