From 96f8e59009f343a11866a3c461ddd643933d8569 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Wed, 29 Mar 2023 19:16:23 +0900 Subject: [PATCH] Fix incorrect result when hidden directory exist in migrate procedure --- .../io/trino/plugin/iceberg/procedure/MigrateProcedure.java | 3 ++- .../io/trino/plugin/iceberg/TestIcebergMigrateProcedure.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/MigrateProcedure.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/MigrateProcedure.java index 129fe7e220e3..1a7f9a577d0e 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/MigrateProcedure.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/procedure/MigrateProcedure.java @@ -317,7 +317,8 @@ private List buildDataFiles(ConnectorSession session, RecursiveDirecto ImmutableList.Builder dataFilesBuilder = ImmutableList.builder(); while (files.hasNext()) { FileEntry file = files.next(); - if (file.location().contains("/_") || file.location().contains("/.")) { + String relativePath = file.location().substring(location.length()); + if (relativePath.contains("/_") || relativePath.contains("/.")) { continue; } if (recursive == RecursiveDirectory.FALSE && isRecursive(location, file.location())) { diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergMigrateProcedure.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergMigrateProcedure.java index 6dd83af21e3e..abbef53111f5 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergMigrateProcedure.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergMigrateProcedure.java @@ -41,8 +41,8 @@ public class TestIcebergMigrateProcedure protected QueryRunner createQueryRunner() throws Exception { - DistributedQueryRunner queryRunner = IcebergQueryRunner.builder().build(); - dataDirectory = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data"); + dataDirectory = Files.createTempDirectory("_test_hidden"); + DistributedQueryRunner queryRunner = IcebergQueryRunner.builder().setMetastoreDirectory(dataDirectory.toFile()).build(); queryRunner.installPlugin(new TestingHivePlugin()); queryRunner.createCatalog("hive", "hive", ImmutableMap.builder() .put("hive.metastore", "file")