Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaschat-db committed Jul 11, 2024
1 parent 1c253cd commit 56c79b2
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
15 changes: 10 additions & 5 deletions spark/src/main/scala/org/apache/spark/sql/delta/TableFeature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,16 @@ object TableFeature {
* in lower cases. Use [[featureNameToFeature]] instead.
*/
private[delta] def allSupportedFeaturesMap: Map[String, TableFeature] = {
val testingFeaturesEnabled = SparkSession
.getActiveSession
.map(_.conf.get(DeltaSQLConf.TABLE_FEATURES_TEST_FEATURES_ENABLED))
.getOrElse(true)
var features: Set[TableFeature] = Set(
val testingFeaturesEnabled =
try {
SparkSession
.getActiveSession
.map(_.conf.get(DeltaSQLConf.TABLE_FEATURES_TEST_FEATURES_ENABLED))
.getOrElse(true)
} catch {
case _ => true
}
var features: Set[TableFeature] = Set(
AllowColumnDefaultsTableFeature,
AppendOnlyTableFeature,
ChangeDataFeedTableFeature,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ object Protocol {
// relevant implicit features.
val implicitFeaturesFromTableConf =
(readerVersionFromTableConfOpt, writerVersionFromTableConfOpt) match {
case (Some(r), Some(w)) => Protocol(r, w).implicitlySupportedFeatures
case (Some(r), Some(w)) if supportsWriterFeatures(w) =>
Protocol(r, w).implicitlySupportedFeatures
case _ => Set.empty
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ 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").readerAndWriterFeatures.contains(VariantTypeTableFeature))
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion spark/src/test/scala/io/delta/tables/DeltaTableSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.Locale
import scala.language.postfixOps

// scalastyle:off import.ordering.noEmptyLine
import org.apache.spark.sql.delta._
import org.apache.spark.sql.delta.{AppendOnlyTableFeature, DeltaIllegalArgumentException, DeltaLog, DeltaTableFeatureException, FakeFileSystem, InvariantsTableFeature, TestReaderWriterFeature, TestWriterFeature}
import org.apache.spark.sql.delta.actions.{ Metadata, Protocol }
import org.apache.spark.sql.delta.storage.LocalLogStore
import org.apache.spark.sql.delta.test.DeltaSQLCommandTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (2024) The Delta Lake Project Authors.
* Copyright (2021) The Delta Lake Project Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class DropColumnMappingFeatureSuite extends RemoveColumnMappingSuiteUtils {
|TBLPROPERTIES ('delta.columnMapping.mode' = 'name')
|""".stripMargin)
val e = intercept[DeltaAnalysisException] {
// Try to drop column mapping.
dropColumnMappingTableFeature()
}
checkError(e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.apache.spark.sql.delta.schema

import org.apache.spark.sql.delta.DeltaConfigs

import scala.collection.JavaConverters._

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

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

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

0 comments on commit 56c79b2

Please sign in to comment.