Skip to content

Commit

Permalink
More suite fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaschat-db committed Jul 3, 2024
1 parent 469529a commit 731d9dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class DeltaVariantSuite
sql("INSERT INTO tbl (SELECT 'foo', parse_json(cast(id + 99 as string)) FROM range(1))")
assert(spark.table("tbl").selectExpr("v::int").head == Row(99))
assert(
getProtocolForTable("tbl") ==
VariantTypeTableFeature.minProtocolVersion.withFeature(VariantTypeTableFeature)
getProtocolForTable("tbl") == VariantTypeTableFeature.minProtocolVersion
.Features(Seq(AppendOnlyTableFeature, InvariantsTableFeature, VariantTypeTableFeature))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class DeltaTableFeatureSuite
Some(metadata))
.readerAndWriterFeatureNames ===
Set(
AppendOnlyTableFeature.name,
InvariantsTableFeature.name,
TestWriterFeatureWithTransitiveDependency.name,
TestFeatureWithDependency.name,
TestReaderWriterFeature.name))
Expand Down Expand Up @@ -333,6 +335,8 @@ class DeltaTableFeatureSuite
val log = DeltaLog.forTable(spark, TableIdentifier("tbl"))
val protocol = log.update().protocol
assert(protocol.readerAndWriterFeatureNames === Set(
AppendOnlyTableFeature.name,
InvariantsTableFeature.name,
ColumnMappingTableFeature.name,
TestWriterFeature.name))
}
Expand Down Expand Up @@ -386,6 +390,8 @@ class DeltaTableFeatureSuite
commandName, targetTableName = "tbl", sourceTableName = "tbl", tblProperties))
val protocol = log.update().protocol
assert(protocol.readerAndWriterFeatureNames === Set(
AppendOnlyTableFeature.name,
InvariantsTableFeature.name,
ChangeDataFeedTableFeature.name,
TestWriterFeature.name))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class DeltaTimestampNTZSuite extends QueryTest
new Timestamp(2022 - 1900, 0, 2, 3, 4, 5, 123456000),
LocalDateTime.of(2022, 1, 2, 3, 4, 5, 123456000)))
assert(getProtocolForTable("tbl") ==
TimestampNTZTableFeature.minProtocolVersion.withFeature(TimestampNTZTableFeature)
TimestampNTZTableFeature.minProtocolVersion.withFeatures(Seq(
AppendOnlyTableFeature, InvariantsTableFeature, TimestampNTZTableFeature))
)
}
}
Expand Down Expand Up @@ -114,7 +115,8 @@ class DeltaTimestampNTZSuite extends QueryTest
new Timestamp(2022 - 1900, 0, 2, 3, 4, 5, 123456000),
LocalDateTime.of(2022, 1, 2, 3, 4, 5, 123456000)))
assert(getProtocolForTable("delta_test") ==
TimestampNTZTableFeature.minProtocolVersion.withFeature(TimestampNTZTableFeature)
TimestampNTZTableFeature.minProtocolVersion.withFeatures(Seq(
AppendOnlyTableFeature, InvariantsTableFeature, TimestampNTZTableFeature))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.spark.sql.delta.schema
import scala.collection.JavaConverters._

import org.apache.spark.sql.delta.DeltaLog
import org.apache.spark.sql.delta.actions.Protocol
import org.apache.spark.sql.delta.constraints.CharVarcharConstraint
import org.apache.spark.sql.delta.sources.DeltaSQLConf
import org.apache.spark.sql.delta.test.DeltaSQLCommandTest
Expand Down Expand Up @@ -475,7 +476,7 @@ class CheckConstraintsSuite extends QueryTest
parameters = Map("constraints" -> "`c1`, `c2`")
)
val deltaLog = DeltaLog.forTable(spark, TableIdentifier("table"))
assert(deltaLog.update().protocol.readerAndWriterFeatureNames.contains("checkConstraints"))
assert(deltaLog.update().protocol === Protocol(1, 3))

sql("ALTER TABLE table DROP CONSTRAINT c1")
val error2 = intercept[AnalysisException] {
Expand All @@ -486,11 +487,11 @@ class CheckConstraintsSuite extends QueryTest
errorClass = "DELTA_CANNOT_DROP_CHECK_CONSTRAINT_FEATURE",
parameters = Map("constraints" -> "`c2`")
)
assert(deltaLog.update().protocol.readerAndWriterFeatureNames.contains("checkConstraints"))
assert(deltaLog.update().protocol === Protocol(1, 3))

sql("ALTER TABLE table DROP CONSTRAINT c2")
sql("ALTER TABLE table DROP FEATURE checkConstraints")
assert(!deltaLog.update().protocol.readerAndWriterFeatureNames.contains("checkConstraints"))
assert(deltaLog.update().protocol === Protocol(1, 2))
}
}
}

0 comments on commit 731d9dd

Please sign in to comment.