From 4e8e3ac6459847686627b6885b73a0ca3d46e2f9 Mon Sep 17 00:00:00 2001 From: Reetika Agrawal Date: Tue, 21 Jan 2025 01:49:46 +0530 Subject: [PATCH] Move HiveSchemaProperties class to presto-hive-metastore module --- .../presto/hive/SchemaProperties.java | 4 +- .../presto/hive/HiveConnectorFactory.java | 2 +- .../facebook/presto/hive/HiveMetadata.java | 2 +- .../presto/iceberg/IcebergHiveMetadata.java | 4 +- .../iceberg/IcebergSchemaProperties.java | 43 ------------------- .../InternalIcebergConnectorFactory.java | 3 +- 6 files changed, 8 insertions(+), 50 deletions(-) rename presto-hive/src/main/java/com/facebook/presto/hive/HiveSchemaProperties.java => presto-hive-metastore/src/main/java/com/facebook/presto/hive/SchemaProperties.java (94%) delete mode 100644 presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergSchemaProperties.java diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveSchemaProperties.java b/presto-hive-metastore/src/main/java/com/facebook/presto/hive/SchemaProperties.java similarity index 94% rename from presto-hive/src/main/java/com/facebook/presto/hive/HiveSchemaProperties.java rename to presto-hive-metastore/src/main/java/com/facebook/presto/hive/SchemaProperties.java index 12709fa0b234c..04152023a0bae 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveSchemaProperties.java +++ b/presto-hive-metastore/src/main/java/com/facebook/presto/hive/SchemaProperties.java @@ -22,7 +22,7 @@ import static com.facebook.presto.spi.session.PropertyMetadata.stringProperty; -public final class HiveSchemaProperties +public final class SchemaProperties { public static final String LOCATION_PROPERTY = "location"; @@ -33,7 +33,7 @@ public final class HiveSchemaProperties null, false)); - private HiveSchemaProperties() {} + private SchemaProperties() {} public static Optional getLocation(Map schemaProperties) { diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveConnectorFactory.java b/presto-hive/src/main/java/com/facebook/presto/hive/HiveConnectorFactory.java index c5357d0f1739a..eec08e2a792db 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveConnectorFactory.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HiveConnectorFactory.java @@ -175,7 +175,7 @@ public Connector create(String catalogName, Map config, Connecto ImmutableSet.of(), procedures, allSessionProperties, - HiveSchemaProperties.SCHEMA_PROPERTIES, + SchemaProperties.SCHEMA_PROPERTIES, hiveTableProperties.getTableProperties(), hiveAnalyzeProperties.getAnalyzeProperties(), accessControl, diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java index 3d3a0eacd4d44..3541b8ee04d5c 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java @@ -932,7 +932,7 @@ public TupleDomain toExplainIOConstraints(ConnectorSession session @Override public void createSchema(ConnectorSession session, String schemaName, Map properties) { - Optional location = HiveSchemaProperties.getLocation(properties).map(locationUri -> { + Optional location = SchemaProperties.getLocation(properties).map(locationUri -> { try { hdfsEnvironment.getFileSystem(new HdfsContext(session, schemaName), new Path(locationUri)); } diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java index 19d5e531abbb8..8cc86f5a3c8cf 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java @@ -92,6 +92,7 @@ import static com.facebook.presto.hive.HiveUtil.decodeViewData; import static com.facebook.presto.hive.HiveUtil.encodeViewData; import static com.facebook.presto.hive.HiveUtil.hiveColumnHandles; +import static com.facebook.presto.hive.SchemaProperties.getLocation; import static com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege.DELETE; import static com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege.INSERT; import static com.facebook.presto.hive.metastore.HivePrivilegeInfo.HivePrivilege.SELECT; @@ -106,7 +107,6 @@ import static com.facebook.presto.hive.metastore.Statistics.createComputedStatisticsToPartitionMap; import static com.facebook.presto.iceberg.HiveTableOperations.STORAGE_FORMAT; import static com.facebook.presto.iceberg.IcebergErrorCode.ICEBERG_INVALID_METADATA; -import static com.facebook.presto.iceberg.IcebergSchemaProperties.getSchemaLocation; import static com.facebook.presto.iceberg.IcebergSessionProperties.getCompressionCodec; import static com.facebook.presto.iceberg.IcebergSessionProperties.getHiveStatisticsMergeStrategy; import static com.facebook.presto.iceberg.IcebergTableProperties.getFileFormat; @@ -234,7 +234,7 @@ public List listTables(ConnectorSession session, Optional properties) { - Optional location = getSchemaLocation(properties).map(uri -> { + Optional location = getLocation(properties).map(uri -> { try { hdfsEnvironment.getFileSystem(new HdfsContext(session, schemaName), new Path(uri)); } diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergSchemaProperties.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergSchemaProperties.java deleted file mode 100644 index 979341b5ffbc9..0000000000000 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergSchemaProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.iceberg; - -import com.facebook.presto.spi.session.PropertyMetadata; -import com.google.common.collect.ImmutableList; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static com.facebook.presto.spi.session.PropertyMetadata.stringProperty; - -public final class IcebergSchemaProperties -{ - public static final String LOCATION_PROPERTY = "location"; - - public static final List> SCHEMA_PROPERTIES = ImmutableList.>builder() - .add(stringProperty( - LOCATION_PROPERTY, - "Base file system location URI", - null, - false)) - .build(); - - private IcebergSchemaProperties() {} - - public static Optional getSchemaLocation(Map schemaProperties) - { - return Optional.ofNullable((String) schemaProperties.get(LOCATION_PROPERTY)); - } -} diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/InternalIcebergConnectorFactory.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/InternalIcebergConnectorFactory.java index bab2cb74a63d3..f459717f1c22d 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/InternalIcebergConnectorFactory.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/InternalIcebergConnectorFactory.java @@ -23,6 +23,7 @@ import com.facebook.presto.hive.HiveCommonSessionProperties; import com.facebook.presto.hive.NodeVersion; import com.facebook.presto.hive.RebindSafeMBeanServer; +import com.facebook.presto.hive.SchemaProperties; import com.facebook.presto.hive.authentication.HiveAuthenticationModule; import com.facebook.presto.hive.gcs.HiveGcsModule; import com.facebook.presto.hive.metastore.ExtendedHiveMetastore; @@ -130,7 +131,7 @@ public static Connector createConnector( new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), ImmutableSet.of(), allSessionProperties, - IcebergSchemaProperties.SCHEMA_PROPERTIES, + SchemaProperties.SCHEMA_PROPERTIES, icebergTableProperties.getTableProperties(), icebergTableProperties.getColumnProperties(), new AllowAllAccessControl(),