From 1fedb56d5e6af0f7630778150dd3209241bd8d15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wa=C5=9B?= Date: Fri, 4 Aug 2023 12:20:03 +0200 Subject: [PATCH] Update dependencies --- pom.xml | 42 ++++++++++--------- .../trino/storage/operator/JsonPlugin.java | 40 +++++++++++------- .../trino/storage/TestingHadoopServer.java | 2 +- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index fbe1a5e..97caeef 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.ebyhr trino-storage - 421-SNAPSHOT + 422-SNAPSHOT Trino - Storage Connector trino-plugin @@ -16,7 +16,7 @@ io.airlift airbase - 138 + 143 @@ -37,15 +37,15 @@ true false - 420 - 233 + 422 + 234 ${dep.airlift.version} - 1.12.477 - 2.20.0 - 2.15.1 + 1.12.522 + 2.21.0 + 2.15.2 1.18.3 - 3.3.0 - 7.7.1 + 3.3.2 + 7.8.0 2.12.5 1.26.0 1.25.1 @@ -76,7 +76,17 @@ net.bytebuddy byte-buddy - 1.14.4 + 1.14.5 + + + io.airlift + slice + 0.45 + + + org.openjdk.jol + jol-core + 0.17 @@ -205,7 +215,7 @@ io.trino.hadoop hadoop-apache runtime - 3.2.0-18 + 3.3.5-1 @@ -229,7 +239,7 @@ io.airlift units - 1.8 + 1.10 runtime @@ -258,7 +268,6 @@ io.airlift slice - 0.45 provided @@ -287,7 +296,6 @@ org.openjdk.jol jol-core provided - 0.17 @@ -361,12 +369,6 @@ test - - org.jetbrains.kotlin - kotlin-stdlib-common - test - - org.testcontainers testcontainers diff --git a/src/main/java/org/ebyhr/trino/storage/operator/JsonPlugin.java b/src/main/java/org/ebyhr/trino/storage/operator/JsonPlugin.java index cf2d400..178d8b7 100644 --- a/src/main/java/org/ebyhr/trino/storage/operator/JsonPlugin.java +++ b/src/main/java/org/ebyhr/trino/storage/operator/JsonPlugin.java @@ -21,6 +21,7 @@ import io.airlift.slice.Slice; import io.trino.spi.TrinoException; import io.trino.spi.block.BlockBuilder; +import io.trino.spi.block.RowBlockBuilder; import io.trino.spi.type.ArrayType; import io.trino.spi.type.BooleanType; import io.trino.spi.type.RowType; @@ -34,6 +35,7 @@ import java.io.UncheckedIOException; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -150,35 +152,43 @@ private List nodeToRow(JsonNode node) private Object mapValue(JsonNode node) { - BlockBuilder values; switch (node.getNodeType()) { - case ARRAY: + case ARRAY -> { Iterator elements = node.elements(); if (!elements.hasNext()) { throw new VerifyException("Cannot infer the SQL type of an empty JSON array"); } Type type = mapType(elements.next()); - values = type.createBlockBuilder(null, 10); + BlockBuilder values = type.createBlockBuilder(null, 10); node.elements().forEachRemaining(value -> writeObject(values, value)); return values.build(); - case BOOLEAN: + } + case BOOLEAN -> { return node.asBoolean(); - case NUMBER: + } + case NUMBER -> { return node.canConvertToLong() ? node.asLong() : node.asDouble(); - case OBJECT: + } + case OBJECT -> { Type rowType = mapType(node); - values = rowType.createBlockBuilder(null, 10); - BlockBuilder rowBuilder = values.beginBlockEntry(); - node.fields().forEachRemaining(field -> writeObject(rowBuilder, field.getValue())); - values.closeEntry(); - return rowType.getObject(values, values.getPositionCount() - 1); - case NULL: + RowBlockBuilder rowBlockBuilder = (RowBlockBuilder) rowType.createBlockBuilder(null, 10); + rowBlockBuilder.buildEntry(elementBuilder -> { + Iterator> fields = node.fields(); + for (int i = 0; fields.hasNext(); i++) { + writeObject(elementBuilder.get(i), fields.next().getValue()); + } + }); + return rowType.getObject(rowBlockBuilder, rowBlockBuilder.getPositionCount() - 1); + } + case NULL -> { return null; - case STRING: + } + case STRING -> { return node.asText(); - default: + } + default -> // BINARY, MISSING, POJO - throw new VerifyException("Unhandled JSON type: " + node.getNodeType()); + throw new VerifyException("Unhandled JSON type: " + node.getNodeType()); } } diff --git a/src/test/java/org/ebyhr/trino/storage/TestingHadoopServer.java b/src/test/java/org/ebyhr/trino/storage/TestingHadoopServer.java index 6f334d3..b0dd401 100644 --- a/src/test/java/org/ebyhr/trino/storage/TestingHadoopServer.java +++ b/src/test/java/org/ebyhr/trino/storage/TestingHadoopServer.java @@ -40,7 +40,7 @@ public class TestingHadoopServer public TestingHadoopServer(Network network) { - dockerContainer = new GenericContainer<>(DockerImageName.parse("ghcr.io/trinodb/testing/hdp2.6-hive:65")) + dockerContainer = new GenericContainer<>(DockerImageName.parse("ghcr.io/trinodb/testing/hdp2.6-hive:82")) .withCreateContainerCmdModifier(cmd -> cmd.withHostName(HOSTNAME)) .withCopyFileToContainer(MountableFile.forClasspathResource("minio/hive-core-site.xml"), "/etc/hadoop/conf/core-site.xml") .withStartupCheckStrategy(new IsRunningStartupCheckStrategy())