diff --git a/core/trino-main/src/main/java/io/trino/connector/InternalMetadataProvider.java b/core/trino-main/src/main/java/io/trino/connector/InternalMetadataProvider.java index e579c22d9d90..6ff348d7ab6f 100644 --- a/core/trino-main/src/main/java/io/trino/connector/InternalMetadataProvider.java +++ b/core/trino-main/src/main/java/io/trino/connector/InternalMetadataProvider.java @@ -76,8 +76,8 @@ private List toColumnSchema(List viewColumns) return viewColumns.stream() .map(viewColumn -> ColumnSchema.builder() - .setName(viewColumn.getName()) - .setType(typeManager.getType(viewColumn.getType())) + .setName(viewColumn.name()) + .setType(typeManager.getType(viewColumn.type())) .build()) .collect(toImmutableList()); } diff --git a/core/trino-main/src/main/java/io/trino/connector/system/AbstractPropertiesSystemTable.java b/core/trino-main/src/main/java/io/trino/connector/system/AbstractPropertiesSystemTable.java index c4fec1df6b94..9e2f03a99ff3 100644 --- a/core/trino-main/src/main/java/io/trino/connector/system/AbstractPropertiesSystemTable.java +++ b/core/trino-main/src/main/java/io/trino/connector/system/AbstractPropertiesSystemTable.java @@ -83,15 +83,15 @@ public final RecordCursor cursor(ConnectorTransactionHandle transactionHandle, C InMemoryRecordSet.Builder table = InMemoryRecordSet.builder(tableMetadata); List catalogInfos = listCatalogs(session, metadata, accessControl).stream() - .sorted(Comparator.comparing(CatalogInfo::getCatalogName)) + .sorted(Comparator.comparing(CatalogInfo::catalogName)) .collect(toImmutableList()); for (CatalogInfo catalogInfo : catalogInfos) { - catalogProperties.apply(catalogInfo.getCatalogHandle()).stream() + catalogProperties.apply(catalogInfo.catalogHandle()).stream() .sorted(Comparator.comparing(PropertyMetadata::getName)) .forEach(propertyMetadata -> table.addRow( - catalogInfo.getCatalogName(), + catalogInfo.catalogName(), propertyMetadata.getName(), firstNonNull(propertyMetadata.getDefaultValue(), "").toString(), propertyMetadata.getSqlType().toString(), diff --git a/core/trino-main/src/main/java/io/trino/connector/system/CatalogSystemTable.java b/core/trino-main/src/main/java/io/trino/connector/system/CatalogSystemTable.java index 77406f8fbf47..69bcd6166913 100644 --- a/core/trino-main/src/main/java/io/trino/connector/system/CatalogSystemTable.java +++ b/core/trino-main/src/main/java/io/trino/connector/system/CatalogSystemTable.java @@ -74,9 +74,9 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect Builder table = InMemoryRecordSet.builder(CATALOG_TABLE); for (CatalogInfo catalogInfo : listCatalogs(session, metadata, accessControl)) { table.addRow( - catalogInfo.getCatalogName(), - catalogInfo.getCatalogName(), - catalogInfo.getConnectorName().toString()); + catalogInfo.catalogName(), + catalogInfo.catalogName(), + catalogInfo.connectorName().toString()); } return table.build().cursor(); } diff --git a/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java b/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java index 70a7725d892b..bff5e1e38c9b 100644 --- a/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/AddColumnTask.java @@ -96,7 +96,7 @@ public ListenableFuture execute( return immediateVoidFuture(); } TableHandle tableHandle = redirectionAwareTableHandle.tableHandle().get(); - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); QualifiedObjectName qualifiedTableName = redirectionAwareTableHandle.redirectedTableName().orElse(originalTableName); diff --git a/core/trino-main/src/main/java/io/trino/execution/CommentTask.java b/core/trino-main/src/main/java/io/trino/execution/CommentTask.java index 7b148d0cdc80..5b27b082d8a2 100644 --- a/core/trino-main/src/main/java/io/trino/execution/CommentTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/CommentTask.java @@ -145,12 +145,12 @@ private void commentOnColumn(Comment statement, Session session) if (view.isPresent()) { ViewDefinition viewDefinition = view.get(); ViewColumn viewColumn = findAndCheckViewColumn(statement, session, viewDefinition, originalObjectName); - metadata.setViewColumnComment(session, originalObjectName, viewColumn.getName(), statement.getComment()); + metadata.setViewColumnComment(session, originalObjectName, viewColumn.name(), statement.getComment()); } else if (metadata.isMaterializedView(session, originalObjectName)) { MaterializedViewDefinition materializedViewDefinition = metadata.getMaterializedView(session, originalObjectName).get(); ViewColumn viewColumn = findAndCheckViewColumn(statement, session, materializedViewDefinition, originalObjectName); - metadata.setMaterializedViewColumnComment(session, originalObjectName, viewColumn.getName(), statement.getComment()); + metadata.setMaterializedViewColumnComment(session, originalObjectName, viewColumn.name(), statement.getComment()); } else { RedirectionAwareTableHandle redirectionAwareTableHandle = metadata.getRedirectionAwareTableHandle(session, originalObjectName); @@ -175,7 +175,7 @@ private ViewColumn findAndCheckViewColumn(Comment statement, Session session, Vi { String columnName = statement.getName().getSuffix(); ViewColumn viewColumn = viewDefinition.getColumns().stream() - .filter(column -> column.getName().equals(columnName)) + .filter(column -> column.name().equals(columnName)) .findAny() .orElseThrow(() -> semanticException(COLUMN_NOT_FOUND, statement, "Column does not exist: %s", columnName)); accessControl.checkCanSetColumnComment(session.toSecurityContext(), originalObjectName); diff --git a/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java b/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java index 4e917aed3064..84a57f316fb8 100644 --- a/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java +++ b/core/trino-main/src/main/java/io/trino/execution/RenameTableTask.java @@ -107,7 +107,7 @@ public ListenableFuture execute( if (metadata.getTableHandle(session, target).isPresent()) { throw semanticException(TABLE_ALREADY_EXISTS, statement, "Target table '%s' already exists", target); } - if (!tableHandle.getCatalogHandle().getCatalogName().toString().equals(target.catalogName())) { + if (!tableHandle.catalogHandle().getCatalogName().toString().equals(target.catalogName())) { throw semanticException(NOT_SUPPORTED, statement, "Table rename across catalogs is not supported"); } accessControl.checkCanRenameTable(session.toSecurityContext(), source, target); diff --git a/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java b/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java index 492b90c13259..b25f8520f216 100644 --- a/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java +++ b/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java @@ -742,7 +742,7 @@ private boolean shouldWaitForMinWorkers(Statement statement) // Allow set session statements and queries on internal system connectors to run without waiting Collection tables = analysis.getTables(); return !tables.stream() - .map(TableHandle::getCatalogHandle) + .map(TableHandle::catalogHandle) .allMatch(catalogName -> catalogName.getType().isInternal()); } return true; diff --git a/core/trino-main/src/main/java/io/trino/execution/TableInfo.java b/core/trino-main/src/main/java/io/trino/execution/TableInfo.java index 1ff9278f02fc..edc4a61cd74a 100644 --- a/core/trino-main/src/main/java/io/trino/execution/TableInfo.java +++ b/core/trino-main/src/main/java/io/trino/execution/TableInfo.java @@ -88,8 +88,8 @@ private static TableInfo extract(Session session, Metadata metadata, TableScanNo CatalogSchemaTableName tableName = metadata.getTableName(session, node.getTable()); TableProperties tableProperties = metadata.getTableProperties(session, node.getTable()); Optional connectorName = metadata.listCatalogs(session).stream() - .filter(catalogInfo -> catalogInfo.getCatalogName().equals(tableName.getCatalogName())) - .map(CatalogInfo::getConnectorName) + .filter(catalogInfo -> catalogInfo.catalogName().equals(tableName.getCatalogName())) + .map(CatalogInfo::connectorName) .map(ConnectorName::toString) .findFirst(); QualifiedObjectName objectName = new QualifiedObjectName(tableName.getCatalogName(), tableName.getSchemaTableName().getSchemaName(), tableName.getSchemaTableName().getTableName()); diff --git a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/NoMemoryAwarePartitionMemoryEstimator.java b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/NoMemoryAwarePartitionMemoryEstimator.java index 429893b02acd..3931d8d671a4 100644 --- a/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/NoMemoryAwarePartitionMemoryEstimator.java +++ b/core/trino-main/src/main/java/io/trino/execution/scheduler/faulttolerant/NoMemoryAwarePartitionMemoryEstimator.java @@ -94,8 +94,8 @@ private boolean isNoMemoryFragment(PlanFragment fragment, Function new ConnectorMaterializedViewDefinition.Column(column.getName(), column.getType(), column.getComment())) + .map(column -> new ConnectorMaterializedViewDefinition.Column(column.name(), column.type(), column.comment())) .collect(toImmutableList()), getGracePeriod(), getComment(), diff --git a/core/trino-main/src/main/java/io/trino/metadata/MergeHandle.java b/core/trino-main/src/main/java/io/trino/metadata/MergeHandle.java index 39a598a59cd2..5a500a931872 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MergeHandle.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MergeHandle.java @@ -13,35 +13,15 @@ */ package io.trino.metadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.spi.connector.ConnectorMergeTableHandle; import static java.util.Objects.requireNonNull; -public final class MergeHandle +public record MergeHandle(TableHandle tableHandle, ConnectorMergeTableHandle connectorMergeHandle) { - private final TableHandle tableHandle; - private final ConnectorMergeTableHandle connectorMergeHandle; - - @JsonCreator - public MergeHandle( - @JsonProperty("tableHandle") TableHandle tableHandle, - @JsonProperty("connectorMergeHandle") ConnectorMergeTableHandle connectorMergeHandle) - { - this.tableHandle = requireNonNull(tableHandle, "tableHandle is null"); - this.connectorMergeHandle = requireNonNull(connectorMergeHandle, "connectorMergeHandle is null"); - } - - @JsonProperty - public TableHandle getTableHandle() - { - return tableHandle; - } - - @JsonProperty - public ConnectorMergeTableHandle getConnectorMergeHandle() + public MergeHandle { - return connectorMergeHandle; + requireNonNull(tableHandle, "tableHandle is null"); + requireNonNull(connectorMergeHandle, "connectorMergeHandle is null"); } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java index db9bb985a54e..c0a93f356601 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataListing.java @@ -66,7 +66,7 @@ public static SortedSet listCatalogNames(Session session, Metadata metad } else { catalogs = metadata.listCatalogs(session).stream() - .map(CatalogInfo::getCatalogName) + .map(CatalogInfo::catalogName) .filter(stringFilter(catalogDomain)) .collect(toImmutableSet()); } @@ -77,11 +77,11 @@ public static List listCatalogs(Session session, Metadata metadata, { List catalogs = metadata.listCatalogs(session); Set catalogNames = catalogs.stream() - .map(CatalogInfo::getCatalogName) + .map(CatalogInfo::catalogName) .collect(toImmutableSet()); Set allowedCatalogs = accessControl.filterCatalogs(session.toSecurityContext(), catalogNames); return catalogs.stream() - .filter(catalogInfo -> allowedCatalogs.contains(catalogInfo.getCatalogName())) + .filter(catalogInfo -> allowedCatalogs.contains(catalogInfo.catalogName())) .collect(toImmutableList()); } diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java index c04c8698d533..300f02821866 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java @@ -301,41 +301,41 @@ public Optional getTableHandleForExecute(Session session, Ta requireNonNull(procedure, "procedure is null"); requireNonNull(executeProperties, "executeProperties is null"); - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); Optional executeHandle = metadata.getTableHandleForExecute( session.toConnectorSession(catalogHandle), - tableHandle.getConnectorHandle(), + tableHandle.connectorHandle(), procedure, executeProperties, getRetryPolicy(session).getRetryMode()); return executeHandle.map(handle -> new TableExecuteHandle( catalogHandle, - tableHandle.getTransaction(), + tableHandle.transaction(), handle)); } @Override public Optional getLayoutForTableExecute(Session session, TableExecuteHandle tableExecuteHandle) { - CatalogHandle catalogHandle = tableExecuteHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableExecuteHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - return metadata.getLayoutForTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.getConnectorHandle()) + return metadata.getLayoutForTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.connectorHandle()) .map(layout -> new TableLayout(catalogHandle, catalogMetadata.getTransactionHandleFor(catalogHandle), layout)); } @Override public BeginTableExecuteResult beginTableExecute(Session session, TableExecuteHandle tableExecuteHandle, TableHandle sourceHandle) { - CatalogHandle catalogHandle = tableExecuteHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableExecuteHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - BeginTableExecuteResult connectorBeginResult = metadata.beginTableExecute(session.toConnectorSession(), tableExecuteHandle.getConnectorHandle(), sourceHandle.getConnectorHandle()); + BeginTableExecuteResult connectorBeginResult = metadata.beginTableExecute(session.toConnectorSession(), tableExecuteHandle.connectorHandle(), sourceHandle.connectorHandle()); return new BeginTableExecuteResult<>( tableExecuteHandle.withConnectorHandle(connectorBeginResult.getTableExecuteHandle()), @@ -345,17 +345,17 @@ public BeginTableExecuteResult beginTableExecut @Override public void finishTableExecute(Session session, TableExecuteHandle tableExecuteHandle, Collection fragments, List tableExecuteState) { - CatalogHandle catalogHandle = tableExecuteHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableExecuteHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - metadata.finishTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.getConnectorHandle(), fragments, tableExecuteState); + metadata.finishTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.connectorHandle(), fragments, tableExecuteState); } @Override public void executeTableExecute(Session session, TableExecuteHandle tableExecuteHandle) { - CatalogHandle catalogHandle = tableExecuteHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableExecuteHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - metadata.executeTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.getConnectorHandle()); + metadata.executeTableExecute(session.toConnectorSession(catalogHandle), tableExecuteHandle.connectorHandle()); } @Override @@ -380,12 +380,12 @@ public Optional getSystemTable(Session session, QualifiedObjectName @Override public TableProperties getTableProperties(Session session, TableHandle handle) { - CatalogHandle catalogHandle = handle.getCatalogHandle(); + CatalogHandle catalogHandle = handle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return new TableProperties(catalogHandle, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle())); + return new TableProperties(catalogHandle, handle.transaction(), metadata.getTableProperties(connectorSession, handle.connectorHandle())); } @Override @@ -393,14 +393,14 @@ public TableHandle makeCompatiblePartitioning(Session session, TableHandle table { checkArgument(partitioningHandle.getCatalogHandle().isPresent(), "Expect partitioning handle from connector, got system partitioning handle"); CatalogHandle catalogHandle = partitioningHandle.getCatalogHandle().get(); - checkArgument(catalogHandle.equals(tableHandle.getCatalogHandle()), "ConnectorId of tableHandle and partitioningHandle does not match"); + checkArgument(catalogHandle.equals(tableHandle.catalogHandle()), "ConnectorId of tableHandle and partitioningHandle does not match"); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(catalogHandle); ConnectorTableHandle newTableHandle = metadata.makeCompatiblePartitioning( session.toConnectorSession(catalogHandle), - tableHandle.getConnectorHandle(), + tableHandle.connectorHandle(), partitioningHandle.getConnectorHandle()); return new TableHandle(catalogHandle, newTableHandle, transaction); } @@ -426,19 +426,19 @@ public Optional getCommonPartitioning(Session session, Parti @Override public Optional getInfo(Session session, TableHandle handle) { - CatalogHandle catalogHandle = handle.getCatalogHandle(); + CatalogHandle catalogHandle = handle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - return metadata.getInfo(handle.getConnectorHandle()); + return metadata.getInfo(handle.connectorHandle()); } @Override public CatalogSchemaTableName getTableName(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); - SchemaTableName tableName = metadata.getTableName(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + SchemaTableName tableName = metadata.getTableName(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); return new CatalogSchemaTableName(catalogMetadata.getCatalogName().toString(), tableName); } @@ -446,10 +446,10 @@ public CatalogSchemaTableName getTableName(Session session, TableHandle tableHan @Override public TableSchema getTableSchema(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); - ConnectorTableSchema tableSchema = metadata.getTableSchema(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + ConnectorTableSchema tableSchema = metadata.getTableSchema(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); return new TableSchema(catalogMetadata.getCatalogName(), tableSchema); } @@ -457,10 +457,10 @@ public TableSchema getTableSchema(Session session, TableHandle tableHandle) @Override public TableMetadata getTableMetadata(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); - ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); return new TableMetadata(catalogMetadata.getCatalogName(), tableMetadata); } @@ -468,9 +468,9 @@ public TableMetadata getTableMetadata(Session session, TableHandle tableHandle) @Override public TableStatistics getTableStatistics(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - TableStatistics tableStatistics = metadata.getTableStatistics(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + TableStatistics tableStatistics = metadata.getTableStatistics(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); verifyNotNull(tableStatistics, "%s returned null tableStatistics for %s", metadata, tableHandle); return tableStatistics; } @@ -478,9 +478,9 @@ public TableStatistics getTableStatistics(Session session, TableHandle tableHand @Override public Map getColumnHandles(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - Map handles = metadata.getColumnHandles(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + Map handles = metadata.getColumnHandles(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); ImmutableMap.Builder map = ImmutableMap.builder(); for (Entry mapEntry : handles.entrySet()) { @@ -495,9 +495,9 @@ public ColumnMetadata getColumnMetadata(Session session, TableHandle tableHandle requireNonNull(tableHandle, "tableHandle is null"); requireNonNull(columnHandle, "columnHandle is null"); - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - return metadata.getColumnMetadata(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), columnHandle); + return metadata.getColumnMetadata(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), columnHandle); } @Override @@ -828,11 +828,11 @@ public void renameTable(Session session, TableHandle tableHandle, CatalogSchemaT String catalogName = newTableName.catalogName(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName); CatalogHandle catalogHandle = catalogMetadata.getCatalogHandle(); - if (!tableHandle.getCatalogHandle().equals(catalogHandle)) { + if (!tableHandle.catalogHandle().equals(catalogHandle)) { throw new TrinoException(SYNTAX_ERROR, "Cannot rename tables across catalogs"); } ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - metadata.renameTable(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), newTableName.asSchemaTableName()); + metadata.renameTable(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), newTableName.asSchemaTableName()); if (catalogMetadata.getSecurityManagement() != CONNECTOR) { systemSecurityMetadata.tableRenamed(session, sourceTableName, newTableName.asCatalogSchemaTableName()); } @@ -841,17 +841,17 @@ public void renameTable(Session session, TableHandle tableHandle, CatalogSchemaT @Override public void setTableProperties(Session session, TableHandle tableHandle, Map> properties) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.setTableProperties(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), properties); + metadata.setTableProperties(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), properties); } @Override public void setTableComment(Session session, TableHandle tableHandle, Optional comment) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.setTableComment(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), comment); + metadata.setTableComment(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), comment); } @Override @@ -875,18 +875,18 @@ public void setViewColumnComment(Session session, QualifiedObjectName viewName, @Override public void setColumnComment(Session session, TableHandle tableHandle, ColumnHandle column, Optional comment) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.setColumnComment(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column, comment); + metadata.setColumnComment(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column, comment); } @Override public void renameColumn(Session session, TableHandle tableHandle, CatalogSchemaTableName table, ColumnHandle source, String target) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle.getCatalogName().toString()); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.renameColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), source, target.toLowerCase(ENGLISH)); + metadata.renameColumn(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), source, target.toLowerCase(ENGLISH)); if (catalogMetadata.getSecurityManagement() == SYSTEM) { ColumnMetadata columnMetadata = getColumnMetadata(session, tableHandle, source); systemSecurityMetadata.columnRenamed(session, table, columnMetadata.getName(), target); @@ -896,18 +896,18 @@ public void renameColumn(Session session, TableHandle tableHandle, CatalogSchema @Override public void renameField(Session session, TableHandle tableHandle, List fieldPath, String target) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.renameField(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), fieldPath, target.toLowerCase(ENGLISH)); + metadata.renameField(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), fieldPath, target.toLowerCase(ENGLISH)); } @Override public void addColumn(Session session, TableHandle tableHandle, CatalogSchemaTableName table, ColumnMetadata column) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle.getCatalogName().toString()); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.addColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column); + metadata.addColumn(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column); if (catalogMetadata.getSecurityManagement() == SYSTEM) { systemSecurityMetadata.columnCreated(session, table, column.getName()); } @@ -916,18 +916,18 @@ public void addColumn(Session session, TableHandle tableHandle, CatalogSchemaTab @Override public void addField(Session session, TableHandle tableHandle, List parentPath, String fieldName, Type type, boolean ignoreExisting) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.addField(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), parentPath, fieldName, type, ignoreExisting); + metadata.addField(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), parentPath, fieldName, type, ignoreExisting); } @Override public void dropColumn(Session session, TableHandle tableHandle, CatalogSchemaTableName table, ColumnHandle column) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle.getCatalogName().toString()); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.dropColumn(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column); + metadata.dropColumn(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column); if (catalogMetadata.getSecurityManagement() == SYSTEM) { ColumnMetadata columnMetadata = getColumnMetadata(session, tableHandle, column); systemSecurityMetadata.columnDropped(session, table, columnMetadata.getName()); @@ -937,19 +937,19 @@ public void dropColumn(Session session, TableHandle tableHandle, CatalogSchemaTa @Override public void dropField(Session session, TableHandle tableHandle, ColumnHandle column, List fieldPath) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.dropField(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column, fieldPath); + metadata.dropField(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column, fieldPath); } @Override public void setColumnType(Session session, TableHandle tableHandle, ColumnHandle column, Type type) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle.getCatalogName().toString()); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); ColumnMetadata columnMetadata = getColumnMetadata(session, tableHandle, column); - metadata.setColumnType(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column, type); + metadata.setColumnType(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column, type); if (catalogMetadata.getSecurityManagement() == SYSTEM) { systemSecurityMetadata.columnTypeChanged( session, @@ -963,20 +963,20 @@ public void setColumnType(Session session, TableHandle tableHandle, ColumnHandle @Override public void setFieldType(Session session, TableHandle tableHandle, List fieldPath, Type type) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.setFieldType(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), fieldPath, type); + metadata.setFieldType(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), fieldPath, type); } @Override public void dropNotNullConstraint(Session session, TableHandle tableHandle, ColumnHandle column) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ColumnMetadata columnMetadata = getColumnMetadata(session, tableHandle, column); - metadata.dropNotNullConstraint(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), column); + metadata.dropNotNullConstraint(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), column); if (catalogMetadata.getSecurityManagement() == SYSTEM) { systemSecurityMetadata.columnNotNullConstraintDropped( session, @@ -1001,10 +1001,10 @@ public void setTableAuthorization(Session session, CatalogSchemaTableName table, @Override public void dropTable(Session session, TableHandle tableHandle, CatalogSchemaTableName tableName) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - metadata.dropTable(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + metadata.dropTable(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); if (catalogMetadata.getSecurityManagement() != CONNECTOR) { systemSecurityMetadata.tableDropped(session, tableName); } @@ -1013,19 +1013,19 @@ public void dropTable(Session session, TableHandle tableHandle, CatalogSchemaTab @Override public void truncateTable(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - metadata.truncateTable(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + metadata.truncateTable(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); } @Override public Optional getInsertLayout(Session session, TableHandle table) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - return metadata.getInsertLayout(session.toConnectorSession(catalogHandle), table.getConnectorHandle()) + return metadata.getInsertLayout(session.toConnectorSession(catalogHandle), table.connectorHandle()) .map(layout -> new TableLayout(catalogHandle, catalogMetadata.getTransactionHandleFor(catalogHandle), layout)); } @@ -1040,32 +1040,32 @@ public TableStatisticsMetadata getStatisticsCollectionMetadataForWrite(Session s @Override public AnalyzeMetadata getStatisticsCollectionMetadata(Session session, TableHandle tableHandle, Map analyzeProperties) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - ConnectorAnalyzeMetadata analyze = metadata.getStatisticsCollectionMetadata(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), analyzeProperties); - return new AnalyzeMetadata(analyze.getStatisticsMetadata(), new TableHandle(catalogHandle, analyze.getTableHandle(), tableHandle.getTransaction())); + ConnectorAnalyzeMetadata analyze = metadata.getStatisticsCollectionMetadata(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), analyzeProperties); + return new AnalyzeMetadata(analyze.getStatisticsMetadata(), new TableHandle(catalogHandle, analyze.getTableHandle(), tableHandle.transaction())); } @Override public AnalyzeTableHandle beginStatisticsCollection(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogHandle); - ConnectorTableHandle connectorTableHandle = metadata.beginStatisticsCollection(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + ConnectorTableHandle connectorTableHandle = metadata.beginStatisticsCollection(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); return new AnalyzeTableHandle(catalogHandle, transactionHandle, connectorTableHandle); } @Override public void finishStatisticsCollection(Session session, AnalyzeTableHandle tableHandle, Collection computedStatistics) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); - catalogMetadata.getMetadata(session).finishStatisticsCollection(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), computedStatistics); + catalogMetadata.getMetadata(session).finishStatisticsCollection(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), computedStatistics); } @Override @@ -1127,13 +1127,13 @@ public OutputTableHandle beginCreateTable(Session session, String catalogName, C @Override public Optional finishCreateTable(Session session, OutputTableHandle tableHandle, Collection fragments, Collection computedStatistics) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); - Optional output = metadata.finishCreateTable(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), fragments, computedStatistics); + Optional output = metadata.finishCreateTable(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), fragments, computedStatistics); if (catalogMetadata.getSecurityManagement() == SYSTEM) { - systemSecurityMetadata.tableCreated(session, new CatalogSchemaTableName(catalogHandle.getCatalogName().toString(), tableHandle.getTableName())); + systemSecurityMetadata.tableCreated(session, new CatalogSchemaTableName(catalogHandle.getCatalogName().toString(), tableHandle.tableName())); } return output; } @@ -1141,18 +1141,18 @@ public Optional finishCreateTable(Session session, Outp @Override public InsertTableHandle beginInsert(Session session, TableHandle tableHandle, List columns) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogHandle); - ConnectorInsertTableHandle handle = metadata.beginInsert(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), columns, getRetryPolicy(session).getRetryMode()); - return new InsertTableHandle(tableHandle.getCatalogHandle(), transactionHandle, handle); + ConnectorInsertTableHandle handle = metadata.beginInsert(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), columns, getRetryPolicy(session).getRetryMode()); + return new InsertTableHandle(tableHandle.catalogHandle(), transactionHandle, handle); } @Override public boolean supportsMissingColumnsOnInsert(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); return catalogMetadata.getMetadata(session).supportsMissingColumnsOnInsert(); } @@ -1160,13 +1160,13 @@ public boolean supportsMissingColumnsOnInsert(Session session, TableHandle table @Override public Optional finishInsert(Session session, InsertTableHandle tableHandle, List sourceTableHandles, Collection fragments, Collection computedStatistics) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); List sourceConnectorHandles = sourceTableHandles.stream() - .filter(handle -> handle.getCatalogHandle().equals(catalogHandle)) - .map(TableHandle::getConnectorHandle) + .filter(handle -> handle.catalogHandle().equals(catalogHandle)) + .map(TableHandle::connectorHandle) .collect(toImmutableList()); - return metadata.finishInsert(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), sourceConnectorHandles, fragments, computedStatistics); + return metadata.finishInsert(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), sourceConnectorHandles, fragments, computedStatistics); } @Override @@ -1195,19 +1195,19 @@ private static ListenableFuture asVoid(ListenableFuture future) @Override public InsertTableHandle beginRefreshMaterializedView(Session session, TableHandle tableHandle, List sourceTableHandles) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogHandle); List sourceConnectorHandles = sourceTableHandles.stream() - .map(TableHandle::getConnectorHandle) + .map(TableHandle::connectorHandle) .collect(Collectors.toList()); - sourceConnectorHandles.add(tableHandle.getConnectorHandle()); + sourceConnectorHandles.add(tableHandle.connectorHandle()); - ConnectorInsertTableHandle handle = metadata.beginRefreshMaterializedView(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), sourceConnectorHandles, getRetryPolicy(session).getRetryMode()); + ConnectorInsertTableHandle handle = metadata.beginRefreshMaterializedView(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), sourceConnectorHandles, getRetryPolicy(session).getRetryMode()); - return new InsertTableHandle(tableHandle.getCatalogHandle(), transactionHandle, handle); + return new InsertTableHandle(tableHandle.catalogHandle(), transactionHandle, handle); } @Override @@ -1220,16 +1220,16 @@ public Optional finishRefreshMaterializedView( List sourceTableHandles, List sourceTableFunctions) { - CatalogHandle catalogHandle = insertHandle.getCatalogHandle(); + CatalogHandle catalogHandle = insertHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); List sourceConnectorHandles = sourceTableHandles.stream() - .map(TableHandle::getConnectorHandle) + .map(TableHandle::connectorHandle) .collect(toImmutableList()); return metadata.finishRefreshMaterializedView( session.toConnectorSession(catalogHandle), - tableHandle.getConnectorHandle(), - insertHandle.getConnectorHandle(), + tableHandle.connectorHandle(), + insertHandle.connectorHandle(), fragments, computedStatistics, sourceConnectorHandles, @@ -1239,88 +1239,88 @@ public Optional finishRefreshMaterializedView( @Override public ColumnHandle getMergeRowIdColumnHandle(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - return metadata.getMergeRowIdColumnHandle(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + return metadata.getMergeRowIdColumnHandle(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); } @Override public Optional getUpdateLayout(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadata(session); ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogHandle); - return metadata.getUpdateLayout(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()) + return metadata.getUpdateLayout(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()) .map(partitioning -> new PartitioningHandle(Optional.of(catalogHandle), Optional.of(transactionHandle), partitioning)); } @Override public Optional applyUpdate(Session session, TableHandle table, Map assignments) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyUpdate(connectorSession, table.getConnectorHandle(), assignments) - .map(newHandle -> new TableHandle(catalogHandle, newHandle, table.getTransaction())); + return metadata.applyUpdate(connectorSession, table.connectorHandle(), assignments) + .map(newHandle -> new TableHandle(catalogHandle, newHandle, table.transaction())); } @Override public OptionalLong executeUpdate(Session session, TableHandle table) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.executeUpdate(connectorSession, table.getConnectorHandle()); + return metadata.executeUpdate(connectorSession, table.connectorHandle()); } @Override public Optional applyDelete(Session session, TableHandle table) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyDelete(connectorSession, table.getConnectorHandle()) - .map(newHandle -> new TableHandle(catalogHandle, newHandle, table.getTransaction())); + return metadata.applyDelete(connectorSession, table.connectorHandle()) + .map(newHandle -> new TableHandle(catalogHandle, newHandle, table.transaction())); } @Override public OptionalLong executeDelete(Session session, TableHandle table) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.executeDelete(connectorSession, table.getConnectorHandle()); + return metadata.executeDelete(connectorSession, table.connectorHandle()); } @Override public RowChangeParadigm getRowChangeParadigm(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - return metadata.getRowChangeParadigm(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle()); + return metadata.getRowChangeParadigm(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle()); } @Override public MergeHandle beginMerge(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); ConnectorMetadata metadata = getMetadataForWrite(session, catalogHandle); - ConnectorMergeTableHandle newHandle = metadata.beginMerge(session.toConnectorSession(catalogHandle), tableHandle.getConnectorHandle(), getRetryPolicy(session).getRetryMode()); + ConnectorMergeTableHandle newHandle = metadata.beginMerge(session.toConnectorSession(catalogHandle), tableHandle.connectorHandle(), getRetryPolicy(session).getRetryMode()); return new MergeHandle(tableHandle.withConnectorHandle(newHandle.getTableHandle()), newHandle); } @Override public void finishMerge(Session session, MergeHandle mergeHandle, Collection fragments, Collection computedStatistics) { - CatalogHandle catalogHandle = mergeHandle.getTableHandle().getCatalogHandle(); + CatalogHandle catalogHandle = mergeHandle.tableHandle().catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - metadata.finishMerge(session.toConnectorSession(catalogHandle), mergeHandle.getConnectorMergeHandle(), fragments, computedStatistics); + metadata.finishMerge(session.toConnectorSession(catalogHandle), mergeHandle.connectorMergeHandle(), fragments, computedStatistics); } @Override @@ -1835,11 +1835,11 @@ private static boolean isExternalInformationSchema(CatalogHandle catalogHandle, @Override public Optional applyTableScanRedirect(Session session, TableHandle tableHandle) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyTableScanRedirect(connectorSession, tableHandle.getConnectorHandle()); + return metadata.applyTableScanRedirect(connectorSession, tableHandle.connectorHandle()); } private QualifiedObjectName getRedirectedTableName(Session session, QualifiedObjectName originalTableName) @@ -1919,25 +1919,25 @@ public RedirectionAwareTableHandle getRedirectionAwareTableHandle(Session sessio @Override public Optional resolveIndex(Session session, TableHandle tableHandle, Set indexableColumns, Set outputColumns, TupleDomain tupleDomain) { - CatalogHandle catalogHandle = tableHandle.getCatalogHandle(); + CatalogHandle catalogHandle = tableHandle.catalogHandle(); CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogHandle); ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogHandle); ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - Optional resolvedIndex = metadata.resolveIndex(connectorSession, tableHandle.getConnectorHandle(), indexableColumns, outputColumns, tupleDomain); - return resolvedIndex.map(resolved -> new ResolvedIndex(tableHandle.getCatalogHandle(), transaction, resolved)); + Optional resolvedIndex = metadata.resolveIndex(connectorSession, tableHandle.connectorHandle(), indexableColumns, outputColumns, tupleDomain); + return resolvedIndex.map(resolved -> new ResolvedIndex(tableHandle.catalogHandle(), transaction, resolved)); } @Override public Optional> applyLimit(Session session, TableHandle table, long limit) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyLimit(connectorSession, table.getConnectorHandle(), limit) + return metadata.applyLimit(connectorSession, table.connectorHandle(), limit) .map(result -> new LimitApplicationResult<>( - new TableHandle(catalogHandle, result.getHandle(), table.getTransaction()), + new TableHandle(catalogHandle, result.getHandle(), table.transaction()), result.isLimitGuaranteed(), result.isPrecalculateStatistics())); } @@ -1945,15 +1945,15 @@ public Optional> applyLimit(Session session, @Override public Optional> applySample(Session session, TableHandle table, SampleType sampleType, double sampleRatio) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applySample(connectorSession, table.getConnectorHandle(), sampleType, sampleRatio) + return metadata.applySample(connectorSession, table.connectorHandle(), sampleType, sampleRatio) .map(result -> new SampleApplicationResult<>(new TableHandle( catalogHandle, result.getHandle(), - table.getTransaction()), + table.transaction()), result.isPrecalculateStatistics())); } @@ -1968,16 +1968,16 @@ public Optional> applyAggregation( // Global aggregation is represented by [[]] checkArgument(!groupingSets.isEmpty(), "No grouping sets provided"); - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyAggregation(connectorSession, table.getConnectorHandle(), aggregations, assignments, groupingSets) + return metadata.applyAggregation(connectorSession, table.connectorHandle(), aggregations, assignments, groupingSets) .map(result -> { verifyProjection(table, result.getProjections(), result.getAssignments(), aggregations.size()); return new AggregationApplicationResult<>( - new TableHandle(catalogHandle, result.getHandle(), table.getTransaction()), + new TableHandle(catalogHandle, result.getHandle(), table.transaction()), result.getProjections(), result.getAssignments(), result.getGroupingColumnMapping(), @@ -1996,13 +1996,13 @@ public Optional> applyJoin( Map rightAssignments, JoinStatistics statistics) { - if (!right.getCatalogHandle().equals(left.getCatalogHandle())) { + if (!right.catalogHandle().equals(left.catalogHandle())) { // Exact comparison is fine as catalog name here is passed from CatalogMetadata and is normalized to lowercase return Optional.empty(); } - CatalogHandle catalogHandle = left.getCatalogHandle(); + CatalogHandle catalogHandle = left.catalogHandle(); - ConnectorTransactionHandle transaction = left.getTransaction(); + ConnectorTransactionHandle transaction = left.transaction(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); @@ -2010,8 +2010,8 @@ public Optional> applyJoin( metadata.applyJoin( connectorSession, joinType, - left.getConnectorHandle(), - right.getConnectorHandle(), + left.connectorHandle(), + right.connectorHandle(), joinCondition, leftAssignments, rightAssignments, @@ -2054,13 +2054,13 @@ public Optional> applyTopN( List sortItems, Map assignments) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyTopN(connectorSession, table.getConnectorHandle(), topNCount, sortItems, assignments) + return metadata.applyTopN(connectorSession, table.connectorHandle(), topNCount, sortItems, assignments) .map(result -> new TopNApplicationResult<>( - new TableHandle(catalogHandle, result.getHandle(), table.getTransaction()), + new TableHandle(catalogHandle, result.getHandle(), table.transaction()), result.isTopNGuaranteed(), result.isPrecalculateStatistics())); } @@ -2068,12 +2068,12 @@ public Optional> applyTopN( @Override public Optional> applyTableFunction(Session session, TableFunctionHandle handle) { - CatalogHandle catalogHandle = handle.getCatalogHandle(); + CatalogHandle catalogHandle = handle.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - return metadata.applyTableFunction(session.toConnectorSession(catalogHandle), handle.getFunctionHandle()) + return metadata.applyTableFunction(session.toConnectorSession(catalogHandle), handle.functionHandle()) .map(result -> new TableFunctionApplicationResult<>( - new TableHandle(catalogHandle, result.getTableHandle(), handle.getTransactionHandle()), + new TableHandle(catalogHandle, result.getTableHandle(), handle.transactionHandle()), result.getColumnHandles())); } @@ -2103,35 +2103,35 @@ private void verifyProjection(TableHandle table, List proje @Override public void validateScan(Session session, TableHandle table) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); - metadata.validateScan(session.toConnectorSession(catalogHandle), table.getConnectorHandle()); + metadata.validateScan(session.toConnectorSession(catalogHandle), table.connectorHandle()); } @Override public Optional> applyFilter(Session session, TableHandle table, Constraint constraint) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyFilter(connectorSession, table.getConnectorHandle(), constraint) - .map(result -> result.transform(handle -> new TableHandle(catalogHandle, handle, table.getTransaction()))); + return metadata.applyFilter(connectorSession, table.connectorHandle(), constraint) + .map(result -> result.transform(handle -> new TableHandle(catalogHandle, handle, table.transaction()))); } @Override public Optional> applyProjection(Session session, TableHandle table, List projections, Map assignments) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorMetadata metadata = getMetadata(session, catalogHandle); ConnectorSession connectorSession = session.toConnectorSession(catalogHandle); - return metadata.applyProjection(connectorSession, table.getConnectorHandle(), projections, assignments) + return metadata.applyProjection(connectorSession, table.connectorHandle(), projections, assignments) .map(result -> { verifyProjection(table, result.getProjections(), result.getAssignments(), projections.size()); return new ProjectionApplicationResult<>( - new TableHandle(catalogHandle, result.getHandle(), table.getTransaction()), + new TableHandle(catalogHandle, result.getHandle(), table.transaction()), result.getProjections(), result.getAssignments(), result.isPrecalculateStatistics()); @@ -2755,15 +2755,15 @@ public WriterScalingOptions getNewTableWriterScalingOptions(Session session, Qua @Override public WriterScalingOptions getInsertWriterScalingOptions(Session session, TableHandle tableHandle) { - ConnectorMetadata metadata = getMetadataForWrite(session, tableHandle.getCatalogHandle()); - return metadata.getInsertWriterScalingOptions(session.toConnectorSession(tableHandle.getCatalogHandle()), tableHandle.getConnectorHandle()); + ConnectorMetadata metadata = getMetadataForWrite(session, tableHandle.catalogHandle()); + return metadata.getInsertWriterScalingOptions(session.toConnectorSession(tableHandle.catalogHandle()), tableHandle.connectorHandle()); } private Optional toConnectorVersion(Optional version) { Optional connectorVersion = Optional.empty(); if (version.isPresent()) { - connectorVersion = Optional.of(new ConnectorTableVersion(version.get().getPointerType(), version.get().getObjectType(), version.get().getPointer())); + connectorVersion = Optional.of(new ConnectorTableVersion(version.get().pointerType(), version.get().objectType(), version.get().pointer())); } return connectorVersion; } diff --git a/core/trino-main/src/main/java/io/trino/metadata/OutputTableHandle.java b/core/trino-main/src/main/java/io/trino/metadata/OutputTableHandle.java index 80ace4d4f5ce..45d132c327bc 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/OutputTableHandle.java +++ b/core/trino-main/src/main/java/io/trino/metadata/OutputTableHandle.java @@ -13,80 +13,25 @@ */ package io.trino.metadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.spi.connector.CatalogHandle; import io.trino.spi.connector.ConnectorOutputTableHandle; import io.trino.spi.connector.ConnectorTransactionHandle; import io.trino.spi.connector.SchemaTableName; -import java.util.Objects; - import static java.util.Objects.requireNonNull; -public final class OutputTableHandle +public record OutputTableHandle( + CatalogHandle catalogHandle, + SchemaTableName tableName, + ConnectorTransactionHandle transactionHandle, + ConnectorOutputTableHandle connectorHandle) { - private final CatalogHandle catalogHandle; - private final SchemaTableName tableName; - private final ConnectorTransactionHandle transactionHandle; - private final ConnectorOutputTableHandle connectorHandle; - - @JsonCreator - public OutputTableHandle( - @JsonProperty("catalogHandle") CatalogHandle catalogHandle, - @JsonProperty("tableName") SchemaTableName tableName, - @JsonProperty("transactionHandle") ConnectorTransactionHandle transactionHandle, - @JsonProperty("connectorHandle") ConnectorOutputTableHandle connectorHandle) - { - this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null"); - this.tableName = requireNonNull(tableName, "tableName is null"); - this.transactionHandle = requireNonNull(transactionHandle, "transactionHandle is null"); - this.connectorHandle = requireNonNull(connectorHandle, "connectorHandle is null"); - } - - @JsonProperty - public CatalogHandle getCatalogHandle() - { - return catalogHandle; - } - - @JsonProperty - public SchemaTableName getTableName() - { - return tableName; - } - - @JsonProperty - public ConnectorTransactionHandle getTransactionHandle() - { - return transactionHandle; - } - - @JsonProperty - public ConnectorOutputTableHandle getConnectorHandle() - { - return connectorHandle; - } - - @Override - public int hashCode() - { - return Objects.hash(catalogHandle, transactionHandle, connectorHandle); - } - - @Override - public boolean equals(Object obj) + public OutputTableHandle { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - OutputTableHandle other = (OutputTableHandle) obj; - return Objects.equals(this.catalogHandle, other.catalogHandle) && - Objects.equals(this.transactionHandle, other.transactionHandle) && - Objects.equals(this.connectorHandle, other.connectorHandle); + requireNonNull(catalogHandle, "catalogHandle is null"); + requireNonNull(tableName, "tableName is null"); + requireNonNull(transactionHandle, "transactionHandle is null"); + requireNonNull(connectorHandle, "connectorHandle is null"); } @Override diff --git a/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunction.java b/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunction.java index ad0674064d7c..85eb4cf676fa 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunction.java +++ b/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunction.java @@ -72,11 +72,11 @@ private ScalarImplementationChoice getScalarFunctionImplementationChoice( Optional matchingMethod = Optional.empty(); Optional matchingMethodsGroup = Optional.empty(); - for (MethodsGroup candidateMethodsGroup : choice.getMethodsGroups()) { + for (MethodsGroup candidateMethodsGroup : choice.methodsGroups()) { for (MethodAndNativeContainerTypes candidateMethod : candidateMethodsGroup.getMethods()) { - if (matchesParameterAndReturnTypes(candidateMethod, functionBinding.getBoundSignature(), choice.getArgumentConventions(), choice.getReturnConvention())) { + if (matchesParameterAndReturnTypes(candidateMethod, functionBinding.getBoundSignature(), choice.argumentConventions(), choice.returnConvention())) { if (matchingMethod.isPresent()) { - throw new IllegalStateException("two matching methods (" + matchingMethod.get().getMethod().getName() + " and " + candidateMethod.getMethod().getName() + ") for parameter types " + functionBinding.getBoundSignature().getArgumentTypes()); + throw new IllegalStateException("two matching methods (" + matchingMethod.get().method().getName() + " and " + candidateMethod.method().getName() + ") for parameter types " + functionBinding.getBoundSignature().getArgumentTypes()); } matchingMethod = Optional.of(candidateMethod); @@ -87,10 +87,10 @@ private ScalarImplementationChoice getScalarFunctionImplementationChoice( checkState(matchingMethod.isPresent(), "no matching method for parameter types %s", functionBinding.getBoundSignature()); List extraParameters = computeExtraParameters(matchingMethodsGroup.get(), context); - MethodHandle methodHandle = applyExtraParameters(matchingMethod.get().getMethod(), extraParameters, choice.getArgumentConventions()); + MethodHandle methodHandle = applyExtraParameters(matchingMethod.get().method(), extraParameters, choice.argumentConventions()); return new ScalarImplementationChoice( - choice.getReturnConvention(), - choice.getArgumentConventions(), + choice.returnConvention(), + choice.argumentConventions(), ImmutableList.of(), methodHandle, Optional.empty()); @@ -102,7 +102,7 @@ private static boolean matchesParameterAndReturnTypes( List argumentConventions, InvocationReturnConvention returnConvention) { - Method method = methodAndNativeContainerTypes.getMethod(); + Method method = methodAndNativeContainerTypes.method(); checkState(method.getParameterCount() >= boundSignature.getArity(), "method %s has not enough arguments: %s (should have at least %s)", method.getName(), method.getParameterCount(), boundSignature.getArity()); @@ -125,7 +125,7 @@ private static boolean matchesParameterAndReturnTypes( actualType = Primitives.wrap(resolvedType.getJavaType()); break; case BLOCK_POSITION: - Optional> explicitNativeContainerTypes = methodAndNativeContainerTypes.getExplicitNativeContainerTypes().get(i); + Optional> explicitNativeContainerTypes = methodAndNativeContainerTypes.explicitNativeContainerTypes().get(i); if (explicitNativeContainerTypes.isPresent()) { expectedType = explicitNativeContainerTypes.get(); } @@ -181,35 +181,16 @@ private static Class getNullAwareContainerType(Class clazz, InvocationRetu }; } - static final class PolymorphicScalarFunctionChoice + record PolymorphicScalarFunctionChoice( + InvocationReturnConvention returnConvention, + List argumentConventions, + List methodsGroups) { - private final InvocationReturnConvention returnConvention; - private final List argumentConventions; - private final List methodsGroups; - - PolymorphicScalarFunctionChoice( - InvocationReturnConvention returnConvention, - List argumentConventions, - List methodsGroups) - { - this.returnConvention = requireNonNull(returnConvention, "returnConvention is null"); - this.argumentConventions = ImmutableList.copyOf(requireNonNull(argumentConventions, "argumentConventions is null")); - this.methodsGroups = ImmutableList.copyOf(requireNonNull(methodsGroups, "methodsGroups is null")); - } - - InvocationReturnConvention getReturnConvention() - { - return returnConvention; - } - - List getMethodsGroups() - { - return methodsGroups; - } - - List getArgumentConventions() + PolymorphicScalarFunctionChoice { - return argumentConventions; + requireNonNull(returnConvention, "returnConvention is null"); + argumentConventions = ImmutableList.copyOf(requireNonNull(argumentConventions, "argumentConventions is null")); + methodsGroups = ImmutableList.copyOf(requireNonNull(methodsGroups, "methodsGroups is null")); } } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunctionBuilder.java b/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunctionBuilder.java index 972c5d8235ef..eadebdb42001 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunctionBuilder.java +++ b/core/trino-main/src/main/java/io/trino/metadata/PolymorphicScalarFunctionBuilder.java @@ -341,25 +341,5 @@ Optional>> getExtraParametersFunction() } } - static class MethodAndNativeContainerTypes - { - private final Method method; - private final List>> explicitNativeContainerTypes; - - MethodAndNativeContainerTypes(Method method, List>> explicitNativeContainerTypes) - { - this.method = method; - this.explicitNativeContainerTypes = explicitNativeContainerTypes; - } - - public Method getMethod() - { - return method; - } - - List>> getExplicitNativeContainerTypes() - { - return explicitNativeContainerTypes; - } - } + record MethodAndNativeContainerTypes(Method method, List>> explicitNativeContainerTypes) {} } diff --git a/core/trino-main/src/main/java/io/trino/metadata/SessionPropertyManager.java b/core/trino-main/src/main/java/io/trino/metadata/SessionPropertyManager.java index 8c818d418a3a..f3f3afd4802d 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/SessionPropertyManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/SessionPropertyManager.java @@ -134,8 +134,8 @@ public List getAllSessionProperties(Session session, List< } for (CatalogInfo catalogInfo : catalogInfos) { - CatalogHandle catalogHandle = catalogInfo.getCatalogHandle(); - String catalogName = catalogInfo.getCatalogName(); + CatalogHandle catalogHandle = catalogInfo.catalogHandle(); + String catalogName = catalogInfo.catalogName(); Map connectorProperties = session.getCatalogProperties(catalogName); for (PropertyMetadata property : new TreeMap<>(connectorSessionProperties.getService(catalogHandle)).values()) { diff --git a/core/trino-main/src/main/java/io/trino/metadata/SignatureBinder.java b/core/trino-main/src/main/java/io/trino/metadata/SignatureBinder.java index feac419becd9..138ab90eeb3c 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/SignatureBinder.java +++ b/core/trino-main/src/main/java/io/trino/metadata/SignatureBinder.java @@ -1048,14 +1048,12 @@ public enum RelationshipType EXACT, IMPLICIT_COERCION, EXPLICIT_COERCION_TO, EXPLICIT_COERCION_FROM } - private static final class FunctionTypeVariables + private record FunctionTypeVariables(FunctionBinding functionBinding) implements TypeVariables { - private final FunctionBinding functionBinding; - - public FunctionTypeVariables(FunctionBinding functionBinding) + private FunctionTypeVariables { - this.functionBinding = requireNonNull(functionBinding, "functionBinding is null"); + requireNonNull(functionBinding, "functionBinding is null"); } @Override diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableExecuteHandle.java b/core/trino-main/src/main/java/io/trino/metadata/TableExecuteHandle.java index f1f9a7e0dc4f..23f76a01c5d9 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableExecuteHandle.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableExecuteHandle.java @@ -13,53 +13,26 @@ */ package io.trino.metadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.spi.connector.CatalogHandle; import io.trino.spi.connector.ConnectorTableExecuteHandle; import io.trino.spi.connector.ConnectorTransactionHandle; -import java.util.Objects; - import static java.util.Objects.requireNonNull; /** * TableExecuteHandle wraps connectors ConnectorTableExecuteHandle which identifies instance of executing * specific table procedure o specific table. See {#link {@link ConnectorTableExecuteHandle}} for more details. */ -public final class TableExecuteHandle +public record TableExecuteHandle( + CatalogHandle catalogHandle, + ConnectorTransactionHandle transactionHandle, + ConnectorTableExecuteHandle connectorHandle) { - private final CatalogHandle catalogHandle; - private final ConnectorTransactionHandle transactionHandle; - private final ConnectorTableExecuteHandle connectorHandle; - - @JsonCreator - public TableExecuteHandle( - @JsonProperty("catalogHandle") CatalogHandle catalogHandle, - @JsonProperty("transactionHandle") ConnectorTransactionHandle transactionHandle, - @JsonProperty("connectorHandle") ConnectorTableExecuteHandle connectorHandle) - { - this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null"); - this.transactionHandle = requireNonNull(transactionHandle, "transactionHandle is null"); - this.connectorHandle = requireNonNull(connectorHandle, "connectorHandle is null"); - } - - @JsonProperty - public CatalogHandle getCatalogHandle() + public TableExecuteHandle { - return catalogHandle; - } - - @JsonProperty - public ConnectorTransactionHandle getTransactionHandle() - { - return transactionHandle; - } - - @JsonProperty - public ConnectorTableExecuteHandle getConnectorHandle() - { - return connectorHandle; + requireNonNull(catalogHandle, "catalogHandle is null"); + requireNonNull(transactionHandle, "transactionHandle is null"); + requireNonNull(connectorHandle, "connectorHandle is null"); } public TableExecuteHandle withConnectorHandle(ConnectorTableExecuteHandle connectorHandle) @@ -67,27 +40,6 @@ public TableExecuteHandle withConnectorHandle(ConnectorTableExecuteHandle connec return new TableExecuteHandle(catalogHandle, transactionHandle, connectorHandle); } - @Override - public boolean equals(Object obj) - { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - TableExecuteHandle o = (TableExecuteHandle) obj; - return Objects.equals(this.catalogHandle, o.catalogHandle) && - Objects.equals(this.transactionHandle, o.transactionHandle) && - Objects.equals(this.connectorHandle, o.connectorHandle); - } - - @Override - public int hashCode() - { - return Objects.hash(catalogHandle, transactionHandle, connectorHandle); - } - @Override public String toString() { diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableFunctionHandle.java b/core/trino-main/src/main/java/io/trino/metadata/TableFunctionHandle.java index 6f6865ab762c..e12867e39aa4 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableFunctionHandle.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableFunctionHandle.java @@ -13,46 +13,21 @@ */ package io.trino.metadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.spi.connector.CatalogHandle; import io.trino.spi.connector.ConnectorTransactionHandle; import io.trino.spi.function.table.ConnectorTableFunctionHandle; import static java.util.Objects.requireNonNull; -public class TableFunctionHandle +public record TableFunctionHandle( + CatalogHandle catalogHandle, + ConnectorTableFunctionHandle functionHandle, + ConnectorTransactionHandle transactionHandle) { - private final CatalogHandle catalogHandle; - private final ConnectorTableFunctionHandle functionHandle; - private final ConnectorTransactionHandle transactionHandle; - - @JsonCreator - public TableFunctionHandle( - @JsonProperty("catalogHandle") CatalogHandle catalogHandle, - @JsonProperty("functionHandle") ConnectorTableFunctionHandle functionHandle, - @JsonProperty("transactionHandle") ConnectorTransactionHandle transactionHandle) - { - this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null"); - this.functionHandle = requireNonNull(functionHandle, "functionHandle is null"); - this.transactionHandle = requireNonNull(transactionHandle, "transactionHandle is null"); - } - - @JsonProperty - public CatalogHandle getCatalogHandle() - { - return catalogHandle; - } - - @JsonProperty - public ConnectorTableFunctionHandle getFunctionHandle() - { - return functionHandle; - } - - @JsonProperty - public ConnectorTransactionHandle getTransactionHandle() + public TableFunctionHandle { - return transactionHandle; + requireNonNull(catalogHandle, "catalogHandle is null"); + requireNonNull(functionHandle, "functionHandle is null"); + requireNonNull(transactionHandle, "transactionHandle is null"); } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableFunctionMetadata.java b/core/trino-main/src/main/java/io/trino/metadata/TableFunctionMetadata.java index dfef7d239fd1..e5031d20f463 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableFunctionMetadata.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableFunctionMetadata.java @@ -18,24 +18,11 @@ import static java.util.Objects.requireNonNull; -public class TableFunctionMetadata +public record TableFunctionMetadata(CatalogHandle catalogHandle, ConnectorTableFunction function) { - private final CatalogHandle catalogHandle; - private final ConnectorTableFunction function; - - public TableFunctionMetadata(CatalogHandle catalogHandle, ConnectorTableFunction function) - { - this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null"); - this.function = requireNonNull(function, "function is null"); - } - - public CatalogHandle getCatalogHandle() - { - return catalogHandle; - } - - public ConnectorTableFunction getFunction() + public TableFunctionMetadata { - return function; + requireNonNull(catalogHandle, "catalogHandle is null"); + requireNonNull(function, "function is null"); } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableHandle.java b/core/trino-main/src/main/java/io/trino/metadata/TableHandle.java index b352196524d7..c4d96e2e350a 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableHandle.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableHandle.java @@ -13,49 +13,19 @@ */ package io.trino.metadata; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import io.trino.spi.connector.CatalogHandle; import io.trino.spi.connector.ConnectorTableHandle; import io.trino.spi.connector.ConnectorTransactionHandle; -import java.util.Objects; - import static java.util.Objects.requireNonNull; -public final class TableHandle +public record TableHandle(CatalogHandle catalogHandle, ConnectorTableHandle connectorHandle, ConnectorTransactionHandle transaction) { - private final CatalogHandle catalogHandle; - private final ConnectorTableHandle connectorHandle; - private final ConnectorTransactionHandle transaction; - - @JsonCreator - public TableHandle( - @JsonProperty("catalogHandle") CatalogHandle catalogHandle, - @JsonProperty("connectorHandle") ConnectorTableHandle connectorHandle, - @JsonProperty("transaction") ConnectorTransactionHandle transaction) - { - this.catalogHandle = requireNonNull(catalogHandle, "catalogHandle is null"); - this.connectorHandle = requireNonNull(connectorHandle, "connectorHandle is null"); - this.transaction = requireNonNull(transaction, "transaction is null"); - } - - @JsonProperty - public CatalogHandle getCatalogHandle() + public TableHandle { - return catalogHandle; - } - - @JsonProperty - public ConnectorTableHandle getConnectorHandle() - { - return connectorHandle; - } - - @JsonProperty - public ConnectorTransactionHandle getTransaction() - { - return transaction; + requireNonNull(catalogHandle, "catalogHandle is null"); + requireNonNull(connectorHandle, "connectorHandle is null"); + requireNonNull(transaction, "transaction is null"); } public TableHandle withConnectorHandle(ConnectorTableHandle connectorHandle) @@ -71,25 +41,4 @@ public String toString() { return catalogHandle + ":" + connectorHandle; } - - @Override - public boolean equals(Object o) - { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TableHandle other = (TableHandle) o; - return Objects.equals(catalogHandle, other.catalogHandle) && - Objects.equals(connectorHandle, other.connectorHandle) && - Objects.equals(transaction, other.transaction); - } - - @Override - public int hashCode() - { - return Objects.hash(catalogHandle, connectorHandle, transaction); - } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableProperties.java b/core/trino-main/src/main/java/io/trino/metadata/TableProperties.java index 2bca714eb7db..332134bdad58 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableProperties.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableProperties.java @@ -24,7 +24,6 @@ import io.trino.sql.planner.PartitioningHandle; import java.util.List; -import java.util.Objects; import java.util.Optional; import static java.util.Objects.requireNonNull; @@ -73,53 +72,15 @@ public Optional getDiscretePredicates() return tableProperties.getDiscretePredicates(); } - public static class TablePartitioning + public record TablePartitioning( + PartitioningHandle partitioningHandle, + List partitioningColumns, + boolean singleSplitPerPartition) { - private final PartitioningHandle partitioningHandle; - private final List partitioningColumns; - private final boolean singleSplitPerPartition; - - public TablePartitioning(PartitioningHandle partitioningHandle, List partitioningColumns, boolean singleSplitPerPartition) - { - this.partitioningHandle = requireNonNull(partitioningHandle, "partitioningHandle is null"); - this.partitioningColumns = ImmutableList.copyOf(requireNonNull(partitioningColumns, "partitioningColumns is null")); - this.singleSplitPerPartition = singleSplitPerPartition; - } - - public PartitioningHandle getPartitioningHandle() - { - return partitioningHandle; - } - - public List getPartitioningColumns() - { - return partitioningColumns; - } - - public boolean isSingleSplitPerPartition() - { - return singleSplitPerPartition; - } - - @Override - public boolean equals(Object o) - { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TablePartitioning that = (TablePartitioning) o; - return singleSplitPerPartition == that.singleSplitPerPartition && - Objects.equals(partitioningHandle, that.partitioningHandle) && - Objects.equals(partitioningColumns, that.partitioningColumns); - } - - @Override - public int hashCode() + public TablePartitioning { - return Objects.hash(partitioningHandle, partitioningColumns, singleSplitPerPartition); + requireNonNull(partitioningHandle, "partitioningHandle is null"); + partitioningColumns = ImmutableList.copyOf(requireNonNull(partitioningColumns, "partitioningColumns is null")); } } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/TableVersion.java b/core/trino-main/src/main/java/io/trino/metadata/TableVersion.java index 0c9be6598d56..9ea922d40f44 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/TableVersion.java +++ b/core/trino-main/src/main/java/io/trino/metadata/TableVersion.java @@ -16,31 +16,12 @@ import io.trino.spi.connector.PointerType; import io.trino.spi.type.Type; -public class TableVersion -{ - private final PointerType pointerType; - private final Type objectType; - private final Object pointer; - - public TableVersion(PointerType pointerType, Type objectType, Object pointer) - { - this.pointerType = pointerType; - this.objectType = objectType; - this.pointer = pointer; - } +import static java.util.Objects.requireNonNull; - public PointerType getPointerType() - { - return pointerType; - } - - public Type getObjectType() - { - return objectType; - } - - public Object getPointer() +public record TableVersion(PointerType pointerType, Type objectType, Object pointer) +{ + public TableVersion { - return pointer; + requireNonNull(objectType, "objectType is null"); } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/ViewColumn.java b/core/trino-main/src/main/java/io/trino/metadata/ViewColumn.java index ce03e472d80c..72e4ee22644d 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/ViewColumn.java +++ b/core/trino-main/src/main/java/io/trino/metadata/ViewColumn.java @@ -15,39 +15,18 @@ import io.trino.spi.type.TypeId; -import java.util.Objects; import java.util.Optional; import static com.google.common.base.MoreObjects.toStringHelper; import static java.util.Objects.requireNonNull; -public final class ViewColumn +public record ViewColumn(String name, TypeId type, Optional comment) { - private final String name; - private final TypeId type; - - private final Optional comment; - - public ViewColumn(String name, TypeId type, Optional comment) - { - this.name = requireNonNull(name, "name is null"); - this.type = requireNonNull(type, "type is null"); - this.comment = requireNonNull(comment, "comment is null"); - } - - public String getName() + public ViewColumn { - return name; - } - - public TypeId getType() - { - return type; - } - - public Optional getComment() - { - return comment; + requireNonNull(name, "name is null"); + requireNonNull(type, "type is null"); + requireNonNull(comment, "comment is null"); } @Override @@ -59,23 +38,4 @@ public String toString() .add("comment", comment.orElse(null)) .toString(); } - - @Override - public boolean equals(Object o) - { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ViewColumn that = (ViewColumn) o; - return Objects.equals(name, that.name) && Objects.equals(type, that.type) && Objects.equals(comment, that.comment); - } - - @Override - public int hashCode() - { - return Objects.hash(name, type, comment); - } } diff --git a/core/trino-main/src/main/java/io/trino/metadata/ViewDefinition.java b/core/trino-main/src/main/java/io/trino/metadata/ViewDefinition.java index 413c46f024f5..d87dfdb0dd07 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/ViewDefinition.java +++ b/core/trino-main/src/main/java/io/trino/metadata/ViewDefinition.java @@ -102,7 +102,7 @@ public ConnectorViewDefinition toConnectorViewDefinition() catalog, schema, columns.stream() - .map(column -> new ConnectorViewDefinition.ViewColumn(column.getName(), column.getType(), column.getComment())) + .map(column -> new ConnectorViewDefinition.ViewColumn(column.name(), column.type(), column.comment())) .collect(toImmutableList()), comment, runAsIdentity.map(Identity::getUser), diff --git a/core/trino-main/src/main/java/io/trino/operator/index/IndexManager.java b/core/trino-main/src/main/java/io/trino/operator/index/IndexManager.java index cd8b74ff7714..60f9a5ad87af 100644 --- a/core/trino-main/src/main/java/io/trino/operator/index/IndexManager.java +++ b/core/trino-main/src/main/java/io/trino/operator/index/IndexManager.java @@ -38,8 +38,8 @@ public IndexManager(CatalogServiceProvider indexProvider public ConnectorIndex getIndex(Session session, IndexHandle indexHandle, List lookupSchema, List outputSchema) { - ConnectorSession connectorSession = session.toConnectorSession(indexHandle.getCatalogHandle()); - ConnectorIndexProvider provider = indexProvider.getService(indexHandle.getCatalogHandle()); - return provider.getIndex(indexHandle.getTransactionHandle(), connectorSession, indexHandle.getConnectorHandle(), lookupSchema, outputSchema); + ConnectorSession connectorSession = session.toConnectorSession(indexHandle.catalogHandle()); + ConnectorIndexProvider provider = indexProvider.getService(indexHandle.catalogHandle()); + return provider.getIndex(indexHandle.transactionHandle(), connectorSession, indexHandle.connectorHandle(), lookupSchema, outputSchema); } } diff --git a/core/trino-main/src/main/java/io/trino/split/PageSinkManager.java b/core/trino-main/src/main/java/io/trino/split/PageSinkManager.java index 512aae433232..5c082eddd31e 100644 --- a/core/trino-main/src/main/java/io/trino/split/PageSinkManager.java +++ b/core/trino-main/src/main/java/io/trino/split/PageSinkManager.java @@ -44,33 +44,33 @@ public PageSinkManager(CatalogServiceProvider pageSin @Override public ConnectorPageSink createPageSink(Session session, OutputTableHandle tableHandle, ConnectorPageSinkId pageSinkId) { - ConnectorSession connectorSession = session.toConnectorSession(tableHandle.getCatalogHandle()); - return providerFor(tableHandle.getCatalogHandle()).createPageSink(tableHandle.getTransactionHandle(), connectorSession, tableHandle.getConnectorHandle(), pageSinkId); + ConnectorSession connectorSession = session.toConnectorSession(tableHandle.catalogHandle()); + return providerFor(tableHandle.catalogHandle()).createPageSink(tableHandle.transactionHandle(), connectorSession, tableHandle.connectorHandle(), pageSinkId); } @Override public ConnectorPageSink createPageSink(Session session, InsertTableHandle tableHandle, ConnectorPageSinkId pageSinkId) { // assumes connectorId and catalog are the same - ConnectorSession connectorSession = session.toConnectorSession(tableHandle.getCatalogHandle()); - return providerFor(tableHandle.getCatalogHandle()).createPageSink(tableHandle.getTransactionHandle(), connectorSession, tableHandle.getConnectorHandle(), pageSinkId); + ConnectorSession connectorSession = session.toConnectorSession(tableHandle.catalogHandle()); + return providerFor(tableHandle.catalogHandle()).createPageSink(tableHandle.transactionHandle(), connectorSession, tableHandle.connectorHandle(), pageSinkId); } @Override public ConnectorPageSink createPageSink(Session session, TableExecuteHandle tableHandle, ConnectorPageSinkId pageSinkId) { // assumes connectorId and catalog are the same - ConnectorSession connectorSession = session.toConnectorSession(tableHandle.getCatalogHandle()); - return providerFor(tableHandle.getCatalogHandle()).createPageSink(tableHandle.getTransactionHandle(), connectorSession, tableHandle.getConnectorHandle(), pageSinkId); + ConnectorSession connectorSession = session.toConnectorSession(tableHandle.catalogHandle()); + return providerFor(tableHandle.catalogHandle()).createPageSink(tableHandle.transactionHandle(), connectorSession, tableHandle.connectorHandle(), pageSinkId); } @Override public ConnectorMergeSink createMergeSink(Session session, MergeHandle mergeHandle, ConnectorPageSinkId pageSinkId) { // assumes connectorId and catalog are the same - TableHandle tableHandle = mergeHandle.getTableHandle(); - ConnectorSession connectorSession = session.toConnectorSession(tableHandle.getCatalogHandle()); - return providerFor(tableHandle.getCatalogHandle()).createMergeSink(tableHandle.getTransaction(), connectorSession, mergeHandle.getConnectorMergeHandle(), pageSinkId); + TableHandle tableHandle = mergeHandle.tableHandle(); + ConnectorSession connectorSession = session.toConnectorSession(tableHandle.catalogHandle()); + return providerFor(tableHandle.catalogHandle()).createMergeSink(tableHandle.transaction(), connectorSession, mergeHandle.connectorMergeHandle(), pageSinkId); } private ConnectorPageSinkProvider providerFor(CatalogHandle catalogHandle) diff --git a/core/trino-main/src/main/java/io/trino/split/PageSourceManager.java b/core/trino-main/src/main/java/io/trino/split/PageSourceManager.java index b985551cfee5..b2b0572bf6c5 100644 --- a/core/trino-main/src/main/java/io/trino/split/PageSourceManager.java +++ b/core/trino-main/src/main/java/io/trino/split/PageSourceManager.java @@ -47,7 +47,7 @@ public PageSourceManager(CatalogServiceProvider pag public ConnectorPageSource createPageSource(Session session, Split split, TableHandle table, List columns, DynamicFilter dynamicFilter) { requireNonNull(columns, "columns is null"); - checkArgument(split.getCatalogHandle().equals(table.getCatalogHandle()), "mismatched split and table"); + checkArgument(split.getCatalogHandle().equals(table.catalogHandle()), "mismatched split and table"); CatalogHandle catalogHandle = split.getCatalogHandle(); ConnectorPageSourceProvider provider = pageSourceProvider.getService(catalogHandle); @@ -59,10 +59,10 @@ public ConnectorPageSource createPageSource(Session session, Split split, TableH dynamicFilter = DynamicFilter.EMPTY; } return provider.createPageSource( - table.getTransaction(), + table.transaction(), session.toConnectorSession(catalogHandle), split.getConnectorSplit(), - table.getConnectorHandle(), + table.connectorHandle(), columns, dynamicFilter); } diff --git a/core/trino-main/src/main/java/io/trino/split/SplitManager.java b/core/trino-main/src/main/java/io/trino/split/SplitManager.java index e43e4d2da411..12d9e1491d4c 100644 --- a/core/trino-main/src/main/java/io/trino/split/SplitManager.java +++ b/core/trino-main/src/main/java/io/trino/split/SplitManager.java @@ -73,7 +73,7 @@ public SplitSource getSplits( DynamicFilter dynamicFilter, Constraint constraint) { - CatalogHandle catalogHandle = table.getCatalogHandle(); + CatalogHandle catalogHandle = table.catalogHandle(); ConnectorSplitManager splitManager = splitManagerProvider.getService(catalogHandle); if (!isAllowPushdownIntoConnectors(session)) { dynamicFilter = DynamicFilter.EMPTY; @@ -84,12 +84,12 @@ public SplitSource getSplits( ConnectorSplitSource source; try (var ignore = scopedSpan(tracer.spanBuilder("SplitManager.getSplits") .setParent(Context.current().with(parentSpan)) - .setAttribute(TrinoAttributes.TABLE, table.getConnectorHandle().toString()) + .setAttribute(TrinoAttributes.TABLE, table.connectorHandle().toString()) .startSpan())) { source = splitManager.getSplits( - table.getTransaction(), + table.transaction(), connectorSession, - table.getConnectorHandle(), + table.connectorHandle(), dynamicFilter, constraint); } @@ -112,18 +112,18 @@ public SplitSource getSplits( public SplitSource getSplits(Session session, Span parentSpan, TableFunctionHandle function) { - CatalogHandle catalogHandle = function.getCatalogHandle(); + CatalogHandle catalogHandle = function.catalogHandle(); ConnectorSplitManager splitManager = splitManagerProvider.getService(catalogHandle); ConnectorSplitSource source; try (var ignore = scopedSpan(tracer.spanBuilder("SplitManager.getSplits") .setParent(Context.current().with(parentSpan)) - .setAttribute(TrinoAttributes.FUNCTION, function.getFunctionHandle().toString()) + .setAttribute(TrinoAttributes.FUNCTION, function.functionHandle().toString()) .startSpan())) { source = splitManager.getSplits( - function.getTransactionHandle(), + function.transactionHandle(), session.toConnectorSession(catalogHandle), - function.getFunctionHandle()); + function.functionHandle()); } SplitSource splitSource = new ConnectorAwareSplitSource(catalogHandle, source); diff --git a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java index 3da56635f729..1f70ad5754c2 100644 --- a/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java +++ b/core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java @@ -671,7 +671,7 @@ protected Scope visitInsert(Insert insert, Optional scope) Column::new); analysis.setUpdateTarget( - targetTableHandle.get().getCatalogHandle().getVersion(), + targetTableHandle.get().catalogHandle().getVersion(), targetTable, Optional.empty(), Optional.of(Streams.zip( @@ -846,7 +846,7 @@ protected Scope visitDelete(Delete node, Optional scope) node.getWhere().ifPresent(where -> analyzeWhere(node, tableScope, where)); analysis.setUpdateType("DELETE"); - analysis.setUpdateTarget(handle.getCatalogHandle().getVersion(), tableName, Optional.of(table), Optional.empty()); + analysis.setUpdateTarget(handle.catalogHandle().getVersion(), tableName, Optional.of(table), Optional.empty()); Scope accessControlScope = Scope.builder() .withRelationType(RelationId.anonymous(), analysis.getScope(table).getRelationType()) .build(); @@ -871,7 +871,7 @@ protected Scope visitAnalyze(Analyze node, Optional scope) .orElseThrow(() -> semanticException(TABLE_NOT_FOUND, node, "Table '%s' does not exist", tableName)); analysis.setUpdateType("ANALYZE"); - analysis.setUpdateTarget(tableHandle.getCatalogHandle().getVersion(), tableName, Optional.empty(), Optional.empty()); + analysis.setUpdateTarget(tableHandle.catalogHandle().getVersion(), tableName, Optional.empty(), Optional.empty()); validateProperties(node.getProperties(), scope); String catalogName = tableName.catalogName(); @@ -923,7 +923,7 @@ protected Scope visitCreateTableAsSelect(CreateTableAsSelect node, Optional scope) analysis.setTableExecuteHandle(executeHandle); analysis.setUpdateType("ALTER TABLE EXECUTE"); - analysis.setUpdateTarget(executeHandle.getCatalogHandle().getVersion(), tableName, Optional.of(table), Optional.empty()); + analysis.setUpdateTarget(executeHandle.catalogHandle().getVersion(), tableName, Optional.of(table), Optional.empty()); return createAndAssignScope(node, scope, Field.newUnqualified("rows", BIGINT)); } @@ -1665,8 +1665,8 @@ protected Scope visitTableFunctionInvocation(TableFunctionInvocation node, Optio TableFunctionMetadata tableFunctionMetadata = resolveTableFunction(node) .orElseThrow(() -> semanticException(FUNCTION_NOT_FOUND, node, "Table function '%s' not registered", node.getName())); - ConnectorTableFunction function = tableFunctionMetadata.getFunction(); - CatalogHandle catalogHandle = tableFunctionMetadata.getCatalogHandle(); + ConnectorTableFunction function = tableFunctionMetadata.function(); + CatalogHandle catalogHandle = tableFunctionMetadata.catalogHandle(); Node errorLocation = node; if (!node.getArguments().isEmpty()) { @@ -2544,11 +2544,11 @@ private Scope createScopeForView( List viewFields = columns.stream() .map(column -> Field.newQualified( table.getName(), - Optional.of(column.getName()), + Optional.of(column.name()), getViewColumnType(column, name, table), false, Optional.of(name), - Optional.of(column.getName()), + Optional.of(column.name()), false)) .collect(toImmutableList()); @@ -3459,7 +3459,7 @@ protected Scope visitUpdate(Update update, Optional scope) } analysis.setUpdateTarget( - handle.getCatalogHandle().getVersion(), + handle.catalogHandle().getVersion(), tableName, Optional.of(table), Optional.of(updatedColumnSchemas.stream() @@ -3630,7 +3630,7 @@ else if (operation instanceof MergeInsert && caseColumnNames.isEmpty()) { .map(columnHandle -> new OutputColumn(new Column(columnHandle, dataColumnTypes.get(columnHandle).toString()), ImmutableSet.of())) .collect(toImmutableList()); - analysis.setUpdateTarget(targetTableHandle.getCatalogHandle().getVersion(), tableName, Optional.of(table), Optional.of(updatedColumns)); + analysis.setUpdateTarget(targetTableHandle.catalogHandle().getVersion(), tableName, Optional.of(table), Optional.of(updatedColumns)); List> mergeCaseColumnHandles = buildCaseColumnLists(merge, dataColumnSchemas, allColumnHandles); createMergeAnalysis(table, targetTableHandle, tableSchema, targetTableScope, joinScope, mergeCaseColumnHandles); @@ -5005,13 +5005,13 @@ private Optional checkViewStaleness(List columns, Collection i)); } String fieldName = field.getName().orElseThrow(); - if (!column.getName().equalsIgnoreCase(fieldName)) { + if (!column.name().equalsIgnoreCase(fieldName)) { return Optional.of(format( "column [%s] of type %s projected from query view at position %s has a different name from column [%s] of type %s stored in view definition", fieldName, field.getType(), i, - column.getName(), + column.name(), type)); } if (!typeCoercion.canCoerce(field.getType(), type)) { @@ -5020,7 +5020,7 @@ private Optional checkViewStaleness(List columns, Collection fieldName, field.getType(), i, - column.getName(), + column.name(), type)); } } @@ -5031,10 +5031,10 @@ private Optional checkViewStaleness(List columns, Collection private Type getViewColumnType(ViewColumn column, QualifiedObjectName name, Node node) { try { - return plannerContext.getTypeManager().getType(column.getType()); + return plannerContext.getTypeManager().getType(column.type()); } catch (TypeNotFoundException e) { - throw semanticException(INVALID_VIEW, node, e, "Unknown type '%s' for column '%s' in view: %s", column.getType(), column.getName(), name); + throw semanticException(INVALID_VIEW, node, e, "Unknown type '%s' for column '%s' in view: %s", column.type(), column.name(), name); } } @@ -5860,9 +5860,9 @@ private Optional extractTableVersion(Table table, Optional column Optional inputMetadata = metadata.getInfo(session, table); return new Input( tableName.getCatalogName(), - table.getCatalogHandle().getVersion(), + table.catalogHandle().getVersion(), schemaTable.getSchemaName(), schemaTable.getTableName(), inputMetadata, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java index 6be494f04d25..896bbe52e204 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java @@ -1628,9 +1628,9 @@ public PhysicalOperation visitTableFunctionProcessor(TableFunctionProcessorNode OperatorFactory operatorFactory = new LeafTableFunctionOperatorFactory( context.getNextOperatorId(), node.getId(), - node.getHandle().getCatalogHandle(), + node.getHandle().catalogHandle(), processorProvider, - node.getHandle().getFunctionHandle()); + node.getHandle().functionHandle()); return new PhysicalOperation(operatorFactory, makeLayout(node)); } @@ -1677,8 +1677,8 @@ public PhysicalOperation visitTableFunctionProcessor(TableFunctionProcessorNode context.getNextOperatorId(), node.getId(), processorProvider, - node.getHandle().getCatalogHandle(), - node.getHandle().getFunctionHandle(), + node.getHandle().catalogHandle(), + node.getHandle().functionHandle(), properChannelsCount, toIntExact(passThroughSourcesCount), requiredChannels, diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java index 998f1ddccc42..152e3a9c7d36 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/LogicalPlanner.java @@ -405,8 +405,8 @@ private RelationPlan createExplainAnalyzePlan(Analysis analysis, ExplainAnalyze private RelationPlan createAnalyzePlan(Analysis analysis, Analyze analyzeStatement) { AnalyzeMetadata analyzeMetadata = analysis.getAnalyzeMetadata().orElseThrow(); - TableHandle targetTable = analyzeMetadata.getTableHandle(); - TableStatisticsMetadata tableStatisticsMetadata = analyzeMetadata.getStatisticsMetadata(); + TableHandle targetTable = analyzeMetadata.tableHandle(); + TableStatisticsMetadata tableStatisticsMetadata = analyzeMetadata.statisticsMetadata(); // Plan table scan Map columnHandles = metadata.getColumnHandles(session, targetTable); @@ -588,7 +588,7 @@ private RelationPlan getInsertPlan( .map(ColumnMetadata::getName) .collect(toImmutableList()); - TableStatisticsMetadata statisticsMetadata = metadata.getStatisticsCollectionMetadataForWrite(session, tableHandle.getCatalogHandle(), tableMetadata.metadata()); + TableStatisticsMetadata statisticsMetadata = metadata.getStatisticsCollectionMetadataForWrite(session, tableHandle.catalogHandle(), tableMetadata.metadata()); if (materializedViewRefreshWriterTarget.isPresent()) { return createTableWriterPlan( diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/PlanFragmenter.java b/core/trino-main/src/main/java/io/trino/sql/planner/PlanFragmenter.java index 85c83a7b0a37..1f8c5989c02c 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/PlanFragmenter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/PlanFragmenter.java @@ -143,7 +143,7 @@ public SubPlan createSubPlans( Map unchangedSubPlans) { List activeCatalogs = transactionManager.getActiveCatalogs(session.getTransactionId().orElseThrow()).stream() - .map(CatalogInfo::getCatalogHandle) + .map(CatalogInfo::catalogHandle) .flatMap(catalogHandle -> catalogManager.getCatalogProperties(catalogHandle).stream()) .collect(toImmutableList()); Map languageScalarFunctions = languageFunctionManager.serializeFunctionsForWorkers(session); @@ -361,7 +361,7 @@ public PlanNode visitTableScan(TableScanNode node, RewriteContext node.isUseConnectorNodePartitioning()) - .map(TablePartitioning::getPartitioningHandle) + .map(TablePartitioning::partitioningHandle) .orElse(SOURCE_DISTRIBUTION); context.get().addSourceDistribution(node.getId(), partitioning, metadata, session); @@ -799,7 +799,7 @@ public PlanNode visitTableScan(TableScanNode node, RewriteContext context) PartitioningHandle partitioning = metadata.getTableProperties(session, node.getTable()) .getTablePartitioning() .filter(value -> node.isUseConnectorNodePartitioning()) - .map(TablePartitioning::getPartitioningHandle) + .map(TablePartitioning::partitioningHandle) .orElse(SOURCE_DISTRIBUTION); if (partitioning.equals(fragmentPartitioningHandle)) { // do nothing if the current scan node's partitioning matches the fragment's diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DetermineTableScanNodePartitioning.java b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DetermineTableScanNodePartitioning.java index 8b562a63ad29..0810f8381196 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DetermineTableScanNodePartitioning.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/iterative/rule/DetermineTableScanNodePartitioning.java @@ -64,7 +64,7 @@ public Result apply(TableScanNode node, Captures captures, Context context) } TablePartitioning partitioning = properties.getTablePartitioning().get(); - Optional bucketNodeMap = nodePartitioningManager.getConnectorBucketNodeMap(context.getSession(), partitioning.getPartitioningHandle()); + Optional bucketNodeMap = nodePartitioningManager.getConnectorBucketNodeMap(context.getSession(), partitioning.partitioningHandle()); if (bucketNodeMap.map(ConnectorBucketNodeMap::hasFixedMapping).orElse(false)) { // use connector table scan node partitioning when bucket to node assignments are fixed return Result.ofPlanNode(node.withUseConnectorNodePartitioning(true)); @@ -75,7 +75,7 @@ public Result apply(TableScanNode node, Captures captures, Context context) } int numberOfBuckets = bucketNodeMap.map(ConnectorBucketNodeMap::getBucketCount) - .orElseGet(() -> nodePartitioningManager.getNodeCount(context.getSession(), partitioning.getPartitioningHandle())); + .orElseGet(() -> nodePartitioningManager.getNodeCount(context.getSession(), partitioning.partitioningHandle())); int numberOfTasks = max(taskCountEstimator.estimateSourceDistributedTaskCount(context.getSession()), 1); return Result.ofPlanNode(node diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/AddExchanges.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/AddExchanges.java index 782ea823e36a..0603bcb8c8b5 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/AddExchanges.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/AddExchanges.java @@ -1531,7 +1531,7 @@ private static Stream collectSourceCatalogs(PlanNode root) .findAll() .stream() .map(TableScanNode.class::cast) - .map(node -> node.getTable().getCatalogHandle()); + .map(node -> node.getTable().catalogHandle()); } private static boolean isNotRemoteExchange(PlanNode node) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java index 03780bbed88f..7b95ea916fd2 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/BeginTableWrite.java @@ -248,7 +248,7 @@ private WriterTarget createWriterTarget(WriterTarget target, PlanNode planNode) if (target instanceof MergeTarget merge) { MergeHandle mergeHandle = metadata.beginMerge(session, merge.getHandle()); return new MergeTarget( - mergeHandle.getTableHandle(), + mergeHandle.tableHandle(), Optional.of(mergeHandle), merge.getSchemaTableName(), merge.getMergeParadigmAndTypes()); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java index 6b34be6f02d8..c84f1c58ad40 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/PropertyDerivations.java @@ -894,12 +894,12 @@ private Global deriveGlobalProperties(TableScanNode node, TableProperties layout { if (layout.getTablePartitioning().isPresent() && node.isUseConnectorNodePartitioning()) { TablePartitioning tablePartitioning = layout.getTablePartitioning().get(); - if (assignments.keySet().containsAll(tablePartitioning.getPartitioningColumns())) { - List arguments = tablePartitioning.getPartitioningColumns().stream() + if (assignments.keySet().containsAll(tablePartitioning.partitioningColumns())) { + List arguments = tablePartitioning.partitioningColumns().stream() .map(assignments::get) .collect(toImmutableList()); - return partitionedOn(tablePartitioning.getPartitioningHandle(), arguments); + return partitionedOn(tablePartitioning.partitioningHandle(), arguments); } } return arbitraryPartition(); diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/StreamPropertyDerivations.java b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/StreamPropertyDerivations.java index ab181c9e58f2..2a717e4ec8ef 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/StreamPropertyDerivations.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/optimizations/StreamPropertyDerivations.java @@ -321,10 +321,10 @@ public StreamProperties visitTableScan(TableScanNode node, List constants.add(entry.getKey())); Optional> partitioningSymbols = layout.getTablePartitioning().flatMap(partitioning -> { - if (!partitioning.isSingleSplitPerPartition()) { + if (!partitioning.singleSplitPerPartition()) { return Optional.empty(); } - Optional> symbols = getNonConstantSymbols(partitioning.getPartitioningColumns(), assignments, constants); + Optional> symbols = getNonConstantSymbols(partitioning.partitioningColumns(), assignments, constants); // if we are partitioned on empty set, we must say multiple of unknown partitioning, because // the connector does not guarantee a single split in this case (since it might not understand // that the value is a constant). diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/plan/TableWriterNode.java b/core/trino-main/src/main/java/io/trino/sql/planner/plan/TableWriterNode.java index a5d77c51bd26..adb8ff023997 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/plan/TableWriterNode.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/plan/TableWriterNode.java @@ -389,7 +389,7 @@ public boolean supportsMultipleWritersPerPartition(Metadata metadata, Session se @Override public OptionalInt getMaxWriterTasks(Metadata metadata, Session session) { - return metadata.getMaxWriterTasks(session, handle.getCatalogHandle().getCatalogName().toString()); + return metadata.getMaxWriterTasks(session, handle.catalogHandle().getCatalogName().toString()); } @Override @@ -528,7 +528,7 @@ public boolean supportsMultipleWritersPerPartition(Metadata metadata, Session se @Override public OptionalInt getMaxWriterTasks(Metadata metadata, Session session) { - return metadata.getMaxWriterTasks(session, storageTableHandle.getCatalogHandle().getCatalogName().toString()); + return metadata.getMaxWriterTasks(session, storageTableHandle.catalogHandle().getCatalogName().toString()); } public List getSourceTableFunctions() @@ -623,7 +623,7 @@ public boolean supportsMultipleWritersPerPartition(Metadata metadata, Session se @Override public OptionalInt getMaxWriterTasks(Metadata metadata, Session session) { - return metadata.getMaxWriterTasks(session, tableHandle.getCatalogHandle().getCatalogName().toString()); + return metadata.getMaxWriterTasks(session, tableHandle.catalogHandle().getCatalogName().toString()); } @Override @@ -835,7 +835,7 @@ public boolean supportsMultipleWritersPerPartition(Metadata metadata, Session se @Override public OptionalInt getMaxWriterTasks(Metadata metadata, Session session) { - return metadata.getMaxWriterTasks(session, executeHandle.getCatalogHandle().getCatalogName().toString()); + return metadata.getMaxWriterTasks(session, executeHandle.catalogHandle().getCatalogName().toString()); } @Override diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/CounterBasedAnonymizer.java b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/CounterBasedAnonymizer.java index a9e4d846c08b..ae4ff82ce774 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/CounterBasedAnonymizer.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/CounterBasedAnonymizer.java @@ -145,8 +145,8 @@ public String anonymize(ArgumentBinding argument) public String anonymize(IndexHandle indexHandle) { return formatMap(ImmutableMap.of( - "catalog", anonymize(indexHandle.getCatalogHandle().getCatalogName().toString(), ObjectType.CATALOG), - "connectorHandleType", indexHandle.getConnectorHandle().getClass().getSimpleName())); + "catalog", anonymize(indexHandle.catalogHandle().getCatalogName().toString(), ObjectType.CATALOG), + "connectorHandleType", indexHandle.connectorHandle().getClass().getSimpleName())); } @Override @@ -200,7 +200,7 @@ public String anonymize(WriteStatisticsTarget target) { if (target instanceof WriteStatisticsHandle) { return anonymize( - ((WriteStatisticsHandle) target).getHandle().getCatalogHandle().getCatalogName().toString(), + ((WriteStatisticsHandle) target).getHandle().catalogHandle().getCatalogName().toString(), ObjectType.CATALOG); } throw new UnsupportedOperationException("Anonymization is not supported for WriterTarget type: " + target.getClass().getSimpleName()); @@ -209,19 +209,19 @@ public String anonymize(WriteStatisticsTarget target) @Override public String anonymize(TableHandle tableHandle) { - return anonymize(tableHandle.getCatalogHandle().getCatalogName().toString(), ObjectType.CATALOG); + return anonymize(tableHandle.catalogHandle().getCatalogName().toString(), ObjectType.CATALOG); } @Override public String anonymize(TableExecuteHandle tableHandle) { - return anonymize(tableHandle.getCatalogHandle().getCatalogName().toString(), ObjectType.CATALOG); + return anonymize(tableHandle.catalogHandle().getCatalogName().toString(), ObjectType.CATALOG); } private String anonymize(CreateTarget target) { return anonymize( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName()); } @@ -229,7 +229,7 @@ private String anonymize(CreateTarget target) private String anonymize(InsertTarget target) { return anonymize( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName()); } @@ -237,7 +237,7 @@ private String anonymize(InsertTarget target) private String anonymize(MergeTarget target) { return anonymize( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName()); } @@ -245,7 +245,7 @@ private String anonymize(MergeTarget target) private String anonymize(RefreshMaterializedViewTarget target) { return anonymize( - target.getInsertHandle().getCatalogHandle().getCatalogName().toString(), + target.getInsertHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName()); } @@ -253,7 +253,7 @@ private String anonymize(RefreshMaterializedViewTarget target) private String anonymize(TableExecuteTarget target) { return anonymize( - target.getExecuteHandle().getCatalogHandle().getCatalogName().toString(), + target.getExecuteHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName()); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/IoPlanPrinter.java b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/IoPlanPrinter.java index 893da6129ba0..b0de8d9d0f12 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/IoPlanPrinter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/IoPlanPrinter.java @@ -693,25 +693,25 @@ public Void visitTableFinish(TableFinishNode node, IoPlanBuilder context) WriterTarget writerTarget = node.getTarget(); if (writerTarget instanceof CreateTarget target) { context.setOutputTable(new CatalogSchemaTableName( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName())); } else if (writerTarget instanceof InsertTarget target) { context.setOutputTable(new CatalogSchemaTableName( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName())); } else if (writerTarget instanceof MergeTarget target) { context.setOutputTable(new CatalogSchemaTableName( - target.getHandle().getCatalogHandle().getCatalogName().toString(), + target.getHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName())); } else if (writerTarget instanceof TableWriterNode.RefreshMaterializedViewTarget target) { context.setOutputTable(new CatalogSchemaTableName( - target.getInsertHandle().getCatalogHandle().getCatalogName().toString(), + target.getInsertHandle().catalogHandle().getCatalogName().toString(), target.getSchemaTableName().getSchemaName(), target.getSchemaTableName().getTableName())); } diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/TableInfoSupplier.java b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/TableInfoSupplier.java index 36a8176704e3..92fbdbb4a16e 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/TableInfoSupplier.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/TableInfoSupplier.java @@ -46,8 +46,8 @@ public TableInfo apply(TableScanNode node) CatalogSchemaTableName tableName = metadata.getTableName(session, node.getTable()); TableProperties tableProperties = metadata.getTableProperties(session, node.getTable()); Optional connectorName = metadata.listCatalogs(session).stream() - .filter(catalogInfo -> catalogInfo.getCatalogName().equals(tableName.getCatalogName())) - .map(CatalogInfo::getConnectorName) + .filter(catalogInfo -> catalogInfo.catalogName().equals(tableName.getCatalogName())) + .map(CatalogInfo::connectorName) .map(ConnectorName::toString) .findFirst(); QualifiedObjectName objectName = new QualifiedObjectName(tableName.getCatalogName(), tableName.getSchemaTableName().getSchemaName(), tableName.getSchemaTableName().getTableName()); diff --git a/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java b/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java index 72a5346cb0d3..4a8d94592f66 100644 --- a/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java +++ b/core/trino-main/src/main/java/io/trino/sql/rewrite/ShowQueriesRewrite.java @@ -690,7 +690,7 @@ protected Node visitShowCreate(ShowCreate node, Void context) accessControl.checkCanShowCreateTable(session.toSecurityContext(), targetTableName); ConnectorTableMetadata connectorTableMetadata = metadata.getTableMetadata(session, tableHandle).metadata(); - Collection> allColumnProperties = columnPropertyManager.getAllProperties(tableHandle.getCatalogHandle()); + Collection> allColumnProperties = columnPropertyManager.getAllProperties(tableHandle.catalogHandle()); List columns = connectorTableMetadata.getColumns().stream() .filter(column -> !column.isHidden()) @@ -706,7 +706,7 @@ protected Node visitShowCreate(ShowCreate node, Void context) .collect(toImmutableList()); Map properties = connectorTableMetadata.getProperties(); - Collection> allTableProperties = tablePropertyManager.getAllProperties(tableHandle.getCatalogHandle()); + Collection> allTableProperties = tablePropertyManager.getAllProperties(tableHandle.catalogHandle()); List propertyNodes = buildProperties(targetTableName, Optional.empty(), INVALID_TABLE_PROPERTY, properties, allTableProperties); CreateTable createTable = new CreateTable( diff --git a/core/trino-main/src/main/java/io/trino/tracing/TracingMetadata.java b/core/trino-main/src/main/java/io/trino/tracing/TracingMetadata.java index a6d79e6385a1..a4d4141bbf6e 100644 --- a/core/trino-main/src/main/java/io/trino/tracing/TracingMetadata.java +++ b/core/trino-main/src/main/java/io/trino/tracing/TracingMetadata.java @@ -602,9 +602,9 @@ public OutputTableHandle beginCreateTable(Session session, String catalogName, C @Override public Optional finishCreateTable(Session session, OutputTableHandle tableHandle, Collection fragments, Collection computedStatistics) { - Span span = startSpan("finishCreateTable", tableHandle.getCatalogHandle().getCatalogName()); + Span span = startSpan("finishCreateTable", tableHandle.catalogHandle().getCatalogName()); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.TABLE, tableHandle.getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.TABLE, tableHandle.connectorHandle().toString()); } try (var ignored = scopedSpan(span)) { return delegate.finishCreateTable(session, tableHandle, fragments, computedStatistics); @@ -650,9 +650,9 @@ public AnalyzeTableHandle beginStatisticsCollection(Session session, TableHandle @Override public void finishStatisticsCollection(Session session, AnalyzeTableHandle tableHandle, Collection computedStatistics) { - Span span = startSpan("finishStatisticsCollection", tableHandle.getCatalogHandle().getCatalogName()); + Span span = startSpan("finishStatisticsCollection", tableHandle.catalogHandle().getCatalogName()); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.TABLE, tableHandle.getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.TABLE, tableHandle.connectorHandle().toString()); } try (var ignored = scopedSpan(span)) { delegate.finishStatisticsCollection(session, tableHandle, computedStatistics); @@ -698,9 +698,9 @@ public boolean supportsMissingColumnsOnInsert(Session session, TableHandle table @Override public Optional finishInsert(Session session, InsertTableHandle tableHandle, List sourceTableHandles, Collection fragments, Collection computedStatistics) { - Span span = startSpan("finishInsert", tableHandle.getCatalogHandle().getCatalogName()); + Span span = startSpan("finishInsert", tableHandle.catalogHandle().getCatalogName()); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.TABLE, tableHandle.getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.TABLE, tableHandle.connectorHandle().toString()); } try (var ignored = scopedSpan(span)) { return delegate.finishInsert(session, tableHandle, sourceTableHandles, fragments, computedStatistics); @@ -832,9 +832,9 @@ public MergeHandle beginMerge(Session session, TableHandle tableHandle) @Override public void finishMerge(Session session, MergeHandle tableHandle, Collection fragments, Collection computedStatistics) { - Span span = startSpan("finishMerge", tableHandle.getTableHandle().getCatalogHandle().getCatalogName()); + Span span = startSpan("finishMerge", tableHandle.tableHandle().catalogHandle().getCatalogName()); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.TABLE, tableHandle.getTableHandle().getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.TABLE, tableHandle.tableHandle().connectorHandle().toString()); } try (var ignored = scopedSpan(span)) { delegate.finishMerge(session, tableHandle, fragments, computedStatistics); @@ -1016,8 +1016,8 @@ public Optional> applyAggregation(Sess public Optional> applyJoin(Session session, JoinType joinType, TableHandle left, TableHandle right, ConnectorExpression joinCondition, Map leftAssignments, Map rightAssignments, JoinStatistics statistics) { Span span = startSpan("applyJoin"); - if (span.isRecording() && left.getCatalogHandle().equals(right.getCatalogHandle())) { - span.setAttribute(TrinoAttributes.CATALOG, left.getCatalogHandle().getCatalogName().toString()); + if (span.isRecording() && left.catalogHandle().equals(right.catalogHandle())) { + span.setAttribute(TrinoAttributes.CATALOG, left.catalogHandle().getCatalogName().toString()); } try (var ignored = scopedSpan(span)) { return delegate.applyJoin(session, joinType, left, right, joinCondition, leftAssignments, rightAssignments, statistics); @@ -1037,8 +1037,8 @@ public Optional> applyTopN(Session session, T public Optional> applyTableFunction(Session session, TableFunctionHandle handle) { Span span = startSpan("applyTableFunction") - .setAttribute(TrinoAttributes.CATALOG, handle.getCatalogHandle().getCatalogName().toString()) - .setAttribute(TrinoAttributes.HANDLE, handle.getFunctionHandle().toString()); + .setAttribute(TrinoAttributes.CATALOG, handle.catalogHandle().getCatalogName().toString()) + .setAttribute(TrinoAttributes.HANDLE, handle.functionHandle().toString()); try (var ignored = scopedSpan(span)) { return delegate.applyTableFunction(session, handle); } @@ -1595,8 +1595,8 @@ private Span startSpan(String methodName, TableHandle handle) { Span span = startSpan(methodName); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.CATALOG, handle.getCatalogHandle().getCatalogName().toString()); - span.setAttribute(TrinoAttributes.HANDLE, handle.getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.CATALOG, handle.catalogHandle().getCatalogName().toString()); + span.setAttribute(TrinoAttributes.HANDLE, handle.connectorHandle().toString()); } return span; } @@ -1605,8 +1605,8 @@ private Span startSpan(String methodName, TableExecuteHandle handle) { Span span = startSpan(methodName); if (span.isRecording()) { - span.setAttribute(TrinoAttributes.CATALOG, handle.getCatalogHandle().getCatalogName().toString()); - span.setAttribute(TrinoAttributes.HANDLE, handle.getConnectorHandle().toString()); + span.setAttribute(TrinoAttributes.CATALOG, handle.catalogHandle().getCatalogName().toString()); + span.setAttribute(TrinoAttributes.HANDLE, handle.connectorHandle().toString()); } return span; } diff --git a/core/trino-main/src/test/java/io/trino/execution/BaseDataDefinitionTaskTest.java b/core/trino-main/src/test/java/io/trino/execution/BaseDataDefinitionTaskTest.java index 2d2b0b308944..be6856872441 100644 --- a/core/trino-main/src/test/java/io/trino/execution/BaseDataDefinitionTaskTest.java +++ b/core/trino-main/src/test/java/io/trino/execution/BaseDataDefinitionTaskTest.java @@ -444,7 +444,7 @@ private ConnectorTableMetadata getTableMetadata(TableHandle tableHandle) private SchemaTableName getTableName(TableHandle tableHandle) { - return ((TestingTableHandle) tableHandle.getConnectorHandle()).getTableName(); + return ((TestingTableHandle) tableHandle.connectorHandle()).getTableName(); } @Override @@ -520,7 +520,7 @@ public void setMaterializedViewColumnComment(Session session, QualifiedObjectNam view.getCatalog(), view.getSchema(), view.getColumns().stream() - .map(currentViewColumn -> columnName.equals(currentViewColumn.getName()) ? new ViewColumn(currentViewColumn.getName(), currentViewColumn.getType(), comment) : currentViewColumn) + .map(currentViewColumn -> columnName.equals(currentViewColumn.name()) ? new ViewColumn(currentViewColumn.name(), currentViewColumn.type(), comment) : currentViewColumn) .collect(toImmutableList()), view.getGracePeriod(), view.getComment(), @@ -616,7 +616,7 @@ public void setViewColumnComment(Session session, QualifiedObjectName viewName, view.getCatalog(), view.getSchema(), view.getColumns().stream() - .map(currentViewColumn -> columnName.equals(currentViewColumn.getName()) ? new ViewColumn(currentViewColumn.getName(), currentViewColumn.getType(), comment) : currentViewColumn) + .map(currentViewColumn -> columnName.equals(currentViewColumn.name()) ? new ViewColumn(currentViewColumn.name(), currentViewColumn.type(), comment) : currentViewColumn) .collect(toImmutableList()), view.getComment(), view.getRunAsIdentity(), diff --git a/core/trino-main/src/test/java/io/trino/execution/TaskTestUtils.java b/core/trino-main/src/test/java/io/trino/execution/TaskTestUtils.java index ebe717b3ac46..da2dd1f46341 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TaskTestUtils.java +++ b/core/trino-main/src/test/java/io/trino/execution/TaskTestUtils.java @@ -80,7 +80,7 @@ private TaskTestUtils() {} public static final PlanNodeId TABLE_SCAN_NODE_ID = new PlanNodeId("tableScan"); - private static final CatalogHandle CATALOG_HANDLE = TEST_TABLE_HANDLE.getCatalogHandle(); + private static final CatalogHandle CATALOG_HANDLE = TEST_TABLE_HANDLE.catalogHandle(); public static final ScheduledSplit SPLIT = new ScheduledSplit(0, TABLE_SCAN_NODE_ID, new Split(CATALOG_HANDLE, TestingSplit.createLocalSplit())); diff --git a/core/trino-main/src/test/java/io/trino/execution/TestCommentTask.java b/core/trino-main/src/test/java/io/trino/execution/TestCommentTask.java index 0748ca4bf702..1b4618309e23 100644 --- a/core/trino-main/src/test/java/io/trino/execution/TestCommentTask.java +++ b/core/trino-main/src/test/java/io/trino/execution/TestCommentTask.java @@ -134,7 +134,7 @@ public void testCommentViewColumn() assertThat(metadata.isView(testSession, viewName)).isTrue(); getFutureValue(setComment(COLUMN, columnName, Optional.of("new test column comment"))); - assertThat(metadata.getView(testSession, viewName).get().getColumns().stream().filter(column -> "test".equals(column.getName())).collect(onlyElement()).getComment()) + assertThat(metadata.getView(testSession, viewName).get().getColumns().stream().filter(column -> "test".equals(column.name())).collect(onlyElement()).comment()) .isEqualTo(Optional.of("new test column comment")); assertTrinoExceptionThrownBy(() -> getFutureValue(setComment(COLUMN, missingColumnName, Optional.of("comment for missing column")))) @@ -153,7 +153,7 @@ public void testCommentMaterializedViewColumn() QualifiedName missingColumnName = qualifiedColumnName("existing_materialized_view", "missing"); getFutureValue(setComment(COLUMN, columnName, Optional.of("new test column comment"))); - assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getColumns().stream().filter(column -> "test".equals(column.getName())).collect(onlyElement()).getComment()) + assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getColumns().stream().filter(column -> "test".equals(column.name())).collect(onlyElement()).comment()) .isEqualTo(Optional.of("new test column comment")); assertTrinoExceptionThrownBy(() -> getFutureValue(setComment(COLUMN, missingColumnName, Optional.of("comment for missing column")))) diff --git a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java index a1be71f611c4..aab7348ba32f 100644 --- a/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java +++ b/core/trino-main/src/test/java/io/trino/sql/analyzer/TestAnalyzer.java @@ -3532,12 +3532,12 @@ public void testAnalysisDuplicateNames() // Materialized view redirects to "t1" Analysis analysis = analyze("SELECT * FROM table_view_and_materialized_view"); TableHandle handle = getOnlyElement(analysis.getTables()); - assertThat(((TestingTableHandle) handle.getConnectorHandle()).getTableName().getTableName()).isEqualTo("t1"); + assertThat(((TestingTableHandle) handle.connectorHandle()).getTableName().getTableName()).isEqualTo("t1"); // View redirects to "t2" analysis = analyze("SELECT * FROM table_and_view"); handle = getOnlyElement(analysis.getTables()); - assertThat(((TestingTableHandle) handle.getConnectorHandle()).getTableName().getTableName()).isEqualTo("t2"); + assertThat(((TestingTableHandle) handle.connectorHandle()).getTableName().getTableName()).isEqualTo("t2"); } @Test diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java index f886c04a229e..7d33868d308a 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestEffectivePredicateExtractor.java @@ -147,7 +147,7 @@ public TableProperties getTableProperties(Session session, TableHandle handle) TEST_CATALOG_HANDLE, TestingConnectorTransactionHandle.INSTANCE, new ConnectorTableProperties( - ((PredicatedTableHandle) handle.getConnectorHandle()).getPredicate(), + ((PredicatedTableHandle) handle.connectorHandle()).getPredicate(), Optional.empty(), Optional.empty(), ImmutableList.of())); diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/TestJsonTable.java b/core/trino-main/src/test/java/io/trino/sql/planner/TestJsonTable.java index 1891083d218d..30828cf0d7bc 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/TestJsonTable.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/TestJsonTable.java @@ -551,7 +551,7 @@ private void assertJsonTablePlan(@Language("SQL") String sql, JsonTablePlanNode getPlanTester().inTransaction(transactionSession -> { Plan queryPlan = getPlanTester().createPlan(transactionSession, sql, ImmutableList.of(), CREATED, WarningCollector.NOOP, createPlanOptimizersStatsCollector()); TableFunctionNode tableFunctionNode = (TableFunctionNode) getOnlyElement(PlanNodeSearcher.searchFrom(queryPlan.getRoot()).where(TableFunctionNode.class::isInstance).findAll()); - JsonTablePlanNode actualPlan = ((JsonTable.JsonTableFunctionHandle) tableFunctionNode.getHandle().getFunctionHandle()).processingPlan(); + JsonTablePlanNode actualPlan = ((JsonTable.JsonTableFunctionHandle) tableFunctionNode.getHandle().functionHandle()).processingPlan(); assertThat(actualPlan) .usingComparator(planComparator()) .isEqualTo(expectedPlan); diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/ConnectorAwareTableScanMatcher.java b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/ConnectorAwareTableScanMatcher.java index 7526bb819ca8..dbf56a362c91 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/assertions/ConnectorAwareTableScanMatcher.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/assertions/ConnectorAwareTableScanMatcher.java @@ -63,7 +63,7 @@ public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session ses TupleDomain actual = tableScanNode.getEnforcedConstraint(); - boolean tableMatches = expectedTable.test(tableScanNode.getTable().getConnectorHandle()); + boolean tableMatches = expectedTable.test(tableScanNode.getTable().connectorHandle()); boolean domainsMatch = domainsMatch(expectedEnforcedConstraint, actual); boolean statisticMatch = expectedStatistics.test(tableScanNode.getStatistics()); diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestDetermineTableScanNodePartitioning.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestDetermineTableScanNodePartitioning.java index d99e3feea531..b8a1da7b82bc 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestDetermineTableScanNodePartitioning.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestDetermineTableScanNodePartitioning.java @@ -155,7 +155,7 @@ private void testPlanWithTableNodePartitioning( }) .matches( tableScan( - tableHandle.getConnectorHandle()::equals, + tableHandle.connectorHandle()::equals, TupleDomain.all(), ImmutableMap.of( "A", COLUMN_HANDLE_A::equals, diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java index 27ce5ad88f7f..1f98fede465d 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/TestPushDownDereferencesRules.java @@ -351,7 +351,7 @@ public void testExtractDereferencesFromFilterAboveScan() "a", expression(new Reference(nestedRowType, "a")), "b", expression(new Reference(ROW_TYPE, "b"))), tableScan( - testTable.getConnectorHandle()::equals, + testTable.connectorHandle()::equals, TupleDomain.all(), ImmutableMap.of( "a", new TpchColumnHandle("a", nestedRowType)::equals, diff --git a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PlanBuilder.java b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PlanBuilder.java index d5ee038e8c0a..59d440a27a08 100644 --- a/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PlanBuilder.java +++ b/core/trino-main/src/test/java/io/trino/sql/planner/iterative/rule/test/PlanBuilder.java @@ -867,7 +867,7 @@ public IndexSourceNode indexSource( return new IndexSourceNode( idAllocator.getNextId(), new IndexHandle( - tableHandle.getCatalogHandle(), + tableHandle.catalogHandle(), TestingConnectorTransactionHandle.INSTANCE, TestingConnectorIndexHandle.INSTANCE), tableHandle, diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeNodeLocalDynamicSplitPruning.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeNodeLocalDynamicSplitPruning.java index 23c4021abc1b..0f138d5ae673 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeNodeLocalDynamicSplitPruning.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeNodeLocalDynamicSplitPruning.java @@ -335,7 +335,7 @@ private static ConnectorPageSource createTestingPageSource( transaction, getSession(deltaLakeConfig), split, - tableHandle.getConnectorHandle(), + tableHandle.connectorHandle(), columns, dynamicFilter); } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeProjectionPushdownPlans.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeProjectionPushdownPlans.java index bd96e9f46a1e..69bb1df51727 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeProjectionPushdownPlans.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeProjectionPushdownPlans.java @@ -179,7 +179,7 @@ public void testDereferencePushdown() assertPlan( "SELECT col0.x expr_x, col0.y expr_y FROM " + testTable, any(tableScan( - equalTo(((DeltaLakeTableHandle) tableHandle.get().getConnectorHandle()).withProjectedColumns(Set.of(columnX, columnY))), + equalTo(((DeltaLakeTableHandle) tableHandle.get().connectorHandle()).withProjectedColumns(Set.of(columnX, columnY))), TupleDomain.all(), ImmutableMap.of("col0.x", equalTo(columnX), "col0.y", equalTo(columnY))))); @@ -251,7 +251,7 @@ public void testDereferencePushdown() .right( anyTree( tableScan( - equalTo(((DeltaLakeTableHandle) tableHandle.get().getConnectorHandle()).withProjectedColumns(Set.of(column1Handle))), + equalTo(((DeltaLakeTableHandle) tableHandle.get().connectorHandle()).withProjectedColumns(Set.of(column1Handle))), TupleDomain.all(), ImmutableMap.of("s_expr_1", equalTo(column1Handle))))); })))); diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index ce9d00a53e4e..a400228843c5 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -3814,7 +3814,7 @@ private Object getHiveTableProperty(String tableName, Function new AssertionError("applyFilter did not return a result")) .getHandle(); - return propertyGetter.apply((HiveTableHandle) table.getConnectorHandle()); + return propertyGetter.apply((HiveTableHandle) table.connectorHandle()); }); } diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestNodeLocalDynamicSplitPruning.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestNodeLocalDynamicSplitPruning.java index 52c13e20554a..2c8738bdedc7 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestNodeLocalDynamicSplitPruning.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestNodeLocalDynamicSplitPruning.java @@ -165,7 +165,7 @@ private static ConnectorPageSource createTestingPageSource(HiveTransactionHandle transaction, getSession(hiveConfig), split, - tableHandle.getConnectorHandle(), + tableHandle.connectorHandle(), ImmutableList.of(BUCKET_HIVE_COLUMN_HANDLE, PARTITION_HIVE_COLUMN_HANDLE), dynamicFilter); } diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/optimizer/TestHiveProjectionPushdownIntoTableScan.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/optimizer/TestHiveProjectionPushdownIntoTableScan.java index f643bab995e7..619901020c97 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/optimizer/TestHiveProjectionPushdownIntoTableScan.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/optimizer/TestHiveProjectionPushdownIntoTableScan.java @@ -168,7 +168,7 @@ public void testDereferencePushdown() assertPlan( "SELECT col0.x expr_x, col0.y expr_y FROM " + testTable, any(tableScan( - ((HiveTableHandle) tableHandle.get().getConnectorHandle()) + ((HiveTableHandle) tableHandle.get().connectorHandle()) .withProjectedColumns(ImmutableSet.of(columnX, columnY))::equals, TupleDomain.all(), ImmutableMap.of("col0#x", columnX::equals, "col0#y", columnY::equals)))); @@ -230,7 +230,7 @@ public void testDereferencePushdown() .right( anyTree( tableScan( - ((HiveTableHandle) tableHandle.get().getConnectorHandle()) + ((HiveTableHandle) tableHandle.get().connectorHandle()) .withProjectedColumns(ImmutableSet.of(column1Handle))::equals, TupleDomain.all(), ImmutableMap.of("s_expr_1", column1Handle::equals)))))))); diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java index 9f72fcf068e2..fe2e1927c96f 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java @@ -3932,7 +3932,7 @@ private void assertFilterPushdown( assertThat((expectedUnenforcedPredicate == null && expectedEnforcedPredicate == null)).isEqualTo(result.isEmpty()); if (result.isPresent()) { - IcebergTableHandle newTable = (IcebergTableHandle) result.get().getHandle().getConnectorHandle(); + IcebergTableHandle newTable = (IcebergTableHandle) result.get().getHandle().connectorHandle(); assertThat(newTable.getEnforcedPredicate()).isEqualTo(TupleDomain.withColumnDomains(expectedEnforcedPredicate.entrySet().stream() .collect(toImmutableMap(entry -> columns.get(entry.getKey()), Map.Entry::getValue)))); diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergNodeLocalDynamicSplitPruning.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergNodeLocalDynamicSplitPruning.java index 360b165ad0f0..58e05af7da68 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergNodeLocalDynamicSplitPruning.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergNodeLocalDynamicSplitPruning.java @@ -578,7 +578,7 @@ private static ConnectorPageSource createTestingPageSource( transaction, getSession(icebergConfig), split, - tableHandle.getConnectorHandle(), + tableHandle.connectorHandle(), columns, dynamicFilter); } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergProjectionPushdownPlans.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergProjectionPushdownPlans.java index 7bffb6dba579..68b08555344c 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergProjectionPushdownPlans.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergProjectionPushdownPlans.java @@ -183,7 +183,7 @@ public void testDereferencePushdown() assertPlan( "SELECT col0.x expr_x, col0.y expr_y FROM " + testTable, any(tableScan( - equalTo(((IcebergTableHandle) tableHandle.get().getConnectorHandle()).withProjectedColumns(Set.of(columnX, columnY))), + equalTo(((IcebergTableHandle) tableHandle.get().connectorHandle()).withProjectedColumns(Set.of(columnX, columnY))), TupleDomain.all(), ImmutableMap.of("col0#x", equalTo(columnX), "col0#y", equalTo(columnY))))); @@ -233,7 +233,7 @@ public void testDereferencePushdown() .left( anyTree( tableScan( - equalTo(((IcebergTableHandle) tableHandle.get().getConnectorHandle()).withProjectedColumns(Set.of(column1Handle))), + equalTo(((IcebergTableHandle) tableHandle.get().connectorHandle()).withProjectedColumns(Set.of(column1Handle))), TupleDomain.all(), ImmutableMap.of("s_expr_1", equalTo(column1Handle))))) .right( diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/optimizer/TestConnectorPushdownRulesWithIceberg.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/optimizer/TestConnectorPushdownRulesWithIceberg.java index 1f8748b91356..5d7cc69e655c 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/optimizer/TestConnectorPushdownRulesWithIceberg.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/optimizer/TestConnectorPushdownRulesWithIceberg.java @@ -239,7 +239,7 @@ public void testPredicatePushdown() { String tableName = "predicate_test"; tester().getPlanTester().executeStatement(format("CREATE TABLE %s (a, b) AS SELECT 5, 6", tableName)); - long snapshotId = ((IcebergTableHandle) tester().getPlanTester().getTableHandle(TEST_CATALOG_NAME, SCHEMA_NAME, tableName).getConnectorHandle()).getSnapshotId().orElseThrow(); + long snapshotId = ((IcebergTableHandle) tester().getPlanTester().getTableHandle(TEST_CATALOG_NAME, SCHEMA_NAME, tableName).connectorHandle()).getSnapshotId().orElseThrow(); PushPredicateIntoTableScan pushPredicateIntoTableScan = new PushPredicateIntoTableScan(tester().getPlannerContext(), false); diff --git a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoProjectionPushdownPlans.java b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoProjectionPushdownPlans.java index 01a86a666bf3..63a23b0d021d 100644 --- a/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoProjectionPushdownPlans.java +++ b/plugin/trino-mongodb/src/test/java/io/trino/plugin/mongodb/TestMongoProjectionPushdownPlans.java @@ -150,7 +150,7 @@ public void testDereferencePushdown() Optional tableHandle = getTableHandle(session, completeTableName); assertThat(tableHandle).as("expected the table handle to be present").isPresent(); - MongoTableHandle mongoTableHandle = (MongoTableHandle) tableHandle.get().getConnectorHandle(); + MongoTableHandle mongoTableHandle = (MongoTableHandle) tableHandle.get().connectorHandle(); Map columns = getColumnHandles(session, completeTableName); MongoColumnHandle column0Handle = (MongoColumnHandle) columns.get("col0"); @@ -247,7 +247,7 @@ public void testDereferencePushdownWithDotAndDollarContainingField() Optional tableHandle = getTableHandle(session, completeTableName); assertThat(tableHandle).as("expected the table handle to be present").isPresent(); - MongoTableHandle mongoTableHandle = (MongoTableHandle) tableHandle.get().getConnectorHandle(); + MongoTableHandle mongoTableHandle = (MongoTableHandle) tableHandle.get().connectorHandle(); Map columns = getColumnHandles(session, completeTableName); RowType rowType = RowType.rowType( diff --git a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java index f222b4e7444b..35fcb9c81a83 100644 --- a/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java +++ b/testing/trino-testing/src/main/java/io/trino/testing/AbstractTestQueryFramework.java @@ -722,7 +722,7 @@ private CatalogSchemaTableName getTableName(TableHandle tableHandle) { return inTransaction(getSession(), transactionSession -> { // metadata.getCatalogHandle() registers the catalog for the transaction - getQueryRunner().getPlannerContext().getMetadata().getCatalogHandle(transactionSession, tableHandle.getCatalogHandle().getCatalogName().toString()); + getQueryRunner().getPlannerContext().getMetadata().getCatalogHandle(transactionSession, tableHandle.catalogHandle().getCatalogName().toString()); return getQueryRunner().getPlannerContext().getMetadata().getTableName(transactionSession, tableHandle); }); } diff --git a/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java b/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java index e89094adb2e4..bfb8b1f903d7 100644 --- a/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java +++ b/testing/trino-tests/src/test/java/io/trino/execution/TestTableRedirection.java @@ -410,7 +410,7 @@ public void testInsert() .where(TableFinishNode.class::isInstance) .findOnlyElement(); TableWriterNode.InsertTarget insertTarget = ((TableWriterNode.InsertTarget) finishNode.getTarget()); - assertThat(((MockConnectorInsertTableHandle) insertTarget.getHandle().getConnectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); + assertThat(((MockConnectorInsertTableHandle) insertTarget.getHandle().connectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); assertThat(insertTarget.getSchemaTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); }); } @@ -428,7 +428,7 @@ public void testDelete() .where(TableFinishNode.class::isInstance) .findOnlyElement(); TableWriterNode.MergeTarget mergeTarget = (TableWriterNode.MergeTarget) finishNode.getTarget(); - assertThat(((MockConnectorTableHandle) mergeTarget.getHandle().getConnectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); + assertThat(((MockConnectorTableHandle) mergeTarget.getHandle().connectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); assertThat(mergeTarget.getSchemaTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); }); } @@ -446,7 +446,7 @@ public void testUpdate() .where(TableFinishNode.class::isInstance) .findOnlyElement(); TableWriterNode.MergeTarget mergeTarget = (TableWriterNode.MergeTarget) finishNode.getTarget(); - assertThat(((MockConnectorTableHandle) mergeTarget.getHandle().getConnectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); + assertThat(((MockConnectorTableHandle) mergeTarget.getHandle().connectorHandle()).getTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); assertThat(mergeTarget.getSchemaTableName()).isEqualTo(schemaTableName(SCHEMA_TWO, VALID_REDIRECTION_TARGET)); }); } @@ -466,7 +466,7 @@ private Consumer verifySingleTableScan(String schemaName, String tableName TableScanNode tableScan = (TableScanNode) searchFrom(plan.getRoot()) .where(TableScanNode.class::isInstance) .findOnlyElement(); - SchemaTableName actual = ((MockConnectorTableHandle) tableScan.getTable().getConnectorHandle()).getTableName(); + SchemaTableName actual = ((MockConnectorTableHandle) tableScan.getTable().connectorHandle()).getTableName(); assertThat(actual).isEqualTo(schemaTableName(schemaName, tableName)); }; }