From 3fbb7a66c17124359eb5bb392ac84066372a445f Mon Sep 17 00:00:00 2001 From: Konrad Dziedzic Date: Fri, 17 Mar 2023 10:49:43 +0100 Subject: [PATCH] Prevent Hive from returning table handles for Hudi table --- .../src/main/java/io/trino/plugin/hive/HiveMetadata.java | 3 +++ .../src/main/java/io/trino/plugin/hive/util/HiveUtil.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java index 9b85e946a786..b39428bcd7d2 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveMetadata.java @@ -499,6 +499,9 @@ public HiveTableHandle getTableHandle(ConnectorSession session, SchemaTableName if (isIcebergTable(table)) { throw new TrinoException(UNSUPPORTED_TABLE_TYPE, format("Cannot query Iceberg table '%s'", tableName)); } + if (isHudiTable(table)) { + throw new TrinoException(UNSUPPORTED_TABLE_TYPE, format("Cannot query Hudi table '%s'", tableName)); + } // we must not allow system tables due to how permissions are checked in SystemTableAwareAccessControl if (getSourceTableNameFromSystemTable(systemTableProviders, tableName).isPresent()) { diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/HiveUtil.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/HiveUtil.java index 3a158d19a1e7..78976db0f36c 100644 --- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/HiveUtil.java +++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/util/HiveUtil.java @@ -1142,7 +1142,8 @@ public static boolean isIcebergTable(Map tableParameters) public static boolean isHudiTable(Table table) { requireNonNull(table, "table is null"); - String inputFormat = table.getStorage().getStorageFormat().getInputFormat(); + @Nullable + String inputFormat = table.getStorage().getStorageFormat().getInputFormatNullable(); return HUDI_PARQUET_INPUT_FORMAT.equals(inputFormat) || HUDI_PARQUET_REALTIME_INPUT_FORMAT.equals(inputFormat) ||