Skip to content

Commit

Permalink
[Spark] Reorganise where deletion vectors are added to the test suite…
Browse files Browse the repository at this point in the history
…s for CLONE (delta-io#4063)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Just some minor reorganisation of tests to ensure CLONE codepaths are
tested with and without DVs as expected.

## How was this patch tested?

Test-only PR.

## Does this PR introduce _any_ user-facing changes?

No
  • Loading branch information
larsk-db authored Jan 16, 2025
1 parent 5d794e5 commit b153bf3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ import org.apache.spark.util.Utils
class CloneTableSQLSuite extends CloneTableSuiteBase
with DeltaColumnMappingTestUtils
{

override def beforeAll(): Unit = {
super.beforeAll()
disableDeletionVectors(spark.conf)
}

// scalastyle:off argcount
override protected def cloneTable(
source: String,
Expand Down Expand Up @@ -346,7 +352,7 @@ object CloneTableSQLTestUtils {
}

class CloneTableScalaDeletionVectorSuite
extends CloneTableSQLSuite
extends CloneTableScalaSuite
with DeltaSQLCommandTest
with DeltaExcludedTestMixin
with DeletionVectorsTestUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ trait CloneTableSuiteBase extends QueryTest
with DeltaColumnMappingTestUtils
with DeltaSQLCommandTest
with CoordinatedCommitsBaseSuite
with CoordinatedCommitsTestUtils {
with CoordinatedCommitsTestUtils
with DeletionVectorsTestUtils {

protected val TAG_HAS_SHALLOW_CLONE = new Tag("SHALLOW CLONE")
protected val TAG_MODIFY_PROTOCOL = new Tag("CHANGES PROTOCOL")
Expand Down Expand Up @@ -748,7 +749,9 @@ trait CloneTableSuiteBase extends QueryTest
}

testAllClones("CLONE with table properties to disable DV") { (source, target, isShallow) =>
withSQLConf(DeltaConfigs.ENABLE_DELETION_VECTORS_CREATION.defaultTablePropertyKey -> "true") {
withSQLConf(
DeltaConfigs.ENABLE_DELETION_VECTORS_CREATION.defaultTablePropertyKey -> "true",
DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS.key -> "true") {
spark.range(10).write.format("delta").save(source)
spark.sql(s"DELETE FROM delta.`$source` WHERE id = 1")
}
Expand Down Expand Up @@ -829,7 +832,7 @@ trait CloneTableSuiteBase extends QueryTest
val targetDeltaLog = DeltaLog.forTable(spark, target)
val targetSnapshot = targetDeltaLog.update()
assert(targetSnapshot.metadata.configuration ===
tblProperties ++ sourceSnapshot.metadata.configuration)
sourceSnapshot.metadata.configuration ++ tblProperties)
// Check that the protocol has been upgraded.
assert(StrictProtocolOrdering.fulfillsVersionRequirements(
actual = targetSnapshot.protocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ trait DeletionVectorsTestUtils extends QueryTest with SharedSparkSession with De
spark.conf.set(DeltaSQLConf.MERGE_USE_PERSISTENT_DELETION_VECTORS.key, merge.toString)
}

/** Disable persistent deletion vectors in new tables and all supported DML commands. */
def disableDeletionVectors(conf: RuntimeConfig): Unit = {
conf.set(DeltaConfigs.ENABLE_DELETION_VECTORS_CREATION.defaultTablePropertyKey, false.toString)
conf.set(DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS.key, false.toString)
conf.set(DeltaSQLConf.UPDATE_USE_PERSISTENT_DELETION_VECTORS.key, false.toString)
}

def enableDeletionVectorsForAllSupportedOperations(spark: SparkSession): Unit =
enableDeletionVectors(spark, delete = true, update = true)

Expand Down

0 comments on commit b153bf3

Please sign in to comment.