Search in sources :

Example 6 with Procedure

use of io.trino.spi.procedure.Procedure in project trino by trinodb.

the class ProcedureRegistry method addProcedures.

public void addProcedures(CatalogName catalogName, Collection<Procedure> procedures) {
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(procedures, "procedures is null");
    procedures.forEach(this::validateProcedure);
    Map<SchemaTableName, Procedure> proceduresByName = Maps.uniqueIndex(procedures, procedure -> new SchemaTableName(procedure.getSchema(), procedure.getName()));
    checkState(connectorProcedures.putIfAbsent(catalogName, proceduresByName) == null, "Procedures already registered for connector: %s", catalogName);
}
Also used : Procedure(io.trino.spi.procedure.Procedure) SchemaTableName(io.trino.spi.connector.SchemaTableName)

Example 7 with Procedure

use of io.trino.spi.procedure.Procedure in project trino by trinodb.

the class ProcedureRegistry method validateProcedure.

private void validateProcedure(Procedure procedure) {
    List<Class<?>> parameters = procedure.getMethodHandle().type().parameterList().stream().filter(type -> !ConnectorSession.class.equals(type)).filter(type -> !ConnectorAccessControl.class.equals(type)).collect(toList());
    for (int i = 0; i < procedure.getArguments().size(); i++) {
        Argument argument = procedure.getArguments().get(i);
        Type type = argument.getType();
        Class<?> argumentType = Primitives.unwrap(parameters.get(i));
        Class<?> expectedType = getObjectType(type);
        checkArgument(expectedType.equals(argumentType), "Argument '%s' has invalid type %s (expected %s)", argument.getName(), argumentType.getName(), expectedType.getName());
    }
}
Also used : PROCEDURE_NOT_FOUND(io.trino.spi.StandardErrorCode.PROCEDURE_NOT_FOUND) Type(io.trino.spi.type.Type) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) CatalogName(io.trino.connector.CatalogName) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) Procedure(io.trino.spi.procedure.Procedure) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Argument(io.trino.spi.procedure.Procedure.Argument) MapType(io.trino.spi.type.MapType) Collection(java.util.Collection) ConnectorAccessControl(io.trino.spi.connector.ConnectorAccessControl) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TrinoException(io.trino.spi.TrinoException) ArrayType(io.trino.spi.type.ArrayType) ThreadSafe(javax.annotation.concurrent.ThreadSafe) ConnectorSession(io.trino.spi.connector.ConnectorSession) Maps(com.google.common.collect.Maps) SchemaTableName(io.trino.spi.connector.SchemaTableName) Primitives(com.google.common.primitives.Primitives) Preconditions.checkState(com.google.common.base.Preconditions.checkState) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) BIGINT(io.trino.spi.type.BigintType.BIGINT) Type(io.trino.spi.type.Type) MapType(io.trino.spi.type.MapType) ArrayType(io.trino.spi.type.ArrayType) ConnectorAccessControl(io.trino.spi.connector.ConnectorAccessControl) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Argument(io.trino.spi.procedure.Procedure.Argument)

Example 8 with Procedure

use of io.trino.spi.procedure.Procedure in project trino by trinodb.

the class DeltaLakeModule method setup.

@Override
public void setup(Binder binder) {
    Provider<CatalogName> catalogName = binder.getProvider(CatalogName.class);
    configBinder(binder).bindConfig(DeltaLakeConfig.class);
    configBinder(binder).bindConfig(HiveConfig.class);
    // currently not configurable
    binder.bind(MetastoreConfig.class).toInstance(new MetastoreConfig());
    configBinder(binder).bindConfig(ParquetReaderConfig.class);
    configBinder(binder).bindConfig(ParquetWriterConfig.class);
    Multibinder<SystemTableProvider> systemTableProviders = newSetBinder(binder, SystemTableProvider.class);
    systemTableProviders.addBinding().to(PropertiesSystemTableProvider.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeSessionProperties.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeTableProperties.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeAnalyzeProperties.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeTransactionManager.class).in(Scopes.SINGLETON);
    binder.bind(ConnectorSplitManager.class).to(DeltaLakeSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(ConnectorPageSourceProvider.class).to(DeltaLakePageSourceProvider.class).in(Scopes.SINGLETON);
    binder.bind(ConnectorPageSinkProvider.class).to(DeltaLakePageSinkProvider.class).in(Scopes.SINGLETON);
    binder.bind(ConnectorNodePartitioningProvider.class).to(DeltaLakeNodePartitioningProvider.class).in(Scopes.SINGLETON);
    binder.bind(LocationService.class).to(HiveLocationService.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeMetadataFactory.class).in(Scopes.SINGLETON);
    binder.bind(CachingDeltaLakeStatisticsAccess.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeStatisticsAccess.class).to(CachingDeltaLakeStatisticsAccess.class).in(Scopes.SINGLETON);
    binder.bind(DeltaLakeStatisticsAccess.class).annotatedWith(ForCachingDeltaLakeStatisticsAccess.class).to(MetaDirStatisticsAccess.class).in(Scopes.SINGLETON);
    jsonCodecBinder(binder).bindJsonCodec(DeltaLakeStatistics.class);
    binder.bind(HiveTransactionManager.class).in(Scopes.SINGLETON);
    binder.bind(CheckpointSchemaManager.class).in(Scopes.SINGLETON);
    jsonCodecBinder(binder).bindJsonCodec(LastCheckpoint.class);
    binder.bind(CheckpointWriterManager.class).in(Scopes.SINGLETON);
    binder.bind(TransactionLogAccess.class).in(Scopes.SINGLETON);
    newExporter(binder).export(TransactionLogAccess.class).as(generator -> generator.generatedNameOf(TransactionLogAccess.class, catalogName.get().toString()));
    binder.bind(TransactionLogWriterFactory.class).in(Scopes.SINGLETON);
    binder.bind(TransactionLogSynchronizerManager.class).in(Scopes.SINGLETON);
    binder.bind(NoIsolationSynchronizer.class).in(Scopes.SINGLETON);
    MapBinder<String, TransactionLogSynchronizer> logSynchronizerMapBinder = newMapBinder(binder, String.class, TransactionLogSynchronizer.class);
    // S3
    jsonCodecBinder(binder).bindJsonCodec(S3TransactionLogSynchronizer.LockFileContents.class);
    logSynchronizerMapBinder.addBinding("s3").to(S3TransactionLogSynchronizer.class).in(Scopes.SINGLETON);
    logSynchronizerMapBinder.addBinding("s3a").to(S3TransactionLogSynchronizer.class).in(Scopes.SINGLETON);
    logSynchronizerMapBinder.addBinding("s3n").to(S3TransactionLogSynchronizer.class).in(Scopes.SINGLETON);
    // Azure
    logSynchronizerMapBinder.addBinding("abfs").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON);
    logSynchronizerMapBinder.addBinding("abfss").to(AzureTransactionLogSynchronizer.class).in(Scopes.SINGLETON);
    jsonCodecBinder(binder).bindJsonCodec(DataFileInfo.class);
    jsonCodecBinder(binder).bindJsonCodec(DeltaLakeUpdateResult.class);
    binder.bind(DeltaLakeWriterStats.class).in(Scopes.SINGLETON);
    binder.bind(FileFormatDataSourceStats.class).in(Scopes.SINGLETON);
    newExporter(binder).export(FileFormatDataSourceStats.class).as(generator -> generator.generatedNameOf(FileFormatDataSourceStats.class, catalogName.get().toString()));
    Multibinder<Procedure> procedures = newSetBinder(binder, Procedure.class);
    procedures.addBinding().toProvider(DropExtendedStatsProcedure.class).in(Scopes.SINGLETON);
    procedures.addBinding().toProvider(VacuumProcedure.class).in(Scopes.SINGLETON);
    Multibinder<TableProcedureMetadata> tableProcedures = newSetBinder(binder, TableProcedureMetadata.class);
    tableProcedures.addBinding().toProvider(OptimizeTableProcedure.class).in(Scopes.SINGLETON);
}
Also used : AzureTransactionLogSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.AzureTransactionLogSynchronizer) MetaDirStatisticsAccess(io.trino.plugin.deltalake.statistics.MetaDirStatisticsAccess) PropertiesSystemTableProvider(io.trino.plugin.hive.PropertiesSystemTableProvider) NoIsolationSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.NoIsolationSynchronizer) OptimizeTableProcedure(io.trino.plugin.hive.procedure.OptimizeTableProcedure) CheckpointSchemaManager(io.trino.plugin.deltalake.transactionlog.checkpoint.CheckpointSchemaManager) TableProcedureMetadata(io.trino.spi.connector.TableProcedureMetadata) VacuumProcedure(io.trino.plugin.deltalake.procedure.VacuumProcedure) DropExtendedStatsProcedure(io.trino.plugin.deltalake.procedure.DropExtendedStatsProcedure) Procedure(io.trino.spi.procedure.Procedure) OptimizeTableProcedure(io.trino.plugin.hive.procedure.OptimizeTableProcedure) TransactionLogSynchronizerManager(io.trino.plugin.deltalake.transactionlog.writer.TransactionLogSynchronizerManager) HiveLocationService(io.trino.plugin.hive.HiveLocationService) MetastoreConfig(io.trino.plugin.hive.metastore.MetastoreConfig) TransactionLogWriterFactory(io.trino.plugin.deltalake.transactionlog.writer.TransactionLogWriterFactory) TransactionLogAccess(io.trino.plugin.deltalake.transactionlog.TransactionLogAccess) DropExtendedStatsProcedure(io.trino.plugin.deltalake.procedure.DropExtendedStatsProcedure) FileFormatDataSourceStats(io.trino.plugin.hive.FileFormatDataSourceStats) ForCachingDeltaLakeStatisticsAccess(io.trino.plugin.deltalake.statistics.CachingDeltaLakeStatisticsAccess.ForCachingDeltaLakeStatisticsAccess) CachingDeltaLakeStatisticsAccess(io.trino.plugin.deltalake.statistics.CachingDeltaLakeStatisticsAccess) DeltaLakeStatisticsAccess(io.trino.plugin.deltalake.statistics.DeltaLakeStatisticsAccess) VacuumProcedure(io.trino.plugin.deltalake.procedure.VacuumProcedure) S3TransactionLogSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.S3TransactionLogSynchronizer) TransactionLogSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.TransactionLogSynchronizer) S3TransactionLogSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.S3TransactionLogSynchronizer) AzureTransactionLogSynchronizer(io.trino.plugin.deltalake.transactionlog.writer.AzureTransactionLogSynchronizer) CatalogName(io.trino.plugin.base.CatalogName) ForCachingDeltaLakeStatisticsAccess(io.trino.plugin.deltalake.statistics.CachingDeltaLakeStatisticsAccess.ForCachingDeltaLakeStatisticsAccess) CachingDeltaLakeStatisticsAccess(io.trino.plugin.deltalake.statistics.CachingDeltaLakeStatisticsAccess) CheckpointWriterManager(io.trino.plugin.deltalake.transactionlog.checkpoint.CheckpointWriterManager) SystemTableProvider(io.trino.plugin.hive.SystemTableProvider) PropertiesSystemTableProvider(io.trino.plugin.hive.PropertiesSystemTableProvider) HiveTransactionManager(io.trino.plugin.hive.HiveTransactionManager)

Aggregations

Procedure (io.trino.spi.procedure.Procedure)8 ConnectorAccessControl (io.trino.spi.connector.ConnectorAccessControl)5 TableProcedureMetadata (io.trino.spi.connector.TableProcedureMetadata)4 Map (java.util.Map)4 Injector (com.google.inject.Injector)3 Key (com.google.inject.Key)3 Module (com.google.inject.Module)3 TypeLiteral (com.google.inject.TypeLiteral)3 Bootstrap (io.airlift.bootstrap.Bootstrap)3 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)3 EventModule (io.airlift.event.client.EventModule)3 JsonModule (io.airlift.json.JsonModule)3 CatalogName (io.trino.plugin.base.CatalogName)3 ClassLoaderSafeConnectorPageSinkProvider (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSinkProvider)3 ClassLoaderSafeConnectorPageSourceProvider (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorPageSourceProvider)3 ClassLoaderSafeConnectorSplitManager (io.trino.plugin.base.classloader.ClassLoaderSafeConnectorSplitManager)3 ClassLoaderSafeNodePartitioningProvider (io.trino.plugin.base.classloader.ClassLoaderSafeNodePartitioningProvider)3 MBeanServerModule (io.trino.plugin.base.jmx.MBeanServerModule)3 SessionPropertiesProvider (io.trino.plugin.base.session.SessionPropertiesProvider)3 HdfsAuthenticationModule (io.trino.plugin.hive.authentication.HdfsAuthenticationModule)3