Skip to content

Commit 7a030ea

Browse files
authored
[Delta] Refactor DeltaVacuumSuite (delta-io#4850)
<!-- 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 <!-- - Describe what this PR changes. - Describe why we need the change. If this PR resolves an issue be sure to include "Resolves #XXX" to correctly link and close the issue upon merge. --> This PR migrates `DeltaVacuumSuite` to `CatalogOwned`. ## How was this patch tested? <!-- If tests were added, say they were added here. Please make sure to test the changes thoroughly including negative and positive cases if possible. If the changes were tested in any way other than unit tests, please clarify how you tested step by step (ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future). If the changes were not tested, please explain why. --> Existing UTs. ## Does this PR introduce _any_ user-facing changes? <!-- If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Delta Lake versions or within the unreleased branches such as master. If no, write 'No'. --> No
1 parent 3e53bea commit 7a030ea

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

spark/src/test/scala/org/apache/spark/sql/delta/DeltaVacuumSuite.scala

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import org.apache.spark.sql.delta.actions.{AddCDCFile, AddFile, Metadata, Remove
3131
import org.apache.spark.sql.delta.catalog.DeltaTableV2
3232
import org.apache.spark.sql.delta.commands.VacuumCommand
3333
import org.apache.spark.sql.delta.coordinatedcommits.CatalogOwnedCommitCoordinatorProvider
34-
import org.apache.spark.sql.delta.coordinatedcommits.CoordinatedCommitsBaseSuite
34+
import org.apache.spark.sql.delta.coordinatedcommits.CatalogOwnedTestBaseSuite
3535
import org.apache.spark.sql.delta.coordinatedcommits.TrackingInMemoryCommitCoordinatorBuilder
3636
import org.apache.spark.sql.delta.sources.DeltaSQLConf
3737
import org.apache.spark.sql.delta.test.DeltaSQLCommandTest
@@ -47,6 +47,7 @@ import org.scalatest.GivenWhenThen
4747
import org.apache.spark.{SparkConf, SparkException}
4848
import org.apache.spark.sql.{AnalysisException, DataFrame, QueryTest, Row, SaveMode, SparkSession}
4949
import org.apache.spark.sql.catalyst.TableIdentifier
50+
import org.apache.spark.sql.catalyst.catalog.CatalogTableType
5051
import org.apache.spark.sql.catalyst.expressions.Literal
5152
import org.apache.spark.sql.catalyst.util.IntervalUtils
5253
import org.apache.spark.sql.execution.metric.SQLMetric
@@ -63,7 +64,7 @@ trait DeltaVacuumSuiteBase extends QueryTest
6364
with DeltaSQLTestUtils
6465
with DeletionVectorsTestUtils
6566
with DeltaTestUtilsForTempViews
66-
with CoordinatedCommitsBaseSuite {
67+
with CatalogOwnedTestBaseSuite {
6768

6869
private def executeWithEnvironment(file: File)(f: (File, ManualClock) => Unit): Unit = {
6970
val clock = new ManualClock()
@@ -411,9 +412,6 @@ trait DeltaVacuumSuiteBase extends QueryTest
411412
val df1 = sql(s"SELECT * FROM delta.`${dir.getAbsolutePath}`").collect()
412413

413414
val changes = getCDCFiles(deltaLog)
414-
var numExpectedChangeFiles = 2
415-
416-
assert(changes.size === numExpectedChangeFiles)
417415

418416
// vacuum will not delete the cdc files if they are within retention
419417
sql(s"VACUUM '${dir.getAbsolutePath}' RETAIN 100 HOURS")
@@ -616,8 +614,8 @@ class DeltaVacuumSuite extends DeltaVacuumSuiteBase with DeltaSQLCommandTest {
616614
val schema = new StructType().add("_underscore_col_", IntegerType).add("n", IntegerType)
617615
val metadata =
618616
Metadata(schemaString = schema.json, partitionColumns = Seq("_underscore_col_"))
619-
val version =
620-
txn.commit(metadata :: Nil, DeltaOperations.CreateTable(metadata, isManaged = true))
617+
val version = txn.commitActions(
618+
DeltaOperations.CreateTable(metadata, isManaged = true), metadata)
621619
setCommitClock(table, version, clock)
622620
gcTest(table, clock)(
623621
CreateFile("file1.txt", commitToActionLog = true, Map("_underscore_col_" -> "10")),
@@ -639,8 +637,8 @@ class DeltaVacuumSuite extends DeltaVacuumSuiteBase with DeltaSQLCommandTest {
639637
val schema = new StructType().add("_underscore_col_", IntegerType).add("n", IntegerType)
640638
val metadata =
641639
Metadata(schemaString = schema.json, partitionColumns = Seq("_underscore_col_"))
642-
val version =
643-
txn.commit(metadata :: Nil, DeltaOperations.CreateTable(metadata, isManaged = true))
640+
val version = txn.commitActions(
641+
DeltaOperations.CreateTable(metadata, isManaged = true), metadata)
644642
setCommitClock(table, version, clock)
645643
val inventorySchema = StructType(
646644
Seq(
@@ -673,8 +671,8 @@ class DeltaVacuumSuite extends DeltaVacuumSuiteBase with DeltaSQLCommandTest {
673671
// Vacuum should consider partition folders even for clean up even though it starts with `_`
674672
val metadata =
675673
Metadata(schemaString = schema.json, partitionColumns = Seq("_underscore_col_"))
676-
val version =
677-
txn.commit(metadata :: Nil, DeltaOperations.CreateTable(metadata, isManaged = true))
674+
val version = txn.commitActions(
675+
DeltaOperations.CreateTable(metadata, isManaged = true), metadata)
678676
setCommitClock(table, version, clock)
679677
val dataPath = table.deltaLog.dataPath
680678
// Create a Seq of Rows containing the data
@@ -1514,10 +1512,6 @@ class DeltaVacuumSuite extends DeltaVacuumSuiteBase with DeltaSQLCommandTest {
15141512
}
15151513
}
15161514

1517-
class DeltaVacuumWithCoordinatedCommitsBatch100Suite extends DeltaVacuumSuite {
1518-
override val coordinatedCommitsBackfillBatchSize: Option[Int] = Some(100)
1519-
}
1520-
15211515
class DeltaLiteVacuumSuite
15221516
extends DeltaVacuumSuite {
15231517
override def isLiteVacuum: Boolean = true
@@ -1635,7 +1629,3 @@ class DeltaLiteVacuumSuite
16351629
}
16361630
}
16371631
}
1638-
1639-
class DeltaLiteVacuumWithCoordinatedCommitsBatch100Suite extends DeltaLiteVacuumSuite {
1640-
override val coordinatedCommitsBackfillBatchSize: Option[Int] = Some(100)
1641-
}

0 commit comments

Comments
 (0)