Skip to content

Commit 870d409

Browse files
MaxGekkcloud-fan
authored andcommitted
[SPARK-32512][SQL][TESTS][FOLLOWUP] Remove duplicate tests for ALTER TABLE .. PARTITIONS from DataSourceV2SQLSuite
### What changes were proposed in this pull request? Remove tests from `DataSourceV2SQLSuite` that were copied to `AlterTablePartitionV2SQLSuite` by #29339. ### Why are the changes needed? - To reduce tests execution time - To improve test maintenance ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? By running the modified tests: ``` $ build/sbt "test:testOnly *DataSourceV2SQLSuite" $ build/sbt "test:testOnly *AlterTablePartitionV2SQLSuite" ``` Closes #30444 from MaxGekk/dedup-tests-AlterTablePartitionV2SQLSuite. Authored-by: Max Gekk <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
1 parent 2289389 commit 870d409

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import scala.collection.JavaConverters._
2424

2525
import org.apache.spark.SparkException
2626
import org.apache.spark.sql._
27-
import org.apache.spark.sql.catalyst.InternalRow
2827
import org.apache.spark.sql.catalyst.analysis.{CannotReplaceMissingTableException, NamespaceAlreadyExistsException, NoSuchDatabaseException, NoSuchNamespaceException, TableAlreadyExistsException}
2928
import org.apache.spark.sql.catalyst.parser.ParseException
3029
import org.apache.spark.sql.connector.catalog._
@@ -43,7 +42,6 @@ class DataSourceV2SQLSuite
4342
with AlterTableTests with DatasourceV2SQLBase {
4443

4544
import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
46-
import org.apache.spark.sql.execution.datasources.v2.DataSourceV2Implicits._
4745

4846
private val v2Source = classOf[FakeV2Provider].getName
4947
override protected val v2Format = v2Source
@@ -1980,57 +1978,6 @@ class DataSourceV2SQLSuite
19801978
}
19811979
}
19821980

1983-
test("ALTER TABLE RECOVER PARTITIONS") {
1984-
val t = "testcat.ns1.ns2.tbl"
1985-
withTable(t) {
1986-
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING foo")
1987-
val e = intercept[AnalysisException] {
1988-
sql(s"ALTER TABLE $t RECOVER PARTITIONS")
1989-
}
1990-
assert(e.message.contains("ALTER TABLE RECOVER PARTITIONS is only supported with v1 tables"))
1991-
}
1992-
}
1993-
1994-
test("ALTER TABLE ADD PARTITION") {
1995-
val t = "testpart.ns1.ns2.tbl"
1996-
withTable(t) {
1997-
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING foo PARTITIONED BY (id)")
1998-
spark.sql(s"ALTER TABLE $t ADD PARTITION (id=1) LOCATION 'loc'")
1999-
2000-
val partTable = catalog("testpart").asTableCatalog
2001-
.loadTable(Identifier.of(Array("ns1", "ns2"), "tbl")).asInstanceOf[InMemoryPartitionTable]
2002-
assert(partTable.partitionExists(InternalRow.fromSeq(Seq(1))))
2003-
2004-
val partMetadata = partTable.loadPartitionMetadata(InternalRow.fromSeq(Seq(1)))
2005-
assert(partMetadata.containsKey("location"))
2006-
assert(partMetadata.get("location") == "loc")
2007-
}
2008-
}
2009-
2010-
test("ALTER TABLE RENAME PARTITION") {
2011-
val t = "testcat.ns1.ns2.tbl"
2012-
withTable(t) {
2013-
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING foo PARTITIONED BY (id)")
2014-
val e = intercept[AnalysisException] {
2015-
sql(s"ALTER TABLE $t PARTITION (id=1) RENAME TO PARTITION (id=2)")
2016-
}
2017-
assert(e.message.contains("ALTER TABLE RENAME PARTITION is only supported with v1 tables"))
2018-
}
2019-
}
2020-
2021-
test("ALTER TABLE DROP PARTITION") {
2022-
val t = "testpart.ns1.ns2.tbl"
2023-
withTable(t) {
2024-
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING foo PARTITIONED BY (id)")
2025-
spark.sql(s"ALTER TABLE $t ADD PARTITION (id=1) LOCATION 'loc'")
2026-
spark.sql(s"ALTER TABLE $t DROP PARTITION (id=1)")
2027-
2028-
val partTable =
2029-
catalog("testpart").asTableCatalog.loadTable(Identifier.of(Array("ns1", "ns2"), "tbl"))
2030-
assert(!partTable.asPartitionable.partitionExists(InternalRow.fromSeq(Seq(1))))
2031-
}
2032-
}
2033-
20341981
test("ALTER TABLE SerDe properties") {
20351982
val t = "testcat.ns1.ns2.tbl"
20361983
withTable(t) {

0 commit comments

Comments
 (0)