Interface ConnectorMetadata
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) Add the specified columndefault voidaddField(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> parentPath, String fieldName, Type type, boolean ignoreExisting) Add the specified field, potentially nested, to a row.applyAggregation(ConnectorSession session, ConnectorTableHandle handle, List<AggregateFunction> aggregates, Map<String, ColumnHandle> assignments, List<List<ColumnHandle>> groupingSets) Attempt to push down the aggregates into the table.default Optional<ConnectorTableHandle>applyDelete(ConnectorSession session, ConnectorTableHandle handle) Attempt to push down a delete operation into the connector.applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) Attempt to push down the provided constraint into the table.applyJoin(ConnectorSession session, JoinType joinType, ConnectorTableHandle left, ConnectorTableHandle right, ConnectorExpression joinCondition, Map<String, ColumnHandle> leftAssignments, Map<String, ColumnHandle> rightAssignments, JoinStatistics statistics) Attempt to push down the join operation.applyJoin(ConnectorSession session, JoinType joinType, ConnectorTableHandle left, ConnectorTableHandle right, List<JoinCondition> joinConditions, Map<String, ColumnHandle> leftAssignments, Map<String, ColumnHandle> rightAssignments, JoinStatistics statistics) Deprecated.applyLimit(ConnectorSession session, ConnectorTableHandle handle, long limit) Attempt to push down the provided limit into the table.applyProjection(ConnectorSession session, ConnectorTableHandle handle, List<ConnectorExpression> projections, Map<String, ColumnHandle> assignments) Attempt to push down the provided projections into the table.applySample(ConnectorSession session, ConnectorTableHandle handle, SampleType sampleType, double sampleRatio) Attempt to push down the sampling into the table.applyTableFunction(ConnectorSession session, ConnectorTableFunctionHandle handle) Attempt to push down the table function invocation into the connector.applyTableScanRedirect(ConnectorSession session, ConnectorTableHandle tableHandle) applyTopN(ConnectorSession session, ConnectorTableHandle handle, long topNCount, List<SortItem> sortItems, Map<String, ColumnHandle> assignments) Attempt to push down the TopN into the table scan.default Optional<ConnectorTableHandle>applyUpdate(ConnectorSession session, ConnectorTableHandle handle, Map<ColumnHandle, Constant> assignments) Attempt to push down an update operation into the connector.default ConnectorOutputTableHandlebeginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode) Deprecated.default ConnectorOutputTableHandlebeginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode, boolean replace) Begin the atomic creation of a table with data.default ConnectorInsertTableHandlebeginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode) Begin insert query.default ConnectorMergeTableHandlebeginMerge(ConnectorSession session, ConnectorTableHandle tableHandle, RetryMode retryMode) Do whatever is necessary to start an MERGE query, returning theConnectorMergeTableHandleinstance that will be passed to the PageSink, and to thefinishMerge(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorMergeTableHandle, java.util.Collection<io.airlift.slice.Slice>, java.util.Collection<io.trino.spi.statistics.ComputedStatistics>)method.default voidbeginQuery(ConnectorSession session) Start a query.default ConnectorInsertTableHandlebeginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles, RetryMode retryMode) Begin materialized view query.default ConnectorTableHandlebeginStatisticsCollection(ConnectorSession session, ConnectorTableHandle tableHandle) Begin statistics collectionbeginTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle, ConnectorTableHandle updatedSourceTableHandle) Begin execution of table proceduredefault voidcleanupQuery(ConnectorSession session) Cleanup after a query.default voidcreateLanguageFunction(ConnectorSession session, SchemaFunctionName name, LanguageFunction function, boolean replace) Creates a language function with the specified name and signature token.default voidcreateMaterializedView(ConnectorSession session, SchemaTableName viewName, ConnectorMaterializedViewDefinition definition, boolean replace, boolean ignoreExisting) Create the specified materialized view.default voidcreateRole(ConnectorSession session, String role, Optional<TrinoPrincipal> grantor) Creates the specified role.default voidcreateSchema(ConnectorSession session, String schemaName, Map<String, Object> properties, TrinoPrincipal owner) Creates a schema.default voidcreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting) default voidcreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, SaveMode saveMode) Creates a table using the specified table metadata.default voidcreateView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, boolean replace) Create the specified view.default booleandelegateMaterializedViewRefreshToConnector(ConnectorSession session, SchemaTableName viewName) Returns true if materialized view refresh should be delegated to connector usingrefreshMaterializedView(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTableName)default voiddenySchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee) Denys the specified privilege to the specified user on the specified schemadefault voiddenyTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee) Denys the specified privilege to the specified user on the specified tabledefault voiddropColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column) Drop the specified columndefault voiddropField(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, List<String> fieldPath) Drop the specified field, potentially nested, from a row.default voiddropLanguageFunction(ConnectorSession session, SchemaFunctionName name, String signatureToken) Drops a language function with the specified name and signature token.default voiddropMaterializedView(ConnectorSession session, SchemaTableName viewName) Drop the specified materialized view.default voiddropRole(ConnectorSession session, String role) Drops the specified role.default voiddropSchema(ConnectorSession session, String schemaName, boolean cascade) Drops the specified schema.default voiddropTable(ConnectorSession session, ConnectorTableHandle tableHandle) Drops the specified tabledefault voiddropView(ConnectorSession session, SchemaTableName viewName) Drop the specified view.default OptionalLongexecuteDelete(ConnectorSession session, ConnectorTableHandle handle) Execute the delete operation on the handle returned fromapplyDelete(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle).default voidexecuteTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle) Execute acoordinator-onlytable procedure.default OptionalLongexecuteUpdate(ConnectorSession session, ConnectorTableHandle handle) Execute the update operation on the handle returned fromapplyUpdate(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle, java.util.Map<io.trino.spi.connector.ColumnHandle, io.trino.spi.expression.Constant>).default Optional<ConnectorOutputMetadata>finishCreateTable(ConnectorSession session, ConnectorOutputTableHandle tableHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish a table creation with data after the data is written.default Optional<ConnectorOutputMetadata>finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish insert querydefault voidfinishMerge(ConnectorSession session, ConnectorMergeTableHandle mergeTableHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish a merge querydefault Optional<ConnectorOutputMetadata>finishRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, ConnectorInsertTableHandle insertHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics, List<ConnectorTableHandle> sourceTableHandles) Finish materialized view querydefault voidfinishStatisticsCollection(ConnectorSession session, ConnectorTableHandle tableHandle, Collection<ComputedStatistics> computedStatistics) Finish statistics collectiondefault voidfinishTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle, Collection<io.airlift.slice.Slice> fragments, List<Object> tableExecuteState) Finish table executedefault AggregationFunctionMetadatagetAggregationFunctionMetadata(ConnectorSession session, FunctionId functionId) Returns the aggregation metadata for the aggregation function with the specified id.default Map<String,ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) Gets all of the columns on the specified table, or an empty map if the columns cannot be enumerated.default ColumnMetadatagetColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) Gets the metadata for the specified table column.default Optional<ConnectorPartitioningHandle>getCommonPartitioningHandle(ConnectorSession session, ConnectorPartitioningHandle left, ConnectorPartitioningHandle right) Return a partitioning handle which the connector can transparently convert bothleftandrightinto.default FunctionDependencyDeclarationgetFunctionDependencies(ConnectorSession session, FunctionId functionId, BoundSignature boundSignature) Returns the dependencies of the function with the specified id.default FunctionMetadatagetFunctionMetadata(ConnectorSession session, FunctionId functionId) Return the function with the specified id.default Collection<FunctionMetadata>getFunctions(ConnectorSession session, SchemaFunctionName name) Get all functions with specified name.getInfo(ConnectorTableHandle table) default Optional<ConnectorTableLayout>getInsertLayout(ConnectorSession session, ConnectorTableHandle tableHandle) Get the physical layout for inserting into an existing table.default WriterScalingOptionsgetInsertWriterScalingOptions(ConnectorSession session, ConnectorTableHandle tableHandle) default Collection<LanguageFunction>getLanguageFunctions(ConnectorSession session, SchemaFunctionName name) Get all language functions with the specified name.default Optional<ConnectorTableLayout>getLayoutForTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle) getMaterializedView(ConnectorSession session, SchemaTableName viewName) Gets the materialized view data for the specified materialized view name.default MaterializedViewFreshnessgetMaterializedViewFreshness(ConnectorSession session, SchemaTableName name) The method is used by the engine to determine if a materialized view is current with respect to the tables it depends on.getMaterializedViews(ConnectorSession session, Optional<String> schemaName) Gets the definitions of materialized views, possibly filtered by schema.default OptionalIntgetMaxWriterTasks(ConnectorSession session) default ColumnHandlegetMergeRowIdColumnHandle(ConnectorSession session, ConnectorTableHandle tableHandle) Get the column handle that will generate row IDs for the merge operation.default Optional<ConnectorTableLayout>getNewTableLayout(ConnectorSession session, ConnectorTableMetadata tableMetadata) Get the physical layout for a new table.default WriterScalingOptionsgetNewTableWriterScalingOptions(ConnectorSession session, SchemaTableName tableName, Map<String, Object> tableProperties) default RowChangeParadigmgetRowChangeParadigm(ConnectorSession session, ConnectorTableHandle tableHandle) Return the row change paradigm supported by the connector on the table.default Optional<TrinoPrincipal>getSchemaOwner(ConnectorSession session, String schemaName) Get the schema properties for the specified schema.getSchemaProperties(ConnectorSession session, String schemaName) Gets the schema properties for the specified schema.default ConnectorAnalyzeMetadatagetStatisticsCollectionMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, Map<String, Object> analyzeProperties) Describe statistics that must be collected during a statistics collectiondefault TableStatisticsMetadatagetStatisticsCollectionMetadataForWrite(ConnectorSession session, ConnectorTableMetadata tableMetadata) Describes statistics that must be collected during a write.getSupportedType(ConnectorSession session, Map<String, Object> tableProperties, Type type) Return the effectiveTypethat is supported by the connector for the given type.default Optional<SystemTable>getSystemTable(ConnectorSession session, SchemaTableName tableName) Returns the system table for the specified table name, if one exists.default ConnectorTableHandlegetTableHandle(ConnectorSession session, SchemaTableName tableName) Deprecated.default ConnectorTableHandlegetTableHandle(ConnectorSession session, SchemaTableName tableName, Optional<ConnectorTableVersion> startVersion, Optional<ConnectorTableVersion> endVersion) Returns a table handle for the specified table name and version, ornulliftableNamerelation does not exist or is not a table (e.g.default Optional<ConnectorTableExecuteHandle>getTableHandleForExecute(ConnectorSession session, ConnectorTableHandle tableHandle, String procedureName, Map<String, Object> executeProperties, RetryMode retryMode) Create initial handle for execution of table procedure.default ConnectorTableMetadatagetTableMetadata(ConnectorSession session, ConnectorTableHandle table) Return the metadata for the specified table handle.default SchemaTableNamegetTableName(ConnectorSession session, ConnectorTableHandle table) Return schema table name for the specified table handle.default ConnectorTablePropertiesgetTableProperties(ConnectorSession session, ConnectorTableHandle table) default ConnectorTableSchemagetTableSchema(ConnectorSession session, ConnectorTableHandle table) Return table schema definition for the specified table handle.default TableStatisticsgetTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle) Get statistics for table.default Optional<ConnectorPartitioningHandle>getUpdateLayout(ConnectorSession session, ConnectorTableHandle tableHandle) Get the physical layout for updated or deleted rows of a MERGE operation.default Optional<ConnectorViewDefinition>getView(ConnectorSession session, SchemaTableName viewName) Gets the view data for the specified view name.default Map<SchemaTableName,ConnectorViewDefinition> getViews(ConnectorSession session, Optional<String> schemaName) Gets the definitions of views (but not materialized views), possibly filtered by schema.default voidgrantRoles(ConnectorSession connectorSession, Set<String> roles, Set<TrinoPrincipal> grantees, boolean adminOption, Optional<TrinoPrincipal> grantor) Grants the specified roles to the specified granteesdefault voidgrantSchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Grants the specified privilege to the specified user on the specified schemadefault voidgrantTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Grants the specified privilege to the specified user on the specified tabledefault booleanlanguageFunctionExists(ConnectorSession session, SchemaFunctionName name, String signatureToken) Check if a language function exists.listApplicableRoles(ConnectorSession session, TrinoPrincipal principal) List applicable roles, including the transitive grants, for the specified principallistEnabledRoles(ConnectorSession session) List applicable roles, including the transitive grants, in given sessiondefault Collection<FunctionMetadata>listFunctions(ConnectorSession session, String schemaName) List available functions.default Collection<LanguageFunction>listLanguageFunctions(ConnectorSession session, String schemaName) List available language functions.default List<SchemaTableName>listMaterializedViews(ConnectorSession session, Optional<String> schemaName) List materialized view names, possibly filtered by schema.listRoleGrants(ConnectorSession session, TrinoPrincipal principal) List role grants for a given principal, not recursively.listRoles(ConnectorSession session) List available roles.listSchemaNames(ConnectorSession session) Returns the schemas provided by this connector.default Map<SchemaTableName,List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) Deprecated.usestreamTableColumns(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTablePrefix)which handles redirected tableslistTablePrivileges(ConnectorSession session, SchemaTablePrefix prefix) List the table privileges granted to the specified grantee for the tables that have the specified prefix considering the selected session roledefault List<SchemaTableName>listTables(ConnectorSession session, Optional<String> schemaName) List table, view and materialized view names, possibly filtered by schema.default List<SchemaTableName>listViews(ConnectorSession session, Optional<String> schemaName) List view names (but not materialized views), possibly filtered by schema.default ConnectorTableHandlemakeCompatiblePartitioning(ConnectorSession session, ConnectorTableHandle tableHandle, ConnectorPartitioningHandle partitioningHandle) Return a table handle whose partitioning is converted to the provided partitioning handle, but otherwise identical to the provided table handle.default Optional<CatalogSchemaTableName>redirectTable(ConnectorSession session, SchemaTableName tableName) Redirects table to other table which may or may not be in the same catalog.default CompletableFuture<?>refreshMaterializedView(ConnectorSession session, SchemaTableName viewName) Refresh materialized viewdefault voidrenameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target) Rename the specified columndefault voidrenameField(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> fieldPath, String target) Rename the specified field, potentially nested, to a row.default voidrenameMaterializedView(ConnectorSession session, SchemaTableName source, SchemaTableName target) Rename the specified materialized viewdefault voidrenameSchema(ConnectorSession session, String source, String target) Renames the specified schema.default voidrenameTable(ConnectorSession session, ConnectorTableHandle tableHandle, SchemaTableName newTableName) Rename the specified tabledefault voidrenameView(ConnectorSession session, SchemaTableName source, SchemaTableName target) Rename the specified viewdefault Optional<ConnectorResolvedIndex>resolveIndex(ConnectorSession session, ConnectorTableHandle tableHandle, Set<ColumnHandle> indexableColumns, Set<ColumnHandle> outputColumns, TupleDomain<ColumnHandle> tupleDomain) Try to locate a table index that can lookup results by indexableColumns and provide the requested outputColumns.default voidrevokeRoles(ConnectorSession connectorSession, Set<String> roles, Set<TrinoPrincipal> grantees, boolean adminOption, Optional<TrinoPrincipal> grantor) Revokes the specified roles from the specified granteesdefault voidrevokeSchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Revokes the specified privilege on the specified schema from the specified userdefault voidrevokeTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Revokes the specified privilege on the specified table from the specified userdefault booleanroleExists(ConnectorSession session, String role) Does the specified role exist.default booleanschemaExists(ConnectorSession session, String schemaName) Checks if a schema exists.default voidsetColumnComment(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, Optional<String> comment) Comments to the specified columndefault voidsetColumnType(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, Type type) Set the specified column typedefault voidsetFieldType(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> fieldPath, Type type) Set the specified field typedefault voidsetMaterializedViewColumnComment(ConnectorSession session, SchemaTableName viewName, String columnName, Optional<String> comment) Comments to the specified materialized view column.default voidsetMaterializedViewProperties(ConnectorSession session, SchemaTableName viewName, Map<String, Optional<Object>> properties) Sets the properties of the specified materialized viewdefault voidsetSchemaAuthorization(ConnectorSession session, String schemaName, TrinoPrincipal principal) Sets the user/role on the specified schema.default voidsetTableAuthorization(ConnectorSession session, SchemaTableName tableName, TrinoPrincipal principal) Sets the user/role on the specified table.default voidsetTableComment(ConnectorSession session, ConnectorTableHandle tableHandle, Optional<String> comment) Comments to the specified tabledefault voidsetTableProperties(ConnectorSession session, ConnectorTableHandle tableHandle, Map<String, Optional<Object>> properties) Set properties to the specified tabledefault voidsetViewAuthorization(ConnectorSession session, SchemaTableName viewName, TrinoPrincipal principal) Sets the user/role on the specified view.default voidsetViewColumnComment(ConnectorSession session, SchemaTableName viewName, String columnName, Optional<String> comment) Comments to the specified view column.default voidsetViewComment(ConnectorSession session, SchemaTableName viewName, Optional<String> comment) Comments to the specified viewdefault Iterator<RelationColumnsMetadata>streamRelationColumns(ConnectorSession session, Optional<String> schemaName, UnaryOperator<Set<SchemaTableName>> relationFilter) Gets columns for all relations (tables, views, materialized views), possibly filtered by schemaName.default Iterator<RelationCommentMetadata>streamRelationComments(ConnectorSession session, Optional<String> schemaName, UnaryOperator<Set<SchemaTableName>> relationFilter) Gets comments for all relations (tables, views, materialized views), possibly filtered by schemaName.default Iterator<TableColumnsMetadata>streamTableColumns(ConnectorSession session, SchemaTablePrefix prefix) default booleandefault voidtruncateTable(ConnectorSession session, ConnectorTableHandle tableHandle) Truncates the specified tabledefault voidvalidateScan(ConnectorSession session, ConnectorTableHandle handle) Allows the connector to reject the table scan produced by the planner.
-
Field Details
-
MODIFYING_ROWS_MESSAGE
- See Also:
-
-
Method Details
-
schemaExists
Checks if a schema exists. The connector may have schemas that exist but are not enumerable vialistSchemaNames(io.trino.spi.connector.ConnectorSession). -
listSchemaNames
Returns the schemas provided by this connector. -
getTableHandle
@Nullable @Deprecated default ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) Deprecated.Returns a table handle for the specified table name, ornulliftableNamerelation does not exist or is not a table (e.g. is a view, or a materialized view).- Throws:
TrinoException- implementation can throw this exception whentableNamerefers to a table that cannot be queried.- See Also:
-
getTableHandle
@Nullable default ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName, Optional<ConnectorTableVersion> startVersion, Optional<ConnectorTableVersion> endVersion) Returns a table handle for the specified table name and version, ornulliftableNamerelation does not exist or is not a table (e.g. is a view, or a materialized view).- Throws:
TrinoException- implementation can throw this exception whentableNamerefers to a table that cannot be queried.- See Also:
-
getTableHandleForExecute
default Optional<ConnectorTableExecuteHandle> getTableHandleForExecute(ConnectorSession session, ConnectorTableHandle tableHandle, String procedureName, Map<String, Object> executeProperties, RetryMode retryMode) Create initial handle for execution of table procedure. The handle will be used through planning process. It will be converted to final handle used for execution via @{linkbeginTableExecute(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableExecuteHandle, io.trino.spi.connector.ConnectorTableHandle)If connector does not support execution with retries, the method should throw:
new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")unlessretryModeis set toNO_RETRIES. -
getLayoutForTableExecute
default Optional<ConnectorTableLayout> getLayoutForTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle) -
beginTableExecute
default BeginTableExecuteResult<ConnectorTableExecuteHandle,ConnectorTableHandle> beginTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle, ConnectorTableHandle updatedSourceTableHandle) Begin execution of table procedure -
finishTableExecute
default void finishTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle, Collection<io.airlift.slice.Slice> fragments, List<Object> tableExecuteState) Finish table execute- Parameters:
fragments- all fragments returned byConnectorPageSink.finish()
-
executeTableExecute
default void executeTableExecute(ConnectorSession session, ConnectorTableExecuteHandle tableExecuteHandle) Execute acoordinator-onlytable procedure. -
getSystemTable
Returns the system table for the specified table name, if one exists. The system tables handled via this method differ form those returned byConnector.getSystemTables(). The former mechanism allows dynamic resolution of system tables, while the latter is based on static list of system tables built during startup. -
makeCompatiblePartitioning
default ConnectorTableHandle makeCompatiblePartitioning(ConnectorSession session, ConnectorTableHandle tableHandle, ConnectorPartitioningHandle partitioningHandle) Return a table handle whose partitioning is converted to the provided partitioning handle, but otherwise identical to the provided table handle. The provided table handle must be one that the connector can transparently convert to from the original partitioning handle associated with the provided table handle, as promised bygetCommonPartitioningHandle(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorPartitioningHandle, io.trino.spi.connector.ConnectorPartitioningHandle). -
getCommonPartitioningHandle
default Optional<ConnectorPartitioningHandle> getCommonPartitioningHandle(ConnectorSession session, ConnectorPartitioningHandle left, ConnectorPartitioningHandle right) Return a partitioning handle which the connector can transparently convert bothleftandrightinto. -
getTableName
Return schema table name for the specified table handle. This method is useful when requiring onlySchemaTableNamewithout other objects.- Throws:
RuntimeException- if table handle is no longer valid
-
getTableSchema
Return table schema definition for the specified table handle. This method is useful when getting full table metadata is expensive.- Throws:
RuntimeException- if table handle is no longer valid
-
getTableMetadata
default ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table) Return the metadata for the specified table handle.- Throws:
RuntimeException- if table handle is no longer valid
-
getInfo
-
listTables
List table, view and materialized view names, possibly filtered by schema. An empty list is returned if none match. An empty list is returned also when schema name does not refer to an existing schema. -
getColumnHandles
default Map<String,ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) Gets all of the columns on the specified table, or an empty map if the columns cannot be enumerated.- Throws:
RuntimeException- if table handle is no longer valid
-
getColumnMetadata
default ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle) Gets the metadata for the specified table column.- Throws:
RuntimeException- if table or column handles are no longer valid
-
listTableColumns
@Deprecated default Map<SchemaTableName,List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix) Deprecated.usestreamTableColumns(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTablePrefix)which handles redirected tablesGets the metadata for all columns that match the specified table prefix. Columns of views and materialized views are not included. -
streamTableColumns
@Deprecated default Iterator<TableColumnsMetadata> streamTableColumns(ConnectorSession session, SchemaTablePrefix prefix) Deprecated.Gets the metadata for all columns that match the specified table prefix. Redirected table names are included, but the column metadata for them is not. Views and materialized views are not included. -
streamRelationColumns
@Experimental(eta="2024-01-01") default Iterator<RelationColumnsMetadata> streamRelationColumns(ConnectorSession session, Optional<String> schemaName, UnaryOperator<Set<SchemaTableName>> relationFilter) Gets columns for all relations (tables, views, materialized views), possibly filtered by schemaName. (e.g. for all relations that would be returned bylistTables(ConnectorSession, Optional)). Redirected table names are included, but the comment for them is not. -
streamRelationComments
@Experimental(eta="2024-01-01") default Iterator<RelationCommentMetadata> streamRelationComments(ConnectorSession session, Optional<String> schemaName, UnaryOperator<Set<SchemaTableName>> relationFilter) Gets comments for all relations (tables, views, materialized views), possibly filtered by schemaName. (e.g. for all relations that would be returned bylistTables(ConnectorSession, Optional)). Redirected table names are included, but the comment for them is not. -
getTableStatistics
default TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle) Get statistics for table. -
createSchema
default void createSchema(ConnectorSession session, String schemaName, Map<String, Object> properties, TrinoPrincipal owner) Creates a schema. -
dropSchema
Drops the specified schema.- Throws:
TrinoException- withSCHEMA_NOT_EMPTYifcascadeis false and the schema is not empty
-
renameSchema
Renames the specified schema. -
setSchemaAuthorization
default void setSchemaAuthorization(ConnectorSession session, String schemaName, TrinoPrincipal principal) Sets the user/role on the specified schema. -
createTable
@Deprecated default void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, boolean ignoreExisting) Deprecated.Creates a table using the specified table metadata.- Throws:
TrinoException- withALREADY_EXISTSif the table already exists and is not set
-
createTable
default void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, SaveMode saveMode) Creates a table using the specified table metadata. IGNORE means the table is created using CREATE ... IF NOT EXISTS syntax. REPLACE means the table is created using CREATE OR REPLACE syntax.- Throws:
TrinoException- withALREADY_EXISTSif the table already exists and is FAIL.
-
dropTable
Drops the specified table- Throws:
RuntimeException- if the table cannot be dropped or table handle is no longer valid
-
truncateTable
Truncates the specified table- Throws:
RuntimeException- if the table cannot be dropped or table handle is no longer valid
-
renameTable
default void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle, SchemaTableName newTableName) Rename the specified table -
setTableProperties
default void setTableProperties(ConnectorSession session, ConnectorTableHandle tableHandle, Map<String, Optional<Object>> properties) Set properties to the specified table -
setTableComment
default void setTableComment(ConnectorSession session, ConnectorTableHandle tableHandle, Optional<String> comment) Comments to the specified table -
setViewComment
default void setViewComment(ConnectorSession session, SchemaTableName viewName, Optional<String> comment) Comments to the specified view -
setViewColumnComment
default void setViewColumnComment(ConnectorSession session, SchemaTableName viewName, String columnName, Optional<String> comment) Comments to the specified view column. -
setMaterializedViewColumnComment
default void setMaterializedViewColumnComment(ConnectorSession session, SchemaTableName viewName, String columnName, Optional<String> comment) Comments to the specified materialized view column. -
setColumnComment
default void setColumnComment(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, Optional<String> comment) Comments to the specified column -
addColumn
default void addColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnMetadata column) Add the specified column -
addField
@Experimental(eta="2023-06-01") default void addField(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> parentPath, String fieldName, Type type, boolean ignoreExisting) Add the specified field, potentially nested, to a row.- Parameters:
parentPath- path to a field within the column, without leaf field name.
-
setColumnType
@Experimental(eta="2023-04-01") default void setColumnType(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, Type type) Set the specified column type -
setFieldType
@Experimental(eta="2023-09-01") default void setFieldType(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> fieldPath, Type type) Set the specified field type- Parameters:
fieldPath- path starting with column name. The path is always lower-cased. It cannot be an empty or a single element.
-
setTableAuthorization
default void setTableAuthorization(ConnectorSession session, SchemaTableName tableName, TrinoPrincipal principal) Sets the user/role on the specified table. -
renameColumn
default void renameColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle source, String target) Rename the specified column -
renameField
@Experimental(eta="2023-09-01") default void renameField(ConnectorSession session, ConnectorTableHandle tableHandle, List<String> fieldPath, String target) Rename the specified field, potentially nested, to a row.- Parameters:
fieldPath- path starting with column name.target- the new field name. The field position and nested level shouldn't be changed.
-
dropColumn
default void dropColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column) Drop the specified column -
dropField
@Experimental(eta="2023-05-01") default void dropField(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column, List<String> fieldPath) Drop the specified field, potentially nested, from a row.- Parameters:
fieldPath- path to a field within the column, without leading column name.
-
getNewTableLayout
default Optional<ConnectorTableLayout> getNewTableLayout(ConnectorSession session, ConnectorTableMetadata tableMetadata) Get the physical layout for a new table. -
getSupportedType
@Experimental(eta="2024-01-31") default Optional<Type> getSupportedType(ConnectorSession session, Map<String, Object> tableProperties, Type type) Return the effectiveTypethat is supported by the connector for the given type. IfOptional.empty()is returned, the type will be used as is during table creation which may or may not be supported by the connector. The effective type shall be a type that is cast-compatible with the input type. -
getInsertLayout
default Optional<ConnectorTableLayout> getInsertLayout(ConnectorSession session, ConnectorTableHandle tableHandle) Get the physical layout for inserting into an existing table. -
getStatisticsCollectionMetadataForWrite
default TableStatisticsMetadata getStatisticsCollectionMetadataForWrite(ConnectorSession session, ConnectorTableMetadata tableMetadata) Describes statistics that must be collected during a write. -
getStatisticsCollectionMetadata
default ConnectorAnalyzeMetadata getStatisticsCollectionMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, Map<String, Object> analyzeProperties) Describe statistics that must be collected during a statistics collection -
beginStatisticsCollection
default ConnectorTableHandle beginStatisticsCollection(ConnectorSession session, ConnectorTableHandle tableHandle) Begin statistics collection -
finishStatisticsCollection
default void finishStatisticsCollection(ConnectorSession session, ConnectorTableHandle tableHandle, Collection<ComputedStatistics> computedStatistics) Finish statistics collection -
beginCreateTable
@Deprecated default ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode) Deprecated.Begin the atomic creation of a table with data.If connector does not support execution with retries, the method should throw:
new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")unlessretryModeis set toNO_RETRIES. -
beginCreateTable
default ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional<ConnectorTableLayout> layout, RetryMode retryMode, boolean replace) Begin the atomic creation of a table with data. If connector does not support execution with retries, the method should throw:new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")unlessretryModeis set toNO_RETRIES. -
finishCreateTable
default Optional<ConnectorOutputMetadata> finishCreateTable(ConnectorSession session, ConnectorOutputTableHandle tableHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish a table creation with data after the data is written. -
beginQuery
Start a query. This notification is triggered before any other metadata access. -
cleanupQuery
Cleanup after a query. This is the very last notification after the query finishes, whether it succeeds or fails. An exception thrown in this method will not affect the result of the query. -
beginInsert
default ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode) Begin insert query.If connector does not support execution with retries, the method should throw:
new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")unlessretryModeis set toNO_RETRIES. -
supportsMissingColumnsOnInsert
default boolean supportsMissingColumnsOnInsert()- Returns:
- whether connector handles missing columns during insert
-
finishInsert
default Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session, ConnectorInsertTableHandle insertHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish insert query -
delegateMaterializedViewRefreshToConnector
default boolean delegateMaterializedViewRefreshToConnector(ConnectorSession session, SchemaTableName viewName) Returns true if materialized view refresh should be delegated to connector usingrefreshMaterializedView(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.SchemaTableName) -
refreshMaterializedView
default CompletableFuture<?> refreshMaterializedView(ConnectorSession session, SchemaTableName viewName) Refresh materialized view -
beginRefreshMaterializedView
default ConnectorInsertTableHandle beginRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, List<ConnectorTableHandle> sourceTableHandles, RetryMode retryMode) Begin materialized view query.If connector does not support execution with retries, the method should throw:
new TrinoException(NOT_SUPPORTED, "This connector does not support query retries")unlessretryModeis set toNO_RETRIES. -
finishRefreshMaterializedView
default Optional<ConnectorOutputMetadata> finishRefreshMaterializedView(ConnectorSession session, ConnectorTableHandle tableHandle, ConnectorInsertTableHandle insertHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics, List<ConnectorTableHandle> sourceTableHandles) Finish materialized view query -
getRowChangeParadigm
default RowChangeParadigm getRowChangeParadigm(ConnectorSession session, ConnectorTableHandle tableHandle) Return the row change paradigm supported by the connector on the table. -
getMergeRowIdColumnHandle
default ColumnHandle getMergeRowIdColumnHandle(ConnectorSession session, ConnectorTableHandle tableHandle) Get the column handle that will generate row IDs for the merge operation. These IDs will be passed to theConnectorMergeSink.storeMergedRows(io.trino.spi.Page)method of theConnectorMergeSinkthat created them. -
getUpdateLayout
default Optional<ConnectorPartitioningHandle> getUpdateLayout(ConnectorSession session, ConnectorTableHandle tableHandle) Get the physical layout for updated or deleted rows of a MERGE operation. Inserted rows are handled bygetInsertLayout(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle). This layout always uses themerge row ID column. -
beginMerge
default ConnectorMergeTableHandle beginMerge(ConnectorSession session, ConnectorTableHandle tableHandle, RetryMode retryMode) Do whatever is necessary to start an MERGE query, returning theConnectorMergeTableHandleinstance that will be passed to the PageSink, and to thefinishMerge(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorMergeTableHandle, java.util.Collection<io.airlift.slice.Slice>, java.util.Collection<io.trino.spi.statistics.ComputedStatistics>)method. -
finishMerge
default void finishMerge(ConnectorSession session, ConnectorMergeTableHandle mergeTableHandle, Collection<io.airlift.slice.Slice> fragments, Collection<ComputedStatistics> computedStatistics) Finish a merge query- Parameters:
session- The sessionmergeTableHandle- A ConnectorMergeTableHandle for the table that is the target of the mergefragments- All fragments returned by the merge plancomputedStatistics- Statistics for the table, meaningful only to the connector that produced them.
-
createView
default void createView(ConnectorSession session, SchemaTableName viewName, ConnectorViewDefinition definition, boolean replace) Create the specified view. The view definition is intended to be serialized by the connector for permanent storage. -
renameView
Rename the specified view -
setViewAuthorization
default void setViewAuthorization(ConnectorSession session, SchemaTableName viewName, TrinoPrincipal principal) Sets the user/role on the specified view. -
dropView
Drop the specified view. -
listViews
List view names (but not materialized views), possibly filtered by schema. An empty list is returned if none match. An empty list is returned also when schema name does not refer to an existing schema. -
getViews
default Map<SchemaTableName,ConnectorViewDefinition> getViews(ConnectorSession session, Optional<String> schemaName) Gets the definitions of views (but not materialized views), possibly filtered by schema. This optional method may be implemented by connectors that can support fetching view data in bulk. It is used to implementinformation_schema.views. -
getView
default Optional<ConnectorViewDefinition> getView(ConnectorSession session, SchemaTableName viewName) Gets the view data for the specified view name. ReturnsOptional.empty()ifviewNamerelation does not or is not a view (e.g. is a table, or a materialized view). -
getSchemaProperties
Gets the schema properties for the specified schema. -
getSchemaOwner
Get the schema properties for the specified schema. -
applyUpdate
default Optional<ConnectorTableHandle> applyUpdate(ConnectorSession session, ConnectorTableHandle handle, Map<ColumnHandle, Constant> assignments) Attempt to push down an update operation into the connector. If a connector can execute an update for the table handle on its own, it should return a table handle, which will be passed back toexecuteUpdate(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle)during query executing to actually execute the update. -
executeUpdate
Execute the update operation on the handle returned fromapplyUpdate(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle, java.util.Map<io.trino.spi.connector.ColumnHandle, io.trino.spi.expression.Constant>). -
applyDelete
default Optional<ConnectorTableHandle> applyDelete(ConnectorSession session, ConnectorTableHandle handle) Attempt to push down a delete operation into the connector. If a connector can execute a delete for the table handle on its own, it should return a table handle, which will be passed back toexecuteDelete(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle)during query executing to actually execute the delete. -
executeDelete
Execute the delete operation on the handle returned fromapplyDelete(io.trino.spi.connector.ConnectorSession, io.trino.spi.connector.ConnectorTableHandle). -
resolveIndex
default Optional<ConnectorResolvedIndex> resolveIndex(ConnectorSession session, ConnectorTableHandle tableHandle, Set<ColumnHandle> indexableColumns, Set<ColumnHandle> outputColumns, TupleDomain<ColumnHandle> tupleDomain) Try to locate a table index that can lookup results by indexableColumns and provide the requested outputColumns. -
listFunctions
List available functions. -
getFunctions
default Collection<FunctionMetadata> getFunctions(ConnectorSession session, SchemaFunctionName name) Get all functions with specified name. -
getFunctionMetadata
Return the function with the specified id. -
getAggregationFunctionMetadata
default AggregationFunctionMetadata getAggregationFunctionMetadata(ConnectorSession session, FunctionId functionId) Returns the aggregation metadata for the aggregation function with the specified id. -
getFunctionDependencies
default FunctionDependencyDeclaration getFunctionDependencies(ConnectorSession session, FunctionId functionId, BoundSignature boundSignature) Returns the dependencies of the function with the specified id. -
listLanguageFunctions
default Collection<LanguageFunction> listLanguageFunctions(ConnectorSession session, String schemaName) List available language functions. -
getLanguageFunctions
default Collection<LanguageFunction> getLanguageFunctions(ConnectorSession session, SchemaFunctionName name) Get all language functions with the specified name. -
languageFunctionExists
default boolean languageFunctionExists(ConnectorSession session, SchemaFunctionName name, String signatureToken) Check if a language function exists. -
createLanguageFunction
default void createLanguageFunction(ConnectorSession session, SchemaFunctionName name, LanguageFunction function, boolean replace) Creates a language function with the specified name and signature token. The signature token is an opaque string that uniquely identifies the function signature. Multiple functions with the same name but with different signatures may exist. The signature token is used to identify the function when dropping it.- Parameters:
replace- if true, replace existing function with the same name and signature token
-
dropLanguageFunction
default void dropLanguageFunction(ConnectorSession session, SchemaFunctionName name, String signatureToken) Drops a language function with the specified name and signature token. -
roleExists
Does the specified role exist. -
createRole
Creates the specified role.- Parameters:
grantor- represents the principal specified by WITH ADMIN statement
-
dropRole
Drops the specified role. -
listRoles
List available roles. -
listRoleGrants
List role grants for a given principal, not recursively. -
grantRoles
default void grantRoles(ConnectorSession connectorSession, Set<String> roles, Set<TrinoPrincipal> grantees, boolean adminOption, Optional<TrinoPrincipal> grantor) Grants the specified roles to the specified grantees- Parameters:
grantor- represents the principal specified by GRANTED BY statement
-
revokeRoles
default void revokeRoles(ConnectorSession connectorSession, Set<String> roles, Set<TrinoPrincipal> grantees, boolean adminOption, Optional<TrinoPrincipal> grantor) Revokes the specified roles from the specified grantees- Parameters:
grantor- represents the principal specified by GRANTED BY statement
-
listApplicableRoles
List applicable roles, including the transitive grants, for the specified principal -
listEnabledRoles
List applicable roles, including the transitive grants, in given session -
grantSchemaPrivileges
default void grantSchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Grants the specified privilege to the specified user on the specified schema -
denySchemaPrivileges
default void denySchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee) Denys the specified privilege to the specified user on the specified schema -
revokeSchemaPrivileges
default void revokeSchemaPrivileges(ConnectorSession session, String schemaName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Revokes the specified privilege on the specified schema from the specified user -
grantTablePrivileges
default void grantTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Grants the specified privilege to the specified user on the specified table -
denyTablePrivileges
default void denyTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee) Denys the specified privilege to the specified user on the specified table -
revokeTablePrivileges
default void revokeTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, TrinoPrincipal grantee, boolean grantOption) Revokes the specified privilege on the specified table from the specified user -
listTablePrivileges
List the table privileges granted to the specified grantee for the tables that have the specified prefix considering the selected session role -
getTableProperties
default ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) -
applyLimit
default Optional<LimitApplicationResult<ConnectorTableHandle>> applyLimit(ConnectorSession session, ConnectorTableHandle handle, long limit) Attempt to push down the provided limit into the table.Connectors can indicate whether they don't support limit pushdown or that the action had no effect by returning
Optional.empty(). Connectors should expect this method to be called multiple times during the optimization of a given query.Note: it's critical for connectors to return Optional.empty() if calling this method has no effect for that invocation, even if the connector generally supports limit pushdown. Doing otherwise can cause the optimizer to loop indefinitely.
If the connector could benefit from the information but can't guarantee that it will be able to produce fewer rows than the provided limit, it should return a non-empty result containing a new handle for the derived table and the "limit guaranteed" flag set to false.
If the connector can guarantee it will produce fewer rows than the provided limit, it should return a non-empty result with the "limit guaranteed" flag set to true.
-
applyFilter
default Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint) Attempt to push down the provided constraint into the table.Connectors can indicate whether they don't support predicate pushdown or that the action had no effect by returning
Optional.empty(). Connectors should expect this method to be called multiple times during the optimization of a given query.Note: it's critical for connectors to return Optional.empty() if calling this method has no effect for that invocation, even if the connector generally supports pushdown. Doing otherwise can cause the optimizer to loop indefinitely.
Note: Implementation must not maintain reference to
constraint'sConstraint.predicate()after the call returns.- Parameters:
constraint- constraint to be applied to the table.Constraint.getSummary()is guaranteed not to benone.
-
applyProjection
default Optional<ProjectionApplicationResult<ConnectorTableHandle>> applyProjection(ConnectorSession session, ConnectorTableHandle handle, List<ConnectorExpression> projections, Map<String, ColumnHandle> assignments) Attempt to push down the provided projections into the table.Connectors can indicate whether they don't support projection pushdown or that the action had no effect by returning
Optional.empty(). Connectors should expect this method to be called multiple times during the optimization of a given query.Note: it's critical for connectors to return Optional.empty() if calling this method has no effect for that invocation, even if the connector generally supports pushdown. Doing otherwise can cause the optimizer to loop indefinitely.
If the method returns a result, the list of projections in the result *replaces* the existing ones, and the list of assignments is the new set of columns exposed by the derived table.
As an example, given the following plan:
- project x = f1(a, b) y = f2(a, b) z = f3(a, b) - scan (TH0) a = CH0 b = CH1 c = CH2The optimizer would call this method with the following arguments:
handle = TH0 projections = [ f1(a, b) f2(a, b) f3(a, b) ] assignments = [ a = CH0 b = CH1 c = CH2 ]Assuming the connector knows how to handle f1(...) and f2(...), it would return:
handle = TH1 projections = [ v2 v3 f3(v0, v1) ] assignments = [ v0 = CH0 v1 = CH1 v2 = CH3 (synthetic column for f1(CH0, CH1)) v3 = CH4 (synthetic column for f2(CH0, CH1)) ] -
applySample
default Optional<SampleApplicationResult<ConnectorTableHandle>> applySample(ConnectorSession session, ConnectorTableHandle handle, SampleType sampleType, double sampleRatio) Attempt to push down the sampling into the table.Connectors can indicate whether they don't support sample pushdown or that the action had no effect by returning
Optional.empty(). Connectors should expect this method to be called multiple times during the optimization of a given query.Note: it's critical for connectors to return Optional.empty() if calling this method has no effect for that invocation, even if the connector generally supports sample pushdown. Doing otherwise can cause the optimizer to loop indefinitely.
-
applyAggregation
default Optional<AggregationApplicationResult<ConnectorTableHandle>> applyAggregation(ConnectorSession session, ConnectorTableHandle handle, List<AggregateFunction> aggregates, Map<String, ColumnHandle> assignments, List<List<ColumnHandle>> groupingSets) Attempt to push down the aggregates into the table.Connectors can indicate whether they don't support aggregate pushdown or that the action had no effect by returning
Note: it's critical for connectors to returnOptional.empty(). Connectors should expect this method may be called multiple times.Optional.empty()if calling this method has no effect for that invocation, even if the connector generally supports pushdown. Doing otherwise can cause the optimizer to loop indefinitely.If the method returns a result, the list of assignments in the result will be merged with existing assignments. The projections returned by the method must have the same order as the given input list of aggregates.
As an example, given the following plan:- aggregation (GROUP BY c) variable0 = agg_fn1(a) variable1 = agg_fn2(b, 2) variable2 = c - scan (TH0) a = CH0 b = CH1 c = CH2The optimizer would call this method with the following arguments:
handle = TH0 aggregates = [ { functionName=agg_fn1, outputType = «some Trino type» inputs = [Variablea]} , { functionName=agg_fn2, outputType = «some Trino type» inputs = [Variableb,Constant2]} ] groupingSets=[[ColumnHandleCH2]] assignments = {a = CH0, b = CH1, c = CH2}Assuming the connector knows how to handle
agg_fn1(...)andagg_fn2(...), it would return:AggregationApplicationResult{ handle = TH1 projections = [Variablesynthetic_name0,Variablesynthetic_name1] -- The order in the list must be same as input list of aggregates assignments = { synthetic_name0 = CH3 (synthetic column for agg_fn1(a)) synthetic_name1 = CH4 (synthetic column for agg_fn2(b,2)) } }if the connector only knows how to handle
agg_fn1(...), but notagg_fn2, it should returnOptional.empty().Another example is where the connector wants to handle the aggregate function by pointing to a pre-materialized table. In this case the input can stay same as in the above example and the connector can return
AggregationApplicationResult{ handle = TH1 (could capture information about which pre-materialized table to use) projections = [Variablesynthetic_name0,Variablesynthetic_name1] -- The order in the list must be same as input list of aggregates assignments = { synthetic_name0 = CH3 (reference to the column in pre-materialized table that has agg_fn1(a) calculated) synthetic_name1 = CH4 (reference to the column in pre-materialized table that has agg_fn2(b,2) calculated) synthetic_name2 = CH5 (reference to the column in pre-materialized table that has the group by column c) } groupingColumnMapping = { CH2 -> CH5 (CH2 in the original assignment should now be replaced by CH5 in the new assignment) } } -
applyJoin
default Optional<JoinApplicationResult<ConnectorTableHandle>> applyJoin(ConnectorSession session, JoinType joinType, ConnectorTableHandle left, ConnectorTableHandle right, ConnectorExpression joinCondition, Map<String, ColumnHandle> leftAssignments, Map<String, ColumnHandle> rightAssignments, JoinStatistics statistics) Attempt to push down the join operation.Connectors can indicate whether they don't support join pushdown or that the action had no effect by returning
Warning: this is an experimental API and it will change in the future.Optional.empty(). Connectors should expect this method may be called multiple times.Join condition conjuncts are passed via joinConditions list. For current implementation connector may assume that leftExpression and rightExpression in each of the conjucts are instances of
Variable. This may be relaxed in the future.The leftAssignments and rightAssignments lists provide mappings from variable names, used in joinConditions to input tables column handles. It is guaranteed that all the required mappings will be provided but not necessarily *all* the column handles of tables which are join inputs.
Table statistics for left, right table as well as estimated statistics for join are provided via statistics parameter. Those can be used by connector to assess if performing join pushdown is expected to improve query performance.
If the method returns a result the returned table handle will be used in place of join and input table scans. Returned result must provide mapping from old column handles to new ones via leftColumnHandles and rightColumnHandles fields of the result. It is required that mapping is provided for *all* column handles exposed previously by both left and right join sources.
-
applyJoin
@Deprecated default Optional<JoinApplicationResult<ConnectorTableHandle>> applyJoin(ConnectorSession session, JoinType joinType, ConnectorTableHandle left, ConnectorTableHandle right, List<JoinCondition> joinConditions, Map<String, ColumnHandle> leftAssignments, Map<String, ColumnHandle> rightAssignments, JoinStatistics statistics) Deprecated. -
applyTopN
default Optional<TopNApplicationResult<ConnectorTableHandle>> applyTopN(ConnectorSession session, ConnectorTableHandle handle, long topNCount, List<SortItem> sortItems, Map<String, ColumnHandle> assignments) Attempt to push down the TopN into the table scan.Connectors can indicate whether they don't support topN pushdown or that the action had no effect by returning
Note: it's critical for connectors to returnOptional.empty(). Connectors should expect this method may be called multiple times.Optional.empty()if calling this method has no effect for that invocation, even if the connector generally supports topN pushdown. Doing otherwise can cause the optimizer to loop indefinitely.If the connector can handle TopN Pushdown and guarantee it will produce no more rows than requested then it should return a non-empty result with "topN guaranteed" flag set to true.
-
applyTableFunction
default Optional<TableFunctionApplicationResult<ConnectorTableHandle>> applyTableFunction(ConnectorSession session, ConnectorTableFunctionHandle handle) Attempt to push down the table function invocation into the connector.Connectors can indicate whether they don't support table function invocation pushdown or that the action had no effect by returning
Optional.empty(). Connectors should expect this method may be called multiple times.If the method returns a result, the returned table handle will be used in place of the table function invocation.
-
validateScan
Allows the connector to reject the table scan produced by the planner.Connectors can choose to reject a query based on the table scan potentially being too expensive, for example if no filtering is done on a partition column.
-
createMaterializedView
default void createMaterializedView(ConnectorSession session, SchemaTableName viewName, ConnectorMaterializedViewDefinition definition, boolean replace, boolean ignoreExisting) Create the specified materialized view. The view definition is intended to be serialized by the connector for permanent storage.- Throws:
TrinoException- withALREADY_EXISTSif the object already exists and is not set
-
dropMaterializedView
Drop the specified materialized view. -
listMaterializedViews
default List<SchemaTableName> listMaterializedViews(ConnectorSession session, Optional<String> schemaName) List materialized view names, possibly filtered by schema. An empty list is returned if none match. An empty list is returned also when schema name does not refer to an existing schema. -
getMaterializedViews
default Map<SchemaTableName,ConnectorMaterializedViewDefinition> getMaterializedViews(ConnectorSession session, Optional<String> schemaName) Gets the definitions of materialized views, possibly filtered by schema. This optional method may be implemented by connectors that can support fetching view data in bulk. It is used to populateinformation_schema.columns. -
getMaterializedView
default Optional<ConnectorMaterializedViewDefinition> getMaterializedView(ConnectorSession session, SchemaTableName viewName) Gets the materialized view data for the specified materialized view name. ReturnsOptional.empty()ifviewNamerelation does not or is not a materialized view (e.g. is a table, or a view). -
getMaterializedViewFreshness
default MaterializedViewFreshness getMaterializedViewFreshness(ConnectorSession session, SchemaTableName name) The method is used by the engine to determine if a materialized view is current with respect to the tables it depends on.- Throws:
MaterializedViewNotFoundException- when materialized view is not found
-
renameMaterializedView
default void renameMaterializedView(ConnectorSession session, SchemaTableName source, SchemaTableName target) Rename the specified materialized view -
setMaterializedViewProperties
default void setMaterializedViewProperties(ConnectorSession session, SchemaTableName viewName, Map<String, Optional<Object>> properties) Sets the properties of the specified materialized view -
applyTableScanRedirect
default Optional<TableScanRedirectApplicationResult> applyTableScanRedirect(ConnectorSession session, ConnectorTableHandle tableHandle) -
redirectTable
default Optional<CatalogSchemaTableName> redirectTable(ConnectorSession session, SchemaTableName tableName) Redirects table to other table which may or may not be in the same catalog. Currently the engine tries to do redirection only for table reads and metadata listing.Also consider implementing streamTableColumns to support redirection for listing.
-
getMaxWriterTasks
-
getNewTableWriterScalingOptions
default WriterScalingOptions getNewTableWriterScalingOptions(ConnectorSession session, SchemaTableName tableName, Map<String, Object> tableProperties) -
getInsertWriterScalingOptions
default WriterScalingOptions getInsertWriterScalingOptions(ConnectorSession session, ConnectorTableHandle tableHandle)
-
beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata, Optional layout, RetryMode retryMode, boolean replace)