dongjoon-hyun commented on code in PR #56102:
URL: https://github.com/apache/spark/pull/56102#discussion_r3300723524
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryTable.scala:
##########
@@ -50,7 +53,50 @@ class InMemoryTable(
override val id: String = UUID.randomUUID().toString)
extends InMemoryBaseTable(name, columns, partitioning, properties,
constraints, distribution,
ordering, numPartitions, advisoryPartitionSize,
isDistributionStrictlyRequired,
- numRowsPerSplit) with SupportsDelete {
+ numRowsPerSplit) with SupportsDelete with SupportsBranching {
+
+ private val branches = new ConcurrentHashMap[String, TableBranch]()
+
+ override def createBranch(branchName: String,
+ sourceSnapshotId: OptionalLong): TableBranch = {
+ val snapshot = if (sourceSnapshotId.isPresent) sourceSnapshotId.getAsLong
+ else version().toLong
+ val branch = new TableBranch(branchName, snapshot,
System.currentTimeMillis())
+ val existing = branches.putIfAbsent(branchName, branch)
+ if (existing != null) {
+ throw new SupportsBranching.BranchAlreadyExistsException(branchName)
+ }
+ branch
+ }
+
+ override def dropBranch(branchName: String): Boolean = {
+ branches.remove(branchName) != null
+ }
+
+ override def fastForward(branchName: String, targetBranchName: String):
TableBranch = {
+ val current = branches.get(branchName)
+ if (current == null) {
+ throw new java.util.NoSuchElementException(s"Branch not found:
$branchName")
+ }
+ val target = branches.get(targetBranchName)
+ if (target == null) {
+ throw new java.util.NoSuchElementException(s"Branch not found:
$targetBranchName")
Review Comment:
ditto.
Please correct me if this is the standard of DSv2 and Apache Iceberg.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]