Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.spi.connector;
import com.facebook.presto.common.predicate.TupleDomain;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.spi.ColumnHandle;
import com.facebook.presto.spi.ColumnMetadata;
import com.facebook.presto.spi.ConnectorInsertTableHandle;
import com.facebook.presto.spi.ConnectorMetadataUpdateHandle;
import com.facebook.presto.spi.ConnectorNewTableLayout;
import com.facebook.presto.spi.ConnectorOutputTableHandle;
import com.facebook.presto.spi.ConnectorResolvedIndex;
import com.facebook.presto.spi.ConnectorSession;
import com.facebook.presto.spi.ConnectorTableHandle;
import com.facebook.presto.spi.ConnectorTableLayout;
import com.facebook.presto.spi.ConnectorTableLayoutHandle;
import com.facebook.presto.spi.ConnectorTableLayoutResult;
import com.facebook.presto.spi.ConnectorTableMetadata;
import com.facebook.presto.spi.ConnectorViewDefinition;
import com.facebook.presto.spi.Constraint;
import com.facebook.presto.spi.MaterializedViewDefinition;
import com.facebook.presto.spi.MaterializedViewStatus;
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.QueryId;
import com.facebook.presto.spi.SchemaTableName;
import com.facebook.presto.spi.SchemaTablePrefix;
import com.facebook.presto.spi.SystemTable;
import com.facebook.presto.spi.TableLayoutFilterCoverage;
import com.facebook.presto.spi.api.Experimental;
import com.facebook.presto.spi.constraints.TableConstraint;
import com.facebook.presto.spi.security.GrantInfo;
import com.facebook.presto.spi.security.PrestoPrincipal;
import com.facebook.presto.spi.security.Privilege;
import com.facebook.presto.spi.security.RoleGrant;
import com.facebook.presto.spi.statistics.ComputedStatistics;
import com.facebook.presto.spi.statistics.TableStatistics;
import com.facebook.presto.spi.statistics.TableStatisticsMetadata;
import io.airlift.slice.Slice;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import static com.facebook.presto.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static com.facebook.presto.spi.StandardErrorCode.NOT_SUPPORTED;
import static com.facebook.presto.spi.TableLayoutFilterCoverage.NOT_APPLICABLE;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toList;
public interface ConnectorMetadata
{
/**
* Checks if a schema exists. The connector may have schemas that exist
* but are not enumerable via {@link #listSchemaNames}.
*/
default boolean schemaExists(ConnectorSession session, String schemaName)
{
return listSchemaNames(session).contains(schemaName);
}
/**
* Returns the schemas provided by this connector.
*/
List listSchemaNames(ConnectorSession session);
/**
* Returns a table handle for the specified table name, or null if the connector does not contain the table.
*/
ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName);
/**
* Returns an error for connectors which do not support table version AS OF/BEFORE expression.
*/
default ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName, Optional tableVersion)
{
throw new PrestoException(NOT_SUPPORTED, "This connector does not support table version AS OF/BEFORE expression");
}
/**
* Returns a table handle for the specified table name, or null if the connector does not contain the table.
* The returned table handle can contain information in analyzeProperties.
*/
default ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSession session, SchemaTableName tableName, Map analyzeProperties)
{
throw new PrestoException(NOT_SUPPORTED, "This connector does not support analyze");
}
/**
* Returns the system table for the specified table name, if one exists.
* The system tables handled via this method differ from those returned by {@link Connector#getSystemTables()}.
* The former mechanism allows dynamic resolution of system tables, while the latter is
* based on static list of system tables built during startup.
*/
default Optional getSystemTable(ConnectorSession session, SchemaTableName tableName)
{
return Optional.empty();
}
/**
* Return a list of table layouts that satisfy the given constraint.
*
* For each layout, connectors must return an "unenforced constraint" representing the part of the constraint summary that isn't guaranteed by the layout.
*
* @deprecated replaced by {@link ConnectorMetadata#getTableLayoutForConstraint(ConnectorSession, ConnectorTableHandle, Constraint, Optional)}
*/
@Deprecated
default List getTableLayouts(
ConnectorSession session,
ConnectorTableHandle table,
Constraint constraint,
Optional> desiredColumns)
{
return emptyList();
}
/**
* Return a table layout result that satisfy the given constraint.
*
* Connectors must return an "unenforced constraint" representing the part of the constraint summary that isn't guaranteed by the layout.
*/
default ConnectorTableLayoutResult getTableLayoutForConstraint(
ConnectorSession session,
ConnectorTableHandle table,
Constraint constraint,
Optional> desiredColumns)
{
List layouts = getTableLayouts(session, table, constraint, desiredColumns);
if (layouts.isEmpty()) {
throw new PrestoException(NOT_SUPPORTED, "Connector hasn't implemented either getTableLayoutForConstraint() or getTableLayouts()");
}
else if (layouts.size() > 1) {
throw new PrestoException(NOT_SUPPORTED, "Connector returned multiple layouts for table " + table);
}
return layouts.get(0);
}
ConnectorTableLayout getTableLayout(ConnectorSession session, ConnectorTableLayoutHandle handle);
/**
* Return a table layout handle whose partitioning is converted to the provided partitioning handle,
* but otherwise identical to the provided table layout handle.
* The provided table layout handle must be one that the connector can transparently convert to from
* the original partitioning handle associated with the provided table layout handle,
* as promised by {@link #getCommonPartitioningHandle}.
*/
default ConnectorTableLayoutHandle getAlternativeLayoutHandle(ConnectorSession session, ConnectorTableLayoutHandle tableLayoutHandle, ConnectorPartitioningHandle partitioningHandle)
{
throw new PrestoException(GENERIC_INTERNAL_ERROR, "ConnectorMetadata getCommonPartitioningHandle() is implemented without getAlternativeLayout()");
}
/**
* Experimental: if true, the engine will invoke getLayout otherwise, getLayout will not be called.
*/
@Deprecated
@Experimental
default boolean isLegacyGetLayoutSupported(ConnectorSession session, ConnectorTableHandle tableHandle)
{
return true;
}
/**
* Return a partitioning handle which the connector can transparently convert both {@code left} and {@code right} into.
*/
@Deprecated
default Optional getCommonPartitioningHandle(ConnectorSession session, ConnectorPartitioningHandle left, ConnectorPartitioningHandle right)
{
if (left.equals(right)) {
return Optional.of(left);
}
return Optional.empty();
}
/**
* Partitioning a = {a_1, ... a_n} is considered as a refined partitioning over
* partitioning b = {b_1, ... b_m} if:
*
*
n >= m
*
For every partition b_i in partitioning b,
* the rows it contains is the same as union of a set of partitions a_{i_1}, a_{i_2}, ... a_{i_k}
* in partitioning a, i.e.
*
* b_i = a_{i_1} + a_{i_2} + ... + a_{i_k}
*
Connector can transparently convert partitioning a to partitioning b
* associated with the provided table layout handle.
*
*
*
* For example, consider two partitioning over order table:
*
*
partitioning a has 256 partitions by orderkey % 256
*
partitioning b has 128 partitions by orderkey % 128
*
*
*
* Partitioning a is a refined partitioning over b if Connector supports
* transparently convert a to b.
*
* Refined-over relation is reflexive.
*
* This SPI is unstable and subject to change in the future.
*/
default boolean isRefinedPartitioningOver(ConnectorSession session, ConnectorPartitioningHandle left, ConnectorPartitioningHandle right)
{
return left.equals(right);
}
/**
* Provides partitioning handle for exchange.
*/
default ConnectorPartitioningHandle getPartitioningHandleForExchange(ConnectorSession session, int partitionCount, List partitionTypes)
{
throw new PrestoException(NOT_SUPPORTED, "This connector does not support custom partitioning");
}
/**
* Return the metadata for the specified table handle.
*
* @throws RuntimeException if table handle is no longer valid
*/
ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table);
/**
* Return the connector-specific metadata for the specified table layout. This is the object that is passed to the event listener framework.
*
* @throws RuntimeException if table handle is no longer valid
*/
default Optional