Skip to content

Commit

Permalink
[Spark][Test-Only] Add Row Tracking Clone tests with empty source tab…
Browse files Browse the repository at this point in the history
…le (#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](#2059).

## How was this patch tested?
Existing + added UTs.

## Does this PR introduce _any_ user-facing changes?
No.
  • Loading branch information
longvu-db authored Mar 20, 2024
1 parent d4ffc42 commit c5ff236
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,49 @@ class RowIdCloneSuite
}
}

for {
rowIdsEnabledOnSource <- BOOLEAN_DOMAIN
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 into 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 c5ff236

Please sign in to comment.