-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c04cb06
commit ef278ab
Showing
9 changed files
with
284 additions
and
49 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
kernel/kernel-api/src/main/java/io/delta/kernel/actions/AbstractProtocol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (2024) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.delta.kernel.actions; | ||
|
||
import io.delta.kernel.annotation.Evolving; | ||
import java.util.Set; | ||
|
||
/** | ||
* Interface for Protocol actions in Delta. | ||
* | ||
* <p>See <a | ||
* href=https://github.com/delta-io/delta/blob/master/PROTOCOL.md#protocol-evolution>Protocol</a> | ||
* for more details. | ||
*/ | ||
@Evolving | ||
public interface AbstractProtocol { | ||
|
||
/** The minimum reader version required to read the table. */ | ||
int getMinReaderVersion(); | ||
|
||
/** The minimum writer version required to read the table. */ | ||
int getMinWriterVersion(); | ||
|
||
/** The reader features that need to be supported to read the table. */ | ||
Set<String> getReaderFeatures(); | ||
|
||
/** The writer features that need to be supported to write the table. */ | ||
Set<String> getWriterFeatures(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
kernel/kernel-api/src/test/scala/io/delta/kernel/internal/actions/ProtocolSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (2025) 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.delta.kernel.internal.actions | ||
|
||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
class ProtocolSuite extends AnyFunSuite { | ||
|
||
test("instantiation -- bad minReaderVersion should throw") { | ||
val exMsg = intercept[IllegalArgumentException] { | ||
new Protocol(0, 1, null, null) | ||
}.getMessage | ||
|
||
assert(exMsg === "minReaderVersion must be >= 1") | ||
} | ||
|
||
test("instantiation -- bad minWriterVersion should throw") { | ||
val exMsg = intercept[IllegalArgumentException] { | ||
new Protocol(1, 0, null, null) | ||
}.getMessage | ||
|
||
assert(exMsg === "minWriterVersion must be >= 1") | ||
} | ||
|
||
test("instantiation -- minReaderVersion < 3 but readerFeatures non-empty should throw") { | ||
val exMsg = intercept[IllegalArgumentException] { | ||
new Protocol(1, 1, Set("columnMapping").asJava, null) | ||
}.getMessage | ||
|
||
assert(exMsg === "This protocol has minReaderVersion 1 but readerFeatures is not " + | ||
"empty: [columnMapping]. readerFeatures are only supported with minReaderVersion >= 3.") | ||
} | ||
|
||
test("instantiation -- minWriterVersion < 7 but writerFeatures non-empty should throw") { | ||
val exMsg = intercept[IllegalArgumentException] { | ||
new Protocol(1, 1, null, Set("appendOnly").asJava) | ||
}.getMessage | ||
|
||
assert(exMsg === "This protocol has minWriterVersion 1 but writerFeatures is not " + | ||
"empty: [appendOnly]. writerFeatures are only supported with minWriterVersion >= 7.") | ||
} | ||
|
||
test("instantiation -- minReaderVersion >= 3 but minWriterVersion < 7 should throw") { | ||
val exMsg = intercept[IllegalArgumentException] { | ||
new Protocol(3, 6, null, null) | ||
}.getMessage | ||
|
||
assert(exMsg === "This protocol has minReaderVersion 3 but minWriterVersion 6. When " + | ||
"minReaderVersion is >= 3, minWriterVersion must be >= 7.") | ||
} | ||
|
||
} |
Oops, something went wrong.