Skip to content

Commit

Permalink
PartitioningUpdateException (#266)
Browse files Browse the repository at this point in the history
PartitioningUpdateException
  • Loading branch information
salamonpavel authored Sep 10, 2024
1 parent d31eded commit 18f2285
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions agent/src/main/scala/za/co/absa/atum/agent/AtumContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package za.co.absa.atum.agent

import org.apache.spark.sql.DataFrame
import za.co.absa.atum.agent.AtumContext.{AdditionalData, AtumPartitions}
import za.co.absa.atum.agent.exception.AtumAgentException.PartitioningUpdateException
import za.co.absa.atum.agent.model._
import za.co.absa.atum.model.dto._

Expand Down Expand Up @@ -52,6 +53,10 @@ class AtumContext private[agent] (
* @return the sub-partition context
*/
def subPartitionContext(subPartitions: AtumPartitions): AtumContext = {
val overlap = atumPartitions.keys.toSet.intersect(subPartitions.keys.toSet)
if (overlap.nonEmpty) {
throw PartitioningUpdateException(s"Partition keys '$overlap' already exist. Updates are not allowed.")
}
agent.getOrCreateAtumSubContext(atumPartitions ++ subPartitions)(this)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ object AtumAgentException {
* @param message A message describing the exception.
*/
case class HttpException(statusCode: Int, message: String) extends AtumAgentException(message)

/**
* This type represents an exception related to partitioning update.
* @param message A message describing the exception.
*/
case class PartitioningUpdateException(message: String) extends AtumAgentException(message)
}

0 comments on commit 18f2285

Please sign in to comment.