Skip to content

Commit

Permalink
Move isIcebergTable to HiveUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelWeezardo authored and findepi committed Jun 24, 2021
1 parent 37813cd commit ea5d988
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
import static io.trino.plugin.hive.metastore.thrift.ThriftMetastoreUtil.updateStatisticsParameters;
import static io.trino.plugin.hive.util.HiveUtil.DELTA_LAKE_PROVIDER;
import static io.trino.plugin.hive.util.HiveUtil.SPARK_TABLE_PROVIDER_KEY;
import static io.trino.plugin.hive.util.HiveUtil.isIcebergTable;
import static io.trino.plugin.hive.util.HiveUtil.toPartitionValues;
import static io.trino.spi.StandardErrorCode.ALREADY_EXISTS;
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
Expand All @@ -134,8 +135,6 @@ public class FileHiveMetastore
private static final String TRINO_PERMISSIONS_DIRECTORY_NAME = ".trinoPermissions";
// todo there should be a way to manage the admins list
private static final Set<String> ADMIN_USERS = ImmutableSet.of("admin", "hive", "hdfs");
private static final String ICEBERG_TABLE_TYPE_NAME = "table_type";
private static final String ICEBERG_TABLE_TYPE_VALUE = "iceberg";

private final String currentVersion;
private final VersionCompatibility versionCompatibility;
Expand Down Expand Up @@ -557,7 +556,7 @@ public synchronized void renameTable(HiveIdentity identity, String databaseName,
Table table = getRequiredTable(databaseName, tableName);
getRequiredDatabase(newDatabaseName);

if (isIcebergTable(table.getParameters())) {
if (isIcebergTable(table)) {
throw new TrinoException(NOT_SUPPORTED, "Rename not supported for Iceberg tables");
}

Expand Down Expand Up @@ -1369,11 +1368,6 @@ private static boolean isChildDirectory(Path parentDirectory, Path childDirector
return isChildDirectory(parentDirectory, childDirectory.getParent());
}

private static boolean isIcebergTable(Map<String, String> parameters)
{
return ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(parameters.get(ICEBERG_TABLE_TYPE_NAME));
}

private static class RoleGranteeTuple
{
private final String role;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public final class HiveUtil
private static final String BIG_DECIMAL_POSTFIX = "BD";

private static final Splitter COLUMN_NAMES_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
private static final String ICEBERG_TABLE_TYPE_NAME = "table_type";
private static final String ICEBERG_TABLE_TYPE_VALUE = "iceberg";

static {
DateTimeParser[] timestampWithoutTimeZoneParser = {
Expand Down Expand Up @@ -1073,4 +1075,9 @@ public static boolean isDeltaLakeTable(Table table)
return table.getParameters().containsKey(SPARK_TABLE_PROVIDER_KEY)
&& table.getParameters().get(SPARK_TABLE_PROVIDER_KEY).toLowerCase(ENGLISH).equals(DELTA_LAKE_PROVIDER);
}

public static boolean isIcebergTable(Table table)
{
return ICEBERG_TABLE_TYPE_VALUE.equalsIgnoreCase(table.getParameters().get(ICEBERG_TABLE_TYPE_NAME));
}
}

0 comments on commit ea5d988

Please sign in to comment.