use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestJdbcQueryBuilder method testEmptyBuildSql.
@Test
public void testEmptyBuildSql() throws SQLException {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(columns.get(0), Domain.all(BIGINT), columns.get(1), Domain.onlyNull(DOUBLE)));
Connection connection = database.getConnection();
try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql(jdbcClient, session, connection, "", "", "test_table", columns, tupleDomain, Optional.empty());
ResultSet resultSet = preparedStatement.executeQuery()) {
assertEquals(resultSet.next(), false);
}
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestJdbcQueryBuilder method testNormalBuildSql.
@Test
public void testNormalBuildSql() throws SQLException {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>builder().put(columns.get(0), Domain.create(SortedRangeSet.copyOf(BIGINT, ImmutableList.of(Range.equal(BIGINT, 128L), Range.equal(BIGINT, 180L), Range.equal(BIGINT, 233L), Range.lessThan(BIGINT, 25L), Range.range(BIGINT, 66L, true, 96L, true), Range.greaterThan(BIGINT, 192L))), false)).put(columns.get(1), Domain.create(SortedRangeSet.copyOf(DOUBLE, ImmutableList.of(Range.equal(DOUBLE, 200011.0), Range.equal(DOUBLE, 200014.0), Range.equal(DOUBLE, 200017.0), Range.equal(DOUBLE, 200116.5), Range.range(DOUBLE, 200030.0, true, 200036.0, true), Range.range(DOUBLE, 200048.0, true, 200099.0, true))), false)).put(columns.get(7), Domain.create(SortedRangeSet.copyOf(TINYINT, ImmutableList.of(Range.range(TINYINT, 60L, true, 70L, false), Range.range(TINYINT, 52L, true, 55L, false))), false)).put(columns.get(8), Domain.create(SortedRangeSet.copyOf(SMALLINT, ImmutableList.of(Range.range(SMALLINT, -75L, true, -68L, true), Range.range(SMALLINT, -200L, true, -100L, false))), false)).put(columns.get(9), Domain.create(SortedRangeSet.copyOf(INTEGER, ImmutableList.of(Range.equal(INTEGER, 80L), Range.equal(INTEGER, 96L), Range.lessThan(INTEGER, 0L))), false)).put(columns.get(2), Domain.create(SortedRangeSet.copyOf(BOOLEAN, ImmutableList.of(Range.equal(BOOLEAN, true))), false)).build());
Connection connection = database.getConnection();
try (PreparedStatement preparedStatement = new QueryBuilder("\"").buildSql(jdbcClient, session, connection, "", "", "test_table", columns, tupleDomain, Optional.empty());
ResultSet resultSet = preparedStatement.executeQuery()) {
ImmutableSet.Builder<Long> builder = ImmutableSet.builder();
while (resultSet.next()) {
builder.add((Long) resultSet.getObject("col_0"));
}
assertEquals(builder.build(), ImmutableSet.of(68L, 180L, 196L));
}
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class JdbcRecordSetProvider method getRecordSet.
@Override
public RecordSet getRecordSet(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<? extends ColumnHandle> columns) {
JdbcSplit jdbcSplit = (JdbcSplit) split;
ImmutableList.Builder<JdbcColumnHandle> handles = ImmutableList.builder();
for (ColumnHandle handle : columns) {
handles.add((JdbcColumnHandle) handle);
}
return new JdbcRecordSet(jdbcClient, session, jdbcSplit, handles.build());
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class DeltaMetadata method getTableLayouts.
@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
DeltaTableHandle tableHandle = (DeltaTableHandle) table;
// Split the predicate into partition column predicate and other column predicates
// Only the partition column predicate is fully enforced. Other predicate is partially enforced (best effort).
List<TupleDomain<ColumnHandle>> predicate = splitPredicate(constraint.getSummary());
TupleDomain<ColumnHandle> unenforcedPredicate = predicate.get(1);
DeltaTableLayoutHandle newDeltaTableLayoutHandle = new DeltaTableLayoutHandle(tableHandle, constraint.getSummary().transform(DeltaColumnHandle.class::cast), Optional.of(constraint.getSummary().toString(session.getSqlFunctionProperties())));
ConnectorTableLayout newLayout = new ConnectorTableLayout(newDeltaTableLayoutHandle, Optional.empty(), constraint.getSummary(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), Optional.empty());
return ImmutableList.of(new ConnectorTableLayoutResult(newLayout, unenforcedPredicate));
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class MongoPageSourceProvider method createPageSource.
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns, SplitContext splitContext) {
MongoSplit mongodbSplit = (MongoSplit) split;
ImmutableList.Builder<MongoColumnHandle> handles = ImmutableList.builder();
for (ColumnHandle handle : requireNonNull(columns, "columns is null")) {
handles.add((MongoColumnHandle) handle);
}
return new MongoPageSource(mongoSession, mongodbSplit, handles.build());
}
Aggregations