Skip to content

Commit fbc2384

Browse files
authored
[Spark][Test-Only] Add Row Tracking self-Clone tests (delta-io#2743)
## Description Add Row Tracking self-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 fb08c8f commit fbc2384

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.spark.sql.delta.rowid
1818

1919
import org.apache.spark.sql.delta.{DeltaConfigs, DeltaIllegalStateException, DeltaLog, RowId}
20+
import org.apache.spark.sql.delta.DeltaTestUtils.BOOLEAN_DOMAIN
2021
import org.apache.spark.sql.delta.actions.TableFeatureProtocolUtils.TABLE_FEATURES_MIN_WRITER_VERSION
2122
import org.apache.spark.sql.delta.sources.DeltaSQLConf
2223

@@ -70,6 +71,21 @@ class RowIdCloneSuite
7071
}
7172
}
7273

74+
for (enableRowIdsForSource <- BOOLEAN_DOMAIN)
75+
test("self-clone an empty table does not change the table's Row Tracking " +
76+
s"enablement and does not set Row IDs, enableRowIdsForSource=$enableRowIdsForSource") {
77+
withTables(
78+
TableSetupInfo(tableName = "source",
79+
rowIdsEnabled = enableRowIdsForSource, tableState = TableState.EMPTY)) {
80+
cloneTable(targetTableName = "source", sourceTableName = "source")
81+
82+
val (targetLog, snapshot) = DeltaLog.forTableWithSnapshot(spark, TableIdentifier("source"))
83+
assertRowIdsAreNotSet(targetLog)
84+
assert(RowId.isSupported(targetLog.update().protocol) === enableRowIdsForSource)
85+
assert(RowId.isEnabled(snapshot.protocol, snapshot.metadata) === enableRowIdsForSource)
86+
}
87+
}
88+
7389
test("clone that add row ID feature using table property override " +
7490
"doesn't enable row IDs on target") {
7591
withTables(

0 commit comments

Comments
 (0)