diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java index 7666e9137d89..7598abc4150f 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java @@ -157,14 +157,13 @@ public RowType getAddEntryType(MetadataEntry metadataEntry, boolean requireWrite private static RowType.Field buildNullCountType(Optional columnName, Type columnType) { if (columnType instanceof RowType rowType) { - if (columnName.isPresent()) { - return RowType.field( - columnName.get(), - RowType.from(rowType.getFields().stream().map(field -> buildNullCountType(field.getName(), field.getType())).collect(toImmutableList()))); - } - return RowType.field(RowType.from(rowType.getFields().stream().map(field -> buildNullCountType(field.getName(), field.getType())).collect(toImmutableList()))); + RowType rowTypeFromFields = RowType.from( + rowType.getFields().stream() + .map(field -> buildNullCountType(field.getName(), field.getType())) + .collect(toImmutableList())); + return new RowType.Field(columnName, rowTypeFromFields); } - return columnName.map(name -> RowType.field(name, BigintType.BIGINT)).orElse(RowType.field(BigintType.BIGINT)); + return new RowType.Field(columnName, BigintType.BIGINT); } public RowType getRemoveEntryType() diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsConnectorSmokeTest.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsConnectorSmokeTest.java index 2fe5b4aef91e..891aadd0e95e 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsConnectorSmokeTest.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsConnectorSmokeTest.java @@ -87,7 +87,7 @@ protected HiveMinioDataLake createHiveMinioDataLake() FileAttribute> posixFilePermissions = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")); Path hadoopCoreSiteXmlTempFile = Files.createTempFile("core-site", ".xml", posixFilePermissions); hadoopCoreSiteXmlTempFile.toFile().deleteOnExit(); - Files.write(hadoopCoreSiteXmlTempFile, abfsSpecificCoreSiteXmlContent.getBytes(UTF_8)); + Files.writeString(hadoopCoreSiteXmlTempFile, abfsSpecificCoreSiteXmlContent); HiveMinioDataLake hiveMinioDataLake = new HiveMinioDataLake( bucketName, diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsStorage.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsStorage.java index faa729a7b838..9e5fb94216cb 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsStorage.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeAdlsStorage.java @@ -103,7 +103,7 @@ private Path createHadoopCoreSiteXmlTempFileWithAbfsSettings() FileAttribute> posixFilePermissions = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rw-r--r--")); Path coreSiteXml = Files.createTempFile("core-site", ".xml", posixFilePermissions); coreSiteXml.toFile().deleteOnExit(); - Files.write(coreSiteXml, abfsSpecificCoreSiteXmlContent.getBytes(UTF_8)); + Files.writeString(coreSiteXml, abfsSpecificCoreSiteXmlContent); return coreSiteXml; } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePlugin.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePlugin.java index badd1f894e68..9b85235740fa 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePlugin.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakePlugin.java @@ -26,7 +26,6 @@ import java.nio.file.Files; import static com.google.common.collect.Iterables.getOnlyElement; -import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThatThrownBy; public class TestDeltaLakePlugin @@ -197,7 +196,7 @@ public void testFileBasedAccessControl() ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); File tempFile = File.createTempFile("test-delta-lake-plugin-access-control", ".json"); tempFile.deleteOnExit(); - Files.write(tempFile.toPath(), "{}".getBytes(UTF_8)); + Files.writeString(tempFile.toPath(), "{}"); factory.create( "test", diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java index ffdf9566ea8c..927ac5812366 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java @@ -81,6 +81,7 @@ import static io.trino.testing.TestingConnectorSession.SESSION; import static io.trino.testing.TestingNames.randomNameSuffix; import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.hadoop.hive.metastore.TableType.EXTERNAL_TABLE; import static org.apache.hadoop.hive.metastore.TableType.VIRTUAL_VIEW; import static org.assertj.core.api.Assertions.assertThat; @@ -266,8 +267,8 @@ private void createTransactionLog(String deltaLakeTableLocation) { File deltaTableLogLocation = new File(new File(new URI(deltaLakeTableLocation)), "_delta_log"); verify(deltaTableLogLocation.mkdirs(), "mkdirs() on '%s' failed", deltaTableLogLocation); - byte[] entry = Resources.toByteArray(Resources.getResource("deltalake/person/_delta_log/00000000000000000000.json")); - Files.write(new File(deltaTableLogLocation, "00000000000000000000.json").toPath(), entry); + String entry = Resources.toString(Resources.getResource("deltalake/person/_delta_log/00000000000000000000.json"), UTF_8); + Files.writeString(new File(deltaTableLogLocation, "00000000000000000000.json").toPath(), entry); } private String tableLocation(SchemaTableName tableName)