Java Code Examples for io.prestosql.spi.connector.ColumnHandle

The following examples show how to use io.prestosql.spi.connector.ColumnHandle. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: presto   Source File: TestRaptorMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateTable()
{
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));

    metadata.createTable(SESSION, getOrdersTable(), false);

    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);
    assertEquals(((RaptorTableHandle) tableHandle).getTableId(), 1);

    ConnectorTableMetadata table = metadata.getTableMetadata(SESSION, tableHandle);
    assertTableEqual(table, getOrdersTable());

    ColumnHandle columnHandle = metadata.getColumnHandles(SESSION, tableHandle).get("orderkey");
    assertInstanceOf(columnHandle, RaptorColumnHandle.class);
    assertEquals(((RaptorColumnHandle) columnHandle).getColumnId(), 1);

    ColumnMetadata columnMetadata = metadata.getColumnMetadata(SESSION, tableHandle, columnHandle);
    assertNotNull(columnMetadata);
    assertEquals(columnMetadata.getName(), "orderkey");
    assertEquals(columnMetadata.getType(), BIGINT);
}
 
Example 2
@Test
public void consumesDeterministicPredicateIfNewDomainIsSame()
{
    ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
    tester().assertThat(removeRedundantTableScanPredicate)
            .on(p -> p.filter(expression("nationkey = BIGINT '44'"),
                    p.tableScan(
                            nationTableHandle,
                            ImmutableList.of(p.symbol("nationkey", BIGINT)),
                            ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle),
                            TupleDomain.fromFixedValues(ImmutableMap.of(
                                    columnHandle, NullableValue.of(BIGINT, (long) 44))))))
            .matches(constrainedTableScanWithTableLayout(
                    "nation",
                    ImmutableMap.of("nationkey", singleValue(BIGINT, (long) 44)),
                    ImmutableMap.of("nationkey", "nationkey")));
}
 
Example 3
Source Project: presto   Source File: HivePartitionManager.java    License: Apache License 2.0 6 votes vote down vote up
public HiveTableHandle applyPartitionResult(HiveTableHandle handle, HivePartitionResult partitions, Optional<Set<ColumnHandle>> columns)
{
    return new HiveTableHandle(
            handle.getSchemaName(),
            handle.getTableName(),
            handle.getTableParameters(),
            ImmutableList.copyOf(partitions.getPartitionColumns()),
            Optional.of(getPartitionsAsList(partitions)),
            partitions.getCompactEffectivePredicate(),
            partitions.getEnforcedConstraint(),
            partitions.getBucketHandle(),
            partitions.getBucketFilter(),
            handle.getAnalyzePartitionValues(),
            handle.getAnalyzeColumnNames(),
            Optionals.combine(handle.getConstraintColumns(), columns,
                    (oldColumns, newColumns) -> Sets.union(oldColumns, newColumns)));
}
 
Example 4
Source Project: presto   Source File: LocalFileMetadata.java    License: Apache License 2.0 6 votes vote down vote up
private Map<String, ColumnHandle> getColumnHandles(LocalFileTableHandle tableHandle)
{
    ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
    int index = 0;
    for (ColumnMetadata column : localFileTables.getColumns(tableHandle)) {
        int ordinalPosition;
        if (column.getName().equals(SERVER_ADDRESS_COLUMN_NAME)) {
            ordinalPosition = SERVER_ADDRESS_ORDINAL_POSITION;
        }
        else {
            ordinalPosition = index;
            index++;
        }
        columnHandles.put(column.getName(), new LocalFileColumnHandle(column.getName(), column.getType(), ordinalPosition));
    }
    return columnHandles.build();
}
 
Example 5
Source Project: presto   Source File: TpcdsTableStatisticsFactory.java    License: Apache License 2.0 6 votes vote down vote up
private TableStatistics toTableStatistics(Map<String, ColumnHandle> columnHandles, TableStatisticsData statisticsData)
{
    long rowCount = statisticsData.getRowCount();
    TableStatistics.Builder tableStatistics = TableStatistics.builder()
            .setRowCount(Estimate.of(rowCount));

    if (rowCount > 0) {
        Map<String, ColumnStatisticsData> columnsData = statisticsData.getColumns();
        for (Map.Entry<String, ColumnHandle> entry : columnHandles.entrySet()) {
            TpcdsColumnHandle columnHandle = (TpcdsColumnHandle) entry.getValue();
            tableStatistics.setColumnStatistics(entry.getValue(), toColumnStatistics(columnsData.get(entry.getKey()), columnHandle.getType(), rowCount));
        }
    }

    return tableStatistics.build();
}
 
Example 6
Source Project: presto   Source File: TestEffectivePredicateExtractor.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeMethod
public void setUp()
{
    scanAssignments = ImmutableMap.<Symbol, ColumnHandle>builder()
            .put(A, new TestingColumnHandle("a"))
            .put(B, new TestingColumnHandle("b"))
            .put(C, new TestingColumnHandle("c"))
            .put(D, new TestingColumnHandle("d"))
            .put(E, new TestingColumnHandle("e"))
            .put(F, new TestingColumnHandle("f"))
            .build();

    Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D, E, F)));
    baseTableScan = TableScanNode.newInstance(
            newId(),
            makeTableHandle(TupleDomain.all()),
            ImmutableList.copyOf(assignments.keySet()),
            assignments);

    expressionNormalizer = new ExpressionIdentityNormalizer();
}
 
Example 7
private void createScanFilterAndProjectOperatorFactories(List<Page> inputPages, PageProcessor pageProcessor, CursorProcessor cursorProcessor, List<ColumnHandle> columnHandles, List<Type> types)
{
    operatorFactory = new ScanFilterAndProjectOperatorFactory(
            0,
            new PlanNodeId("test"),
            new PlanNodeId("test_source"),
            (session, split, table, columns, dynamicFilter) -> new FixedPageSource(inputPages),
            () -> cursorProcessor,
            () -> pageProcessor,
            TEST_TABLE_HANDLE,
            columnHandles,
            TupleDomain::all,
            types,
            FILTER_AND_PROJECT_MIN_OUTPUT_PAGE_SIZE,
            FILTER_AND_PROJECT_MIN_OUTPUT_PAGE_ROW_COUNT);
}
 
Example 8
@Test
public void doesNotFireOnNonDeterministicPredicate()
{
    ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
    tester().assertThat(removeRedundantTableScanPredicate)
            .on(p -> p.filter(
                    new ComparisonExpression(
                            EQUAL,
                            new FunctionCallBuilder(tester().getMetadata())
                                    .setName(QualifiedName.of("rand"))
                                    .build(),
                            new GenericLiteral("BIGINT", "42")),
                    p.tableScan(
                            nationTableHandle,
                            ImmutableList.of(p.symbol("nationkey", BIGINT)),
                            ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle),
                            TupleDomain.all())))
            .doesNotFire();
}
 
Example 9
Source Project: presto   Source File: KuduMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint)
{
    KuduTableHandle handle = (KuduTableHandle) table;

    TupleDomain<ColumnHandle> oldDomain = handle.getConstraint();
    TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
    if (oldDomain.equals(newDomain)) {
        return Optional.empty();
    }

    handle = new KuduTableHandle(
            handle.getSchemaTableName(),
            handle.getTable(clientSession),
            newDomain,
            handle.getDesiredColumns(),
            handle.isDeleteHandle());

    return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary()));
}
 
Example 10
Source Project: presto   Source File: TestJmxSplitManager.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPredicatePushdown()
        throws Exception
{
    for (Node node : nodes) {
        String nodeIdentifier = node.getNodeIdentifier();
        TupleDomain<ColumnHandle> nodeTupleDomain = TupleDomain.fromFixedValues(ImmutableMap.of(columnHandle, NullableValue.of(createUnboundedVarcharType(), utf8Slice(nodeIdentifier))));
        JmxTableHandle tableHandle = new JmxTableHandle(new SchemaTableName("schema", "tableName"), ImmutableList.of("objectName"), ImmutableList.of(columnHandle), true, nodeTupleDomain);

        ConnectorSplitSource splitSource = splitManager.getSplits(JmxTransactionHandle.INSTANCE, SESSION, tableHandle, UNGROUPED_SCHEDULING);
        List<ConnectorSplit> allSplits = getAllSplits(splitSource);

        assertEquals(allSplits.size(), 1);
        assertEquals(allSplits.get(0).getAddresses().size(), 1);
        assertEquals(allSplits.get(0).getAddresses().get(0).getHostText(), nodeIdentifier);
    }
}
 
Example 11
Source Project: presto   Source File: DistributedExecutionPlanner.java    License: Apache License 2.0 6 votes vote down vote up
private Map<PlanNodeId, SplitSource> visitScanAndFilter(TableScanNode node, Optional<FilterNode> filter)
{
    List<DynamicFilters.Descriptor> dynamicFilters = filter
            .map(FilterNode::getPredicate)
            .map(DynamicFilters::extractDynamicFilters)
            .map(DynamicFilters.ExtractResult::getDynamicConjuncts)
            .orElse(ImmutableList.of());

    Supplier<TupleDomain<ColumnHandle>> dynamicFilterSupplier = TupleDomain::all;
    if (!dynamicFilters.isEmpty()) {
        log.debug("Dynamic filters: %s", dynamicFilters);
        dynamicFilterSupplier = dynamicFilterService.createDynamicFilterSupplier(session.getQueryId(), dynamicFilters, node.getAssignments());
    }

    // get dataSource for table
    SplitSource splitSource = splitManager.getSplits(
            session,
            node.getTable(),
            stageExecutionDescriptor.isScanGroupedExecution(node.getId()) ? GROUPED_SCHEDULING : UNGROUPED_SCHEDULING,
            dynamicFilterSupplier);

    splitSources.add(splitSource);

    return ImmutableMap.of(node.getId(), splitSource);
}
 
Example 12
Source Project: presto   Source File: RaptorMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    ImmutableMap.Builder<String, ColumnHandle> builder = ImmutableMap.builder();
    for (TableColumn tableColumn : dao.listTableColumns(raptorTableHandle.getTableId())) {
        builder.put(tableColumn.getColumnName(), getRaptorColumnHandle(tableColumn));
    }

    RaptorColumnHandle uuidColumn = shardUuidColumnHandle();
    builder.put(uuidColumn.getColumnName(), uuidColumn);

    if (raptorTableHandle.isBucketed()) {
        RaptorColumnHandle bucketNumberColumn = bucketNumberColumnHandle();
        builder.put(bucketNumberColumn.getColumnName(), bucketNumberColumn);
    }

    return builder.build();
}
 
Example 13
Source Project: presto   Source File: BigQueryMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(
        ConnectorSession session,
        ConnectorTableHandle handle,
        Constraint constraint)
{
    log.debug("applyFilter(session=%s, handle=%s, summary=%s, predicate=%s, columns=%s)",
            session, handle, constraint.getSummary(), constraint.predicate(), constraint.getPredicateColumns());
    BigQueryTableHandle bigQueryTableHandle = (BigQueryTableHandle) handle;

    TupleDomain<ColumnHandle> oldDomain = bigQueryTableHandle.getConstraint();
    TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
    if (oldDomain.equals(newDomain)) {
        return Optional.empty();
    }

    BigQueryTableHandle updatedHandle = bigQueryTableHandle.withConstraint(newDomain);

    return Optional.of(new ConstraintApplicationResult<>(updatedHandle, constraint.getSummary()));
}
 
Example 14
Source Project: presto   Source File: TestJdbcRecordSetProvider.java    License: Apache License 2.0 6 votes vote down vote up
private RecordCursor getCursor(JdbcTableHandle jdbcTableHandle, List<JdbcColumnHandle> columns, TupleDomain<ColumnHandle> domain)
{
    jdbcTableHandle = new JdbcTableHandle(
            jdbcTableHandle.getSchemaTableName(),
            jdbcTableHandle.getCatalogName(),
            jdbcTableHandle.getSchemaName(),
            jdbcTableHandle.getTableName(),
            domain,
            Optional.empty(),
            OptionalLong.empty(),
            Optional.empty());

    ConnectorSplitSource splits = jdbcClient.getSplits(SESSION, jdbcTableHandle);
    JdbcSplit split = (JdbcSplit) getOnlyElement(getFutureValue(splits.getNextBatch(NOT_PARTITIONED, 1000)).getSplits());

    ConnectorTransactionHandle transaction = new JdbcTransactionHandle();
    JdbcRecordSetProvider recordSetProvider = new JdbcRecordSetProvider(jdbcClient);
    RecordSet recordSet = recordSetProvider.getRecordSet(transaction, SESSION, split, jdbcTableHandle, columns);

    return recordSet.cursor();
}
 
Example 15
Source Project: presto   Source File: DynamicTableBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private static List<String> resolvePinotColumns(SchemaTableName schemaTableName, List<String> prestoColumnNames, Map<String, ColumnHandle> columnHandles)
{
    ImmutableList.Builder<String> pinotColumnNamesBuilder = ImmutableList.builder();
    for (String prestoColumnName : prestoColumnNames) {
        if (prestoColumnName.equals(WILDCARD)) {
            pinotColumnNamesBuilder.addAll(columnHandles.values().stream().map(handle -> ((PinotColumnHandle) handle).getColumnName()).collect(toImmutableList()));
        }
        else {
            PinotColumnHandle columnHandle = (PinotColumnHandle) columnHandles.get(prestoColumnName);
            if (columnHandle == null) {
                throw new ColumnNotFoundException(schemaTableName, prestoColumnName);
            }
            pinotColumnNamesBuilder.add(columnHandle.getColumnName());
        }
    }
    return pinotColumnNamesBuilder.build();
}
 
Example 16
Source Project: presto   Source File: TestRaptorMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRenameColumn()
{
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    metadata.createTable(SESSION, getOrdersTable(), false);
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);

    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    ColumnHandle columnHandle = metadata.getColumnHandles(SESSION, tableHandle).get("orderkey");

    metadata.renameColumn(SESSION, raptorTableHandle, columnHandle, "orderkey_renamed");

    assertNull(metadata.getColumnHandles(SESSION, tableHandle).get("orderkey"));
    assertNotNull(metadata.getColumnHandles(SESSION, tableHandle).get("orderkey_renamed"));
}
 
Example 17
Source Project: presto   Source File: PinotMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint)
{
    PinotTableHandle handle = (PinotTableHandle) table;
    TupleDomain<ColumnHandle> oldDomain = handle.getConstraint();
    TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
    if (oldDomain.equals(newDomain)) {
        return Optional.empty();
    }

    handle = new PinotTableHandle(
            handle.getSchemaName(),
            handle.getTableName(),
            newDomain,
            handle.getLimit(),
            handle.getQuery());
    return Optional.of(new ConstraintApplicationResult<>(handle, constraint.getSummary()));
}
 
Example 18
Source Project: presto   Source File: TestOrcPageSourceMemoryTracking.java    License: Apache License 2.0 5 votes vote down vote up
public SourceOperator newScanFilterAndProjectOperator(DriverContext driverContext)
{
    ConnectorPageSource pageSource = newPageSource();
    ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder();
    for (int i = 0; i < types.size(); i++) {
        projectionsBuilder.add(field(i, types.get(i)));
    }
    Supplier<CursorProcessor> cursorProcessor = EXPRESSION_COMPILER.compileCursorProcessor(Optional.empty(), projectionsBuilder.build(), "key");
    Supplier<PageProcessor> pageProcessor = EXPRESSION_COMPILER.compilePageProcessor(Optional.empty(), projectionsBuilder.build());
    SourceOperatorFactory sourceOperatorFactory = new ScanFilterAndProjectOperatorFactory(
            0,
            new PlanNodeId("test"),
            new PlanNodeId("0"),
            (session, split, table, columnHandles, dynamicFilter) -> pageSource,
            cursorProcessor,
            pageProcessor,
            TEST_TABLE_HANDLE,
            columns.stream().map(columnHandle -> (ColumnHandle) columnHandle).collect(toList()),
            TupleDomain::all,
            types,
            DataSize.ofBytes(0),
            0);
    SourceOperator operator = sourceOperatorFactory.createOperator(driverContext);
    operator.addSplit(new Split(new CatalogName("test"), TestingSplit.createLocalSplit(), Lifespan.taskWide()));
    operator.noMoreSplits();
    return operator;
}
 
Example 19
Source Project: presto   Source File: SystemTablesMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(ConnectorSession session, ConnectorTableHandle handle, Constraint constraint)
{
    SystemTableHandle table = (SystemTableHandle) handle;

    TupleDomain<ColumnHandle> oldDomain = table.getConstraint();
    TupleDomain<ColumnHandle> newDomain = oldDomain.intersect(constraint.getSummary());
    if (oldDomain.equals(newDomain) && constraint.predicate().isEmpty()) {
        return Optional.empty();
    }

    SystemTable systemTable = checkAndGetTable(session, table);
    if (systemTable instanceof JdbcTable) {
        TupleDomain<ColumnHandle> filtered = ((JdbcTable) systemTable).applyFilter(session, new Constraint(newDomain, constraint.predicate(), constraint.getColumns()));
        newDomain = newDomain.intersect(filtered);
    }

    if (oldDomain.equals(newDomain)) {
        return Optional.empty();
    }

    if (newDomain.isNone()) {
        // TODO (https://github.com/prestosql/presto/issues/3647) indicate the table scan is empty
    }
    table = new SystemTableHandle(table.getSchemaName(), table.getTableName(), newDomain);
    return Optional.of(new ConstraintApplicationResult<>(table, constraint.getSummary()));
}
 
Example 20
Source Project: presto   Source File: SystemTablesMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
{
    ConnectorTableMetadata tableMetadata = checkAndGetTable(session, tableHandle).getTableMetadata();

    String columnName = ((SystemColumnHandle) columnHandle).getColumnName();

    ColumnMetadata columnMetadata = findColumnMetadata(tableMetadata, columnName);
    checkArgument(columnMetadata != null, "Column '%s' on table '%s' does not exist", columnName, tableMetadata.getTable());
    return columnMetadata;
}
 
Example 21
Source Project: presto   Source File: SheetsRecordSetProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, ConnectorTableHandle table, List<? extends ColumnHandle> columns)
{
    requireNonNull(split, "split is null");
    SheetsSplit sheetsSplit = (SheetsSplit) split;

    List<SheetsColumnHandle> handles = columns.stream().map(c -> (SheetsColumnHandle) c).collect(Collectors.toList());
    return new SheetsRecordSet(sheetsSplit, handles);
}
 
Example 22
Source Project: presto   Source File: TpchMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
{
    ConnectorTableMetadata tableMetadata = getTableMetadata(session, tableHandle);
    String columnName = ((TpchColumnHandle) columnHandle).getColumnName();

    for (ColumnMetadata column : tableMetadata.getColumns()) {
        if (column.getName().equals(columnName)) {
            return column;
        }
    }
    throw new IllegalArgumentException(format("Table '%s' does not have column '%s'", tableMetadata.getTable(), columnName));
}
 
Example 23
Source Project: presto   Source File: MongoMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table)
{
    MongoTableHandle tableHandle = (MongoTableHandle) table;

    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty(); //TODO: sharding key
    ImmutableList.Builder<LocalProperty<ColumnHandle>> localProperties = ImmutableList.builder();

    MongoTable tableInfo = mongoSession.getTable(tableHandle.getSchemaTableName());
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);

    for (MongoIndex index : tableInfo.getIndexes()) {
        for (MongodbIndexKey key : index.getKeys()) {
            if (key.getSortOrder().isEmpty()) {
                continue;
            }
            if (columns.get(key.getName()) != null) {
                localProperties.add(new SortingProperty<>(columns.get(key.getName()), key.getSortOrder().get()));
            }
        }
    }

    return new ConnectorTableProperties(
            TupleDomain.all(),
            Optional.empty(),
            partitioningColumns,
            Optional.empty(),
            localProperties.build());
}
 
Example 24
Source Project: presto   Source File: SplitManager.java    License: Apache License 2.0 5 votes vote down vote up
public SplitSource getSplits(Session session, TableHandle table, SplitSchedulingStrategy splitSchedulingStrategy, Supplier<TupleDomain<ColumnHandle>> dynamicFilter)
{
    CatalogName catalogName = table.getCatalogName();
    ConnectorSplitManager splitManager = getConnectorSplitManager(catalogName);

    ConnectorSession connectorSession = session.toConnectorSession(catalogName);

    ConnectorSplitSource source;
    if (metadata.usesLegacyTableLayouts(session, table)) {
        ConnectorTableLayoutHandle layout = table.getLayout()
                .orElseGet(() -> metadata.getLayout(session, table, Constraint.alwaysTrue(), Optional.empty())
                        .get()
                        .getNewTableHandle()
                        .getLayout().get());

        source = splitManager.getSplits(table.getTransaction(), connectorSession, layout, splitSchedulingStrategy);
    }
    else {
        source = splitManager.getSplits(
                table.getTransaction(),
                connectorSession,
                table.getConnectorHandle(),
                splitSchedulingStrategy,
                dynamicFilter);
    }

    SplitSource splitSource = new ConnectorAwareSplitSource(catalogName, source);
    int minScheduleSplitBatchSize = this.minScheduleSplitBatchSize;
    if (splitSource.getMinScheduleSplitBatchSize().isPresent()) {
        minScheduleSplitBatchSize = min(minScheduleSplitBatchSize, splitSource.getMinScheduleSplitBatchSize().get());
    }
    if (minScheduleSplitBatchSize > 1) {
        splitSource = new BufferingSplitSource(splitSource, minScheduleSplitBatchSize);
    }
    return splitSource;
}
 
Example 25
Source Project: presto   Source File: TestTpchMetadata.java    License: Apache License 2.0 5 votes vote down vote up
private static TupleDomain<ColumnHandle> fixedValueTupleDomain(TpchMetadata tpchMetadata, TpchColumn<?> column, Object value)
{
    requireNonNull(column, "column is null");
    requireNonNull(value, "value is null");
    return TupleDomain.fromFixedValues(
            ImmutableMap.of(tpchMetadata.toColumnHandle(column), new NullableValue(getPrestoType(column), value)));
}
 
Example 26
Source Project: presto   Source File: TestEffectivePredicateExtractor.java    License: Apache License 2.0 5 votes vote down vote up
private static TableHandle makeTableHandle(TupleDomain<ColumnHandle> predicate)
{
    return new TableHandle(
            new CatalogName("test"),
            new PredicatedTableHandle(predicate),
            TestingTransactionHandle.create(),
            Optional.empty());
}
 
Example 27
Source Project: presto   Source File: ExampleRecordSetProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorSplit split, ConnectorTableHandle table, List<? extends ColumnHandle> columns)
{
    ExampleSplit exampleSplit = (ExampleSplit) split;

    ImmutableList.Builder<ExampleColumnHandle> handles = ImmutableList.builder();
    for (ColumnHandle handle : columns) {
        handles.add((ExampleColumnHandle) handle);
    }

    return new ExampleRecordSet(exampleSplit, handles.build());
}
 
Example 28
Source Project: presto   Source File: MetadataManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void dropColumn(Session session, TableHandle tableHandle, ColumnHandle column)
{
    CatalogName catalogName = tableHandle.getCatalogName();
    ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
    metadata.dropColumn(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), column);
}
 
Example 29
Source Project: presto   Source File: BlackHoleMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
    BlackHoleTableHandle blackHoleTableHandle = (BlackHoleTableHandle) tableHandle;
    return blackHoleTableHandle.getColumnHandles().stream()
            .collect(toMap(BlackHoleColumnHandle::getName, column -> column));
}
 
Example 30
Source Project: presto   Source File: LocalExecutionPlanner.java    License: Apache License 2.0 5 votes vote down vote up
private PhysicalOperation visitTableScan(TableScanNode node, Expression filterExpression, LocalExecutionPlanContext context)
{
    List<ColumnHandle> columns = new ArrayList<>();
    for (Symbol symbol : node.getOutputSymbols()) {
        columns.add(node.getAssignments().get(symbol));
    }

    Supplier<TupleDomain<ColumnHandle>> dynamicFilter = getDynamicFilter(node, filterExpression, context);
    OperatorFactory operatorFactory = new TableScanOperatorFactory(context.getNextOperatorId(), node.getId(), pageSourceProvider, node.getTable(), columns, dynamicFilter);
    return new PhysicalOperation(operatorFactory, makeLayout(node), context, stageExecutionDescriptor.isScanGroupedExecution(node.getId()) ? GROUPED_EXECUTION : UNGROUPED_EXECUTION);
}