Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor isSameDomain for JsonMetadataDomain #2767

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private[delta] class ConflictChecker(
winningDomainMetadataMap.get(domainMetadataFromCurrentTransaction.domain)) match {
// No-conflict case.
case (domain, None) => domain
case (domain, _) if RowTrackingMetadataDomain.isRowTrackingDomain(domain) => domain
case (domain, _) if RowTrackingMetadataDomain.isSameDomain(domain) => domain
case (_, Some(_)) =>
// Any conflict not specifically handled by a previous case must fail the transaction.
throw new io.delta.exceptions.ConcurrentTransactionException(
Expand Down Expand Up @@ -541,7 +541,7 @@ private[delta] class ConflictChecker(
}
Some(a.copy(baseRowId = Some(newBaseRowId)))
// The row ID high water mark will be replaced if it exists.
case d: DomainMetadata if RowTrackingMetadataDomain.isRowTrackingDomain(d) => None
case d: DomainMetadata if RowTrackingMetadataDomain.isSameDomain(d) => None
case a => Some(a)
}
currentTransactionInfo = currentTransactionInfo.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ abstract class JsonMetadataDomainUtils[T: Manifest] {

protected def fromJsonConfiguration(domain: DomainMetadata): T =
JsonUtils.fromJson[T](domain.configuration)

def isSameDomain(d: DomainMetadata): Boolean = d.domain == domainName
}

Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ trait OptimisticTransactionImpl extends TransactionalWrite
dataChanged = true
}
// Row tracking is able to resolve write conflicts regardless of isolation level.
case d: DomainMetadata if RowTrackingMetadataDomain.isRowTrackingDomain(d) =>
case d: DomainMetadata if RowTrackingMetadataDomain.isSameDomain(d) =>
// Do nothing
case _ =>
hasIncompatibleActions = true
Expand Down
4 changes: 1 addition & 3 deletions spark/src/main/scala/org/apache/spark/sql/delta/RowId.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ object RowId {
case d: DomainMetadata if d.domain == domainName => Some(fromJsonConfiguration(d))
case _ => None
}

def isRowTrackingDomain(d: DomainMetadata): Boolean = d.domain == domainName
}

val MISSING_HIGH_WATER_MARK: Long = -1L
Expand Down Expand Up @@ -87,7 +85,7 @@ object RowId {
throw DeltaErrors.rowIdAssignmentWithoutStats
}
a.copy(baseRowId = Some(baseRowId))
case d: DomainMetadata if RowTrackingMetadataDomain.isRowTrackingDomain(d) =>
case d: DomainMetadata if RowTrackingMetadataDomain.isSameDomain(d) =>
throw new IllegalStateException(
"Manually setting the Row ID high water mark is not allowed")
case other => other
Expand Down
Loading