From 0e489de17538910d142ef79aa8cce5206e1f5741 Mon Sep 17 00:00:00 2001 From: Reetika Agrawal Date: Mon, 4 Nov 2024 11:44:29 +0530 Subject: [PATCH] Remove unused code from Iceberg module --- .../iceberg/IcebergAbstractMetadata.java | 8 ++-- .../presto/iceberg/IcebergErrorCode.java | 3 +- .../presto/iceberg/IcebergWarningCode.java | 39 ------------------- .../facebook/presto/iceberg/Partition.java | 5 --- .../presto/iceberg/TableStatisticsMaker.java | 10 ++--- .../function/changelog/ChangelogRecord.java | 5 --- .../IcebergDistributedSmokeTestBase.java | 1 - .../presto/iceberg/IcebergQueryRunner.java | 1 - .../TestIcebergOrcMetricsCollection.java | 15 ------- ...IcebergRegisterAndUnregisterProcedure.java | 2 - 10 files changed, 9 insertions(+), 80 deletions(-) delete mode 100644 presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWarningCode.java diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java index f60e13abd2b04..42160eb4c4513 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java @@ -449,7 +449,7 @@ public void createTable(ConnectorSession session, ConnectorTableMetadata tableMe @Override public Optional finishCreateTable(ConnectorSession session, ConnectorOutputTableHandle tableHandle, Collection fragments, Collection computedStatistics) { - return finishWrite(session, (IcebergOutputTableHandle) tableHandle, fragments, computedStatistics); + return finishWrite((IcebergOutputTableHandle) tableHandle, fragments); } protected ConnectorInsertTableHandle beginIcebergTableInsert(ConnectorSession session, IcebergTableHandle table, Table icebergTable) @@ -471,10 +471,10 @@ protected ConnectorInsertTableHandle beginIcebergTableInsert(ConnectorSession se @Override public Optional finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection fragments, Collection computedStatistics) { - return finishWrite(session, (IcebergInsertTableHandle) insertHandle, fragments, computedStatistics); + return finishWrite((IcebergInsertTableHandle) insertHandle, fragments); } - private Optional finishWrite(ConnectorSession session, IcebergWritableTableHandle writableTableHandle, Collection fragments, Collection computedStatistics) + private Optional finishWrite(IcebergWritableTableHandle writableTableHandle, Collection fragments) { if (fragments.isEmpty()) { transaction.commitTransaction(); @@ -629,7 +629,7 @@ public void finishStatisticsCollection(ConnectorSession session, ConnectorTableH { IcebergTableHandle icebergTableHandle = (IcebergTableHandle) tableHandle; Table icebergTable = getIcebergTable(session, icebergTableHandle.getSchemaTableName()); - TableStatisticsMaker.writeTableStatistics(nodeVersion, typeManager, icebergTableHandle, icebergTable, session, computedStatistics); + TableStatisticsMaker.writeTableStatistics(nodeVersion, icebergTableHandle, icebergTable, session, computedStatistics); } public void rollback() diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergErrorCode.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergErrorCode.java index 3548ef24ba496..1f1e5fdf5146a 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergErrorCode.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergErrorCode.java @@ -38,8 +38,7 @@ public enum IcebergErrorCode ICEBERG_INVALID_TABLE_TIMESTAMP(12, USER_ERROR), ICEBERG_ROLLBACK_ERROR(13, EXTERNAL), ICEBERG_INVALID_FORMAT_VERSION(14, USER_ERROR), - ICEBERG_UNKNOWN_MANIFEST_TYPE(15, EXTERNAL), - ICEBERG_CACHE_WRITE_ERROR(16, INTERNAL_ERROR); + ICEBERG_UNKNOWN_MANIFEST_TYPE(15, EXTERNAL); private final ErrorCode errorCode; diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWarningCode.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWarningCode.java deleted file mode 100644 index 0ecdc01c56ede..0000000000000 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWarningCode.java +++ /dev/null @@ -1,39 +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.WarningCode; -import com.facebook.presto.spi.WarningCodeSupplier; - -public enum IcebergWarningCode - implements WarningCodeSupplier -{ - ICEBERG_TABLESCAN_CONVERTED_TO_VALUESNODE(1), - /**/; - - private final WarningCode warningCode; - - public static final int WARNING_CODE_MASK = 0x0100_0000; - - IcebergWarningCode(int code) - { - warningCode = new WarningCode(code + WARNING_CODE_MASK, name()); - } - - @Override - public WarningCode toWarningCode() - { - return warningCode; - } -} diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/Partition.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/Partition.java index cc15b3304d0a5..a4630e5e0bf15 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/Partition.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/Partition.java @@ -130,11 +130,6 @@ public Map getNullCounts() return nullCounts; } - public Map getColumnSizes() - { - return columnSizes; - } - public Set getCorruptedStats() { return corruptedStats; diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java index b86a7e9c87cb0..238eb09095f2e 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java @@ -116,17 +116,15 @@ public class TableStatisticsMaker private static final String ICEBERG_DATA_SIZE_BLOB_PROPERTY_KEY = "data_size"; private final Table icebergTable; private final ConnectorSession session; - private final TypeManager typeManager; private static final String STATISITCS_CACHE_METRIC_FILE_SIZE_FORMAT = "StatisticsFileCache/PuffinFileSize/%s/%s"; private static final String STATISITCS_CACHE_METRIC_FILE_COLUMN_COUNT_FORMAT = "StatisticsFileCache/ColumnCount/%s/%s"; private static final String STATISITCS_CACHE_METRIC_PARTIAL_MISS_FORMAT = "StatisticsFileCache/PartialMiss/%s/%s"; - private TableStatisticsMaker(Table icebergTable, ConnectorSession session, TypeManager typeManager) + private TableStatisticsMaker(Table icebergTable, ConnectorSession session) { this.icebergTable = icebergTable; this.session = session; - this.typeManager = typeManager; } private static final Map puffinStatWriters = ImmutableMap.builder() @@ -149,7 +147,7 @@ public static TableStatistics getTableStatistics( Table icebergTable, List columns) { - return new TableStatisticsMaker(icebergTable, session, typeManager).makeTableStatistics(statisticsFileCache, tableHandle, currentPredicate, constraint, columns); + return new TableStatisticsMaker(icebergTable, session).makeTableStatistics(statisticsFileCache, tableHandle, currentPredicate, constraint, columns); } private TableStatistics makeTableStatistics(StatisticsFileCache statisticsFileCache, @@ -312,9 +310,9 @@ private Partition getSummaryFromFiles(CloseableIterable> files, return summary; } - public static void writeTableStatistics(NodeVersion nodeVersion, TypeManager typeManager, IcebergTableHandle tableHandle, Table icebergTable, ConnectorSession session, Collection computedStatistics) + public static void writeTableStatistics(NodeVersion nodeVersion, IcebergTableHandle tableHandle, Table icebergTable, ConnectorSession session, Collection computedStatistics) { - new TableStatisticsMaker(icebergTable, session, typeManager).writeTableStatistics(nodeVersion, tableHandle, computedStatistics); + new TableStatisticsMaker(icebergTable, session).writeTableStatistics(nodeVersion, tableHandle, computedStatistics); } private void writeTableStatistics(NodeVersion nodeVersion, IcebergTableHandle tableHandle, Collection computedStatistics) diff --git a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/function/changelog/ChangelogRecord.java b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/function/changelog/ChangelogRecord.java index c9f71a5ec1dd2..2c28406ff9566 100644 --- a/presto-iceberg/src/main/java/com/facebook/presto/iceberg/function/changelog/ChangelogRecord.java +++ b/presto-iceberg/src/main/java/com/facebook/presto/iceberg/function/changelog/ChangelogRecord.java @@ -80,11 +80,6 @@ public Slice getLastOperation() return lastOperation; } - private int getLastOrdinal() - { - return lastOrdinal; - } - public ChangelogRecord merge(ChangelogRecord other) { if (other.lastOrdinal > lastOrdinal) { diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java index 513ba7f8ebecb..98bfef4aab872 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java @@ -640,7 +640,6 @@ public void testTableComments() public void testRollbackSnapshot() { Session session = getSession(); - MaterializedResult result = computeActual("SHOW SCHEMAS FROM system"); assertUpdate(session, "CREATE TABLE test_rollback AS SELECT * FROM (VALUES (123, CAST(321 AS BIGINT))) AS t (col0, col1)", 1); long afterCreateTableId = getLatestSnapshotId(); diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergQueryRunner.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergQueryRunner.java index f5621e76fd5c0..09a300011c643 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergQueryRunner.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergQueryRunner.java @@ -64,7 +64,6 @@ public final class IcebergQueryRunner public static final String ICEBERG_CATALOG = "iceberg"; public static final String TEST_DATA_DIRECTORY = "iceberg_data"; - public static final String TEST_CATALOG_DIRECTORY = "catalog"; public static final MetastoreContext METASTORE_CONTEXT = new MetastoreContext("test_user", "test_queryId", Optional.empty(), Collections.emptySet(), Optional.empty(), Optional.empty(), false, HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER, WarningCollector.NOOP, new RuntimeStats()); private IcebergQueryRunner() {} diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergOrcMetricsCollection.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergOrcMetricsCollection.java index 4d3bf26dd9a12..18c01897d75f5 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergOrcMetricsCollection.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergOrcMetricsCollection.java @@ -296,11 +296,6 @@ public int getContent() return content; } - public String getFilePath() - { - return filePath; - } - public String getFileFormat() { return fileFormat; @@ -311,16 +306,6 @@ public long getRecordCount() return recordCount; } - public long getFileSizeInBytes() - { - return fileSizeInBytes; - } - - public Map getColumnSizes() - { - return columnSizes; - } - public Map getValueCounts() { return valueCounts; diff --git a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/procedure/TestIcebergRegisterAndUnregisterProcedure.java b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/procedure/TestIcebergRegisterAndUnregisterProcedure.java index ae1148b6cd1a0..30bc013cf7604 100644 --- a/presto-iceberg/src/test/java/com/facebook/presto/iceberg/procedure/TestIcebergRegisterAndUnregisterProcedure.java +++ b/presto-iceberg/src/test/java/com/facebook/presto/iceberg/procedure/TestIcebergRegisterAndUnregisterProcedure.java @@ -66,8 +66,6 @@ public class TestIcebergRegisterAndUnregisterProcedure private Session session; public static final String ICEBERG_CATALOG = "iceberg"; - public static final String TEST_DATA_DIRECTORY = "iceberg_data"; - public static final String TEST_CATALOG_DIRECTORY = "catalog"; public static final String TEST_SCHEMA = "register"; public static final String TEST_TABLE_NAME = "iceberg_test";