-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ba61062
commit ab8f364
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
kernel/kernel-defaults/src/test/scala/io/delta/kernel/defaults/ActionSerializerSuite.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,50 @@ | ||
/* | ||
* 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.defaults; | ||
|
||
import io.delta.kernel.defaults.internal.json.JsonUtils | ||
import io.delta.kernel.internal.actions.Protocol | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
import java.util.Collections | ||
import scala.collection.JavaConverters._ | ||
|
||
// TODO: this class should actually write the actions to a json file and read them back | ||
// TODO: do this for all action types | ||
class ActionSerializerSuite extends AnyFunSuite { | ||
test("protocol to json") { | ||
{ | ||
val protocol = new Protocol(1, 2, Collections.emptySet(), Collections.emptySet()) | ||
val json = JsonUtils.rowToJson(protocol.toRow) | ||
assert(json === """{"minReaderVersion":1,"minWriterVersion":2}""") | ||
} | ||
{ | ||
val protocol = new Protocol(3, 7, Collections.emptySet(), Collections.emptySet()) | ||
val json = JsonUtils.rowToJson(protocol.toRow) | ||
// scalastyle:off line.size.limit | ||
assert(json === """{"minReaderVersion":3,"minWriterVersion":7,"readerFeatures":[],"writerFeatures":[]}""") | ||
// scalastyle:on line.size.limit | ||
} | ||
{ | ||
val protocol = new Protocol(3, 7, Set("columnMapping").asJava, Set("appendOnly").asJava) | ||
val json = JsonUtils.rowToJson(protocol.toRow) | ||
// scalastyle:off line.size.limit | ||
assert(json === """{"minReaderVersion":3,"minWriterVersion":7,"readerFeatures":["columnMapping"],"writerFeatures":["appendOnly"]}""") | ||
// scalastyle:on line.size.limit | ||
} | ||
} | ||
} |