Search in sources :

Example 11 with TableColumn

use of io.trino.plugin.raptor.legacy.metadata.TableColumn in project trino by trinodb.

the class RaptorMetadata method beginInsert.

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle) {
    RaptorTableHandle handle = (RaptorTableHandle) tableHandle;
    long tableId = handle.getTableId();
    ImmutableList.Builder<RaptorColumnHandle> columnHandlesBuilder = ImmutableList.builder();
    ImmutableList.Builder<Type> columnTypes = ImmutableList.builder();
    for (TableColumn column : dao.listTableColumns(tableId)) {
        columnHandlesBuilder.add(new RaptorColumnHandle(column.getColumnName(), column.getColumnId(), column.getDataType()));
        columnTypes.add(column.getDataType());
    }
    long transactionId = shardManager.beginTransaction();
    setTransactionId(transactionId);
    Optional<String> externalBatchId = getExternalBatchId(session);
    List<RaptorColumnHandle> sortColumnHandles = getSortColumnHandles(tableId);
    List<RaptorColumnHandle> bucketColumnHandles = getBucketColumnHandles(tableId);
    ImmutableList<RaptorColumnHandle> columnHandles = columnHandlesBuilder.build();
    Optional<RaptorColumnHandle> temporalColumnHandle = Optional.ofNullable(dao.getTemporalColumnId(tableId)).map(temporalColumnId -> getOnlyElement(columnHandles.stream().filter(columnHandle -> columnHandle.getColumnId() == temporalColumnId).collect(toList())));
    return new RaptorInsertTableHandle(transactionId, tableId, columnHandles, columnTypes.build(), externalBatchId, sortColumnHandles, nCopies(sortColumnHandles.size(), ASC_NULLS_FIRST), handle.getBucketCount(), bucketColumnHandles, temporalColumnHandle);
}
Also used : ORGANIZED_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.ORGANIZED_PROPERTY) SHARD_UUID_COLUMN_TYPE(io.trino.plugin.raptor.legacy.RaptorColumnHandle.SHARD_UUID_COLUMN_TYPE) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) TableNotFoundException(io.trino.spi.connector.TableNotFoundException) RaptorTableProperties.isOrganized(io.trino.plugin.raptor.legacy.RaptorTableProperties.isOrganized) ShardDelta(io.trino.plugin.raptor.legacy.metadata.ShardDelta) RaptorColumnHandle.shardUuidColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle.shardUuidColumnHandle) ConnectorOutputTableHandle(io.trino.spi.connector.ConnectorOutputTableHandle) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) Map(java.util.Map) RaptorSessionProperties.getExternalBatchId(io.trino.plugin.raptor.legacy.RaptorSessionProperties.getExternalBatchId) RAPTOR_ERROR(io.trino.plugin.raptor.legacy.RaptorErrorCode.RAPTOR_ERROR) ViewNotFoundException(io.trino.spi.connector.ViewNotFoundException) Set(java.util.Set) DatabaseUtil.onDemandDao(io.trino.plugin.raptor.legacy.util.DatabaseUtil.onDemandDao) SchemaTableName(io.trino.spi.connector.SchemaTableName) ConnectorPartitioningHandle(io.trino.spi.connector.ConnectorPartitioningHandle) SchemaTablePrefix(io.trino.spi.connector.SchemaTablePrefix) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) ConnectorTablePartitioning(io.trino.spi.connector.ConnectorTablePartitioning) DATE(io.trino.spi.type.DateType.DATE) ConnectorTableLayout(io.trino.spi.connector.ConnectorTableLayout) ConnectorInsertTableHandle(io.trino.spi.connector.ConnectorInsertTableHandle) Slice(io.airlift.slice.Slice) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) TIMESTAMP_MILLIS(io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) BUCKETED_ON_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.BUCKETED_ON_PROPERTY) Multimaps(com.google.common.collect.Multimaps) ArrayList(java.util.ArrayList) OptionalLong(java.util.OptionalLong) ColumnRangesSystemTable(io.trino.plugin.raptor.legacy.systemtables.ColumnRangesSystemTable) RaptorTableProperties.getSortColumns(io.trino.plugin.raptor.legacy.RaptorTableProperties.getSortColumns) ColumnHandle(io.trino.spi.connector.ColumnHandle) ORDERING_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.ORDERING_PROPERTY) INVALID_TABLE_PROPERTY(io.trino.spi.StandardErrorCode.INVALID_TABLE_PROPERTY) Jdbi(org.jdbi.v3.core.Jdbi) SHARD_UUID_COLUMN_NAME(io.trino.plugin.raptor.legacy.RaptorColumnHandle.SHARD_UUID_COLUMN_NAME) DatabaseUtil.runTransaction(io.trino.plugin.raptor.legacy.util.DatabaseUtil.runTransaction) MoreCollectors.toOptional(com.google.common.collect.MoreCollectors.toOptional) ConstraintApplicationResult(io.trino.spi.connector.ConstraintApplicationResult) DatabaseUtil.daoTransaction(io.trino.plugin.raptor.legacy.util.DatabaseUtil.daoTransaction) TableColumn(io.trino.plugin.raptor.legacy.metadata.TableColumn) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) ConnectorSession(io.trino.spi.connector.ConnectorSession) Table(io.trino.plugin.raptor.legacy.metadata.Table) JsonCodec.jsonCodec(io.airlift.json.JsonCodec.jsonCodec) ShardInfo(io.trino.plugin.raptor.legacy.metadata.ShardInfo) ConnectorTableProperties(io.trino.spi.connector.ConnectorTableProperties) TreeMap(java.util.TreeMap) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) RaptorColumnHandle.bucketNumberColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle.bucketNumberColumnHandle) ColumnInfo(io.trino.plugin.raptor.legacy.metadata.ColumnInfo) ViewResult(io.trino.plugin.raptor.legacy.metadata.ViewResult) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) RaptorTableProperties.getBucketColumns(io.trino.plugin.raptor.legacy.RaptorTableProperties.getBucketColumns) RaptorSessionProperties.getOneSplitPerBucketThreshold(io.trino.plugin.raptor.legacy.RaptorSessionProperties.getOneSplitPerBucketThreshold) ALREADY_EXISTS(io.trino.spi.StandardErrorCode.ALREADY_EXISTS) ConnectorViewDefinition(io.trino.spi.connector.ConnectorViewDefinition) INTEGER(io.trino.spi.type.IntegerType.INTEGER) MetadataDao(io.trino.plugin.raptor.legacy.metadata.MetadataDao) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collections.nCopies(java.util.Collections.nCopies) Collection(java.util.Collection) ColumnRangesSystemTable.getSourceTable(io.trino.plugin.raptor.legacy.systemtables.ColumnRangesSystemTable.getSourceTable) ComputedStatistics(io.trino.spi.statistics.ComputedStatistics) TrinoException(io.trino.spi.TrinoException) UUID(java.util.UUID) ConnectorOutputMetadata(io.trino.spi.connector.ConnectorOutputMetadata) ASC_NULLS_FIRST(io.trino.spi.connector.SortOrder.ASC_NULLS_FIRST) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) DISTRIBUTION_NAME_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.DISTRIBUTION_NAME_PROPERTY) List(java.util.List) BUCKET_COUNT_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.BUCKET_COUNT_PROPERTY) JsonCodecFactory(io.airlift.json.JsonCodecFactory) Optional(java.util.Optional) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata) SystemTable(io.trino.spi.connector.SystemTable) SortedMap(java.util.SortedMap) JsonCodec(io.airlift.json.JsonCodec) RaptorColumnHandle.isHiddenColumn(io.trino.plugin.raptor.legacy.RaptorColumnHandle.isHiddenColumn) RaptorColumnHandle.shardRowIdHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle.shardRowIdHandle) Constraint(io.trino.spi.connector.Constraint) Logger(io.airlift.log.Logger) Type(io.trino.spi.type.Type) OptionalInt(java.util.OptionalInt) AtomicReference(java.util.concurrent.atomic.AtomicReference) Collectors.toCollection(java.util.stream.Collectors.toCollection) Distribution(io.trino.plugin.raptor.legacy.metadata.Distribution) RaptorTableProperties.getDistributionName(io.trino.plugin.raptor.legacy.RaptorTableProperties.getDistributionName) ImmutableList(com.google.common.collect.ImmutableList) BUCKET_NUMBER_COLUMN_NAME(io.trino.plugin.raptor.legacy.RaptorColumnHandle.BUCKET_NUMBER_COLUMN_NAME) Objects.requireNonNull(java.util.Objects.requireNonNull) NOT_FOUND(io.trino.spi.StandardErrorCode.NOT_FOUND) RaptorTableProperties.getTemporalColumn(io.trino.plugin.raptor.legacy.RaptorTableProperties.getTemporalColumn) TupleDomain(io.trino.spi.predicate.TupleDomain) Maps(com.google.common.collect.Maps) LongConsumer(java.util.function.LongConsumer) TEMPORAL_COLUMN_PROPERTY(io.trino.plugin.raptor.legacy.RaptorTableProperties.TEMPORAL_COLUMN_PROPERTY) RaptorBucketFunction.validateBucketType(io.trino.plugin.raptor.legacy.RaptorBucketFunction.validateBucketType) Collectors.toList(java.util.stream.Collectors.toList) DatabaseUtil.runIgnoringConstraintViolation(io.trino.plugin.raptor.legacy.util.DatabaseUtil.runIgnoringConstraintViolation) RaptorTableProperties.getBucketCount(io.trino.plugin.raptor.legacy.RaptorTableProperties.getBucketCount) ImmutableList(com.google.common.collect.ImmutableList) TableColumn(io.trino.plugin.raptor.legacy.metadata.TableColumn) Type(io.trino.spi.type.Type) RaptorBucketFunction.validateBucketType(io.trino.plugin.raptor.legacy.RaptorBucketFunction.validateBucketType)

Aggregations

TableColumn (io.trino.plugin.raptor.legacy.metadata.TableColumn)11 ImmutableList (com.google.common.collect.ImmutableList)4 Table (io.trino.plugin.raptor.legacy.metadata.Table)4 SchemaTableName (io.trino.spi.connector.SchemaTableName)4 Type (io.trino.spi.type.Type)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ShardInfo (io.trino.plugin.raptor.legacy.metadata.ShardInfo)3 ShardMetadata (io.trino.plugin.raptor.legacy.metadata.ShardMetadata)3 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)3 List (java.util.List)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Multimaps (com.google.common.collect.Multimaps)2 Logger (io.airlift.log.Logger)2 ColumnInfo (io.trino.plugin.raptor.legacy.metadata.ColumnInfo)2 ColumnStats (io.trino.plugin.raptor.legacy.metadata.ColumnStats)2 MetadataDao (io.trino.plugin.raptor.legacy.metadata.MetadataDao)2 ShardManager (io.trino.plugin.raptor.legacy.metadata.ShardManager)2 ColumnRangesSystemTable (io.trino.plugin.raptor.legacy.systemtables.ColumnRangesSystemTable)2