Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
GitOrigin-RevId: c4d7d8659f3a7c67e50c28a4083b5b26562a0c3c
  • Loading branch information
fred-db authored and allisonport-db committed May 30, 2023
1 parent df9d74d commit 3e2157f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.apache.spark.sql.delta

import scala.collection.JavaConverters._

import org.antlr.v4.runtime.ParserRuleContext

import org.apache.spark.sql.AnalysisException
Expand Down Expand Up @@ -47,6 +49,11 @@ class DeltaIllegalArgumentException(
with DeltaThrowable {
override def getErrorClass: String = errorClass
def getMessageParametersArray: Array[String] = messageParameters

override def getMessageParameters: java.util.Map[String, String] = {
DeltaThrowableHelper.getParameterNames(errorClass, errorSubClass = null)
.zip(messageParameters).toMap.asJava
}
}

class DeltaUnsupportedOperationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite


RowId.verifyMetadata(
spark, protocol, snapshot.metadata, newMetadataTmp, isCreatingNewTable)
spark, snapshot.protocol, protocol, snapshot.metadata, newMetadataTmp, isCreatingNewTable)

assertMetadata(newMetadataTmp)
logInfo(s"Updated metadata from ${newMetadata.getOrElse("-")} to $newMetadataTmp")
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/scala/org/apache/spark/sql/delta/RowId.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ object RowId {
*/
private[delta] def verifyMetadata(
spark: SparkSession,
protocol: Protocol,
oldProtocol: Protocol,
newProtocol: Protocol,
oldMetadata: Metadata,
newMetadata: Metadata,
isCreatingNewTable: Boolean): Unit = {
if (!isAllowed(spark)) return

val rowIdsEnabledBefore = isEnabled(protocol, oldMetadata)
val rowIdsEnabledAfter = isEnabled(protocol, newMetadata)
val rowIdsEnabledBefore = isEnabled(oldProtocol, oldMetadata)
val rowIdsEnabledAfter = isEnabled(newProtocol, newMetadata)

if (rowIdsEnabledAfter && !rowIdsEnabledBefore && !isCreatingNewTable) {
throw new UnsupportedOperationException(
Expand Down

0 comments on commit 3e2157f

Please sign in to comment.