Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@
import static io.trino.plugin.hive.HivePartitionManager.extractPartitionValues;
import static io.trino.plugin.hive.HiveSessionProperties.NON_TRANSACTIONAL_OPTIMIZE_ENABLED;
import static io.trino.plugin.hive.HiveSessionProperties.getCompressionCodec;
import static io.trino.plugin.hive.HiveSessionProperties.getDeltaLakeCatalogName;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change commit message to

Remove `HiveTableRedirectionsProvider` interface

import static io.trino.plugin.hive.HiveSessionProperties.getHiveStorageFormat;
import static io.trino.plugin.hive.HiveSessionProperties.getIcebergCatalogName;
import static io.trino.plugin.hive.HiveSessionProperties.getInsertExistingPartitionsBehavior;
import static io.trino.plugin.hive.HiveSessionProperties.getQueryPartitionFilterRequiredSchemas;
import static io.trino.plugin.hive.HiveSessionProperties.getTimestampPrecision;
Expand Down Expand Up @@ -364,7 +366,6 @@ public class HiveMetadata
private final Set<SystemTableProvider> systemTableProviders;
private final HiveMaterializedViewMetadata hiveMaterializedViewMetadata;
private final AccessControlMetadata accessControlMetadata;
private final HiveTableRedirectionsProvider tableRedirectionsProvider;
private final DirectoryLister directoryLister;

public HiveMetadata(
Expand All @@ -387,7 +388,6 @@ public HiveMetadata(
Set<SystemTableProvider> systemTableProviders,
HiveMaterializedViewMetadata hiveMaterializedViewMetadata,
AccessControlMetadata accessControlMetadata,
HiveTableRedirectionsProvider tableRedirectionsProvider,
DirectoryLister directoryLister)
{
this.catalogName = requireNonNull(catalogName, "catalogName is null");
Expand All @@ -409,7 +409,6 @@ public HiveMetadata(
this.systemTableProviders = requireNonNull(systemTableProviders, "systemTableProviders is null");
this.hiveMaterializedViewMetadata = requireNonNull(hiveMaterializedViewMetadata, "hiveMaterializedViewMetadata is null");
this.accessControlMetadata = requireNonNull(accessControlMetadata, "accessControlMetadata is null");
this.tableRedirectionsProvider = requireNonNull(tableRedirectionsProvider, "tableRedirectionsProvider is null");
this.directoryLister = requireNonNull(directoryLister, "directoryLister is null");
}

Expand Down Expand Up @@ -3534,7 +3533,8 @@ public Optional<CatalogSchemaTableName> redirectTable(ConnectorSession session,
return Optional.empty();
}

Optional<CatalogSchemaTableName> catalogSchemaTableName = tableRedirectionsProvider.redirectTable(session, table.get());
Optional<CatalogSchemaTableName> catalogSchemaTableName = redirectTableToIceberg(session, table.get())
.or(() -> redirectTableToDeltaLake(session, table.get()));

// stitch back the suffix we cut off.
return catalogSchemaTableName.map(name -> new CatalogSchemaTableName(
Expand All @@ -3544,6 +3544,30 @@ public Optional<CatalogSchemaTableName> redirectTable(ConnectorSession session,
name.getSchemaTableName().getTableName() + tableNameSplit.getSuffix().orElse(""))));
}

private Optional<CatalogSchemaTableName> redirectTableToIceberg(ConnectorSession session, Table table)
{
Optional<String> targetCatalogName = getIcebergCatalogName(session);
if (targetCatalogName.isEmpty()) {
return Optional.empty();
}
if (isIcebergTable(table)) {
return targetCatalogName.map(catalog -> new CatalogSchemaTableName(catalog, table.getSchemaTableName()));
}
return Optional.empty();
}

private Optional<CatalogSchemaTableName> redirectTableToDeltaLake(ConnectorSession session, Table table)
{
Optional<String> targetCatalogName = getDeltaLakeCatalogName(session);
if (targetCatalogName.isEmpty()) {
return Optional.empty();
}
if (isDeltaLakeTable(table)) {
return targetCatalogName.map(catalog -> new CatalogSchemaTableName(catalog, table.getSchemaTableName()));
}
return Optional.empty();
}

private static TableNameSplitResult splitTableName(String tableName)
{
int metadataMarkerIndex = tableName.lastIndexOf('$');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public class HiveMetadataFactory
private final HiveMaterializedViewMetadataFactory hiveMaterializedViewMetadataFactory;
private final AccessControlMetadataFactory accessControlMetadataFactory;
private final Optional<Duration> hiveTransactionHeartbeatInterval;
private final HiveTableRedirectionsProvider tableRedirectionsProvider;
private final ScheduledExecutorService heartbeatService;
private final DirectoryLister directoryLister;
private final long perTransactionFileStatusCacheMaximumSize;
Expand All @@ -92,7 +91,6 @@ public HiveMetadataFactory(
Set<SystemTableProvider> systemTableProviders,
HiveMaterializedViewMetadataFactory hiveMaterializedViewMetadataFactory,
AccessControlMetadataFactory accessControlMetadataFactory,
HiveTableRedirectionsProvider tableRedirectionsProvider,
DirectoryLister directoryLister)
{
this(
Expand Down Expand Up @@ -123,7 +121,6 @@ public HiveMetadataFactory(
systemTableProviders,
hiveMaterializedViewMetadataFactory,
accessControlMetadataFactory,
tableRedirectionsProvider,
directoryLister,
hiveConfig.getPerTransactionFileStatusCacheMaximumSize());
}
Expand Down Expand Up @@ -156,7 +153,6 @@ public HiveMetadataFactory(
Set<SystemTableProvider> systemTableProviders,
HiveMaterializedViewMetadataFactory hiveMaterializedViewMetadataFactory,
AccessControlMetadataFactory accessControlMetadataFactory,
HiveTableRedirectionsProvider tableRedirectionsProvider,
DirectoryLister directoryLister,
long perTransactionFileStatusCacheMaximumSize)
{
Expand All @@ -182,7 +178,6 @@ public HiveMetadataFactory(
this.systemTableProviders = requireNonNull(systemTableProviders, "systemTableProviders is null");
this.hiveMaterializedViewMetadataFactory = requireNonNull(hiveMaterializedViewMetadataFactory, "hiveMaterializedViewMetadataFactory is null");
this.accessControlMetadataFactory = requireNonNull(accessControlMetadataFactory, "accessControlMetadataFactory is null");
this.tableRedirectionsProvider = requireNonNull(tableRedirectionsProvider, "tableRedirectionsProvider is null");
this.hiveTransactionHeartbeatInterval = requireNonNull(hiveTransactionHeartbeatInterval, "hiveTransactionHeartbeatInterval is null");

renameExecution = new BoundedExecutor(executorService, maxConcurrentFileRenames);
Expand Down Expand Up @@ -240,7 +235,6 @@ public TransactionalMetadata create(ConnectorIdentity identity, boolean autoComm
systemTableProviders,
hiveMaterializedViewMetadataFactory.create(hiveMetastoreClosure),
accessControlMetadataFactory.create(metastore),
tableRedirectionsProvider,
directoryLister);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public void configure(Binder binder)
.setDefault().to(DefaultHiveMaterializedViewMetadataFactory.class).in(Scopes.SINGLETON);
newOptionalBinder(binder, TransactionalMetadataFactory.class)
.setDefault().to(HiveMetadataFactory.class).in(Scopes.SINGLETON);
newOptionalBinder(binder, HiveTableRedirectionsProvider.class)
.setDefault().to(DefaultHiveTableRedirectionsProvider.class);
binder.bind(HiveTransactionManager.class).in(Scopes.SINGLETON);
binder.bind(ConnectorSplitManager.class).to(HiveSplitManager.class).in(Scopes.SINGLETON);
newExporter(binder).export(ConnectorSplitManager.class).as(generator -> generator.generatedNameOf(HiveSplitManager.class));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@
import static io.trino.plugin.hive.HiveTableProperties.SORTED_BY_PROPERTY;
import static io.trino.plugin.hive.HiveTableProperties.STORAGE_FORMAT_PROPERTY;
import static io.trino.plugin.hive.HiveTableProperties.TRANSACTIONAL;
import static io.trino.plugin.hive.HiveTableRedirectionsProvider.NO_REDIRECTIONS;
import static io.trino.plugin.hive.HiveTestUtils.PAGE_SORTER;
import static io.trino.plugin.hive.HiveTestUtils.SESSION;
import static io.trino.plugin.hive.HiveTestUtils.arrayType;
Expand Down Expand Up @@ -871,7 +870,6 @@ public Optional<ConnectorMaterializedViewDefinition> getMaterializedView(Connect
}
},
SqlStandardAccessControlMetadata::new,
NO_REDIRECTIONS,
countingDirectoryLister,
1000);
transactionManager = new HiveTransactionManager(metadataFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
import static io.trino.plugin.hive.AbstractTestHive.filterNonHiddenColumnMetadata;
import static io.trino.plugin.hive.AbstractTestHive.getAllSplits;
import static io.trino.plugin.hive.AbstractTestHive.getSplits;
import static io.trino.plugin.hive.HiveTableRedirectionsProvider.NO_REDIRECTIONS;
import static io.trino.plugin.hive.HiveTestUtils.PAGE_SORTER;
import static io.trino.plugin.hive.HiveTestUtils.getDefaultHiveFileWriterFactories;
import static io.trino.plugin.hive.HiveTestUtils.getDefaultHivePageSourceFactories;
Expand Down Expand Up @@ -221,7 +220,6 @@ protected void setup(String host, int port, String databaseName, boolean s3Selec
new PropertiesSystemTableProvider()),
new DefaultHiveMaterializedViewMetadataFactory(),
SqlStandardAccessControlMetadata::new,
NO_REDIRECTIONS,
new FileSystemDirectoryLister());
transactionManager = new HiveTransactionManager(metadataFactory);
splitManager = new HiveSplitManager(
Expand Down