Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
longvu-db committed Mar 13, 2024
1 parent 60914cd commit eaa0ebe
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,50 @@ class RowIdCloneSuite
}
}

for (rowIdsEnabledOnSource <- BOOLEAN_DOMAIN) {
for (targetTableState <- Seq(TableState.EMPTY, TableState.NON_EXISTING)) {
test("clone from empty source into an empty or non-existing target " +
s"does not assign row IDs, rowIdsEnabledOnSource=$rowIdsEnabledOnSource, " +
s"targetTableState=$targetTableState") {
withTables(
TableSetupInfo(tableName = "source",
rowIdsEnabled = rowIdsEnabledOnSource, tableState = TableState.EMPTY),
TableSetupInfo(tableName = "target",
rowIdsEnabled = false, tableState = targetTableState)) {
cloneTable(targetTableName = "target", sourceTableName = "source")

val (targetLog, snapshot) =
DeltaLog.forTableWithSnapshot(spark, TableIdentifier("target"))
assertRowIdsAreNotSet(targetLog)
assert(RowId.isSupported(snapshot.protocol) === rowIdsEnabledOnSource)
assert(RowId.isEnabled(snapshot.protocol, snapshot.metadata) === rowIdsEnabledOnSource)
}
}
}
}

for (targetTableState <- Seq(TableState.EMPTY, TableState.NON_EXISTING)) {
test("clone from empty source on an empty or non-existing target " +
s"using property override does not assign row IDs, targetTableState=$targetTableState") {
withTables(
TableSetupInfo(tableName = "source",
rowIdsEnabled = false, tableState = TableState.EMPTY),
TableSetupInfo(tableName = "target",
rowIdsEnabled = false, tableState = targetTableState)) {

cloneTable(
targetTableName = "target",
sourceTableName = "source",
tblProperties = s"'${DeltaConfigs.ROW_TRACKING_ENABLED.key}' = true" :: Nil)

val (targetLog, snapshot) = DeltaLog.forTableWithSnapshot(spark, TableIdentifier("target"))
assertRowIdsAreNotSet(targetLog)
assert(RowId.isSupported(snapshot.protocol))
assert(RowId.isEnabled(snapshot.protocol, snapshot.metadata))
}
}
}

test("clone that add row ID feature using table property override " +
"doesn't enable row IDs on target") {
withTables(
Expand Down

0 comments on commit eaa0ebe

Please sign in to comment.