use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestPrometheusSplit method testPredicatePushDownLowerBoundDirect.
@Test
public void testPredicatePushDownLowerBoundDirect() {
Range lowRange = Range.greaterThanOrEqual(TIMESTAMP_WITH_TIME_ZONE, packDateTimeWithZone(1570460709643L, UTC_KEY));
ValueSet valueSet = ValueSet.ofRanges(lowRange);
Domain testDomain = Domain.create(valueSet, false);
TupleDomain<ColumnHandle> testTupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(new PrometheusColumnHandle("timestamp", TIMESTAMP_WITH_TIME_ZONE, 2), testDomain));
PrometheusPredicateTimeInfo predicateTimes = PrometheusSplitManager.determinePredicateTimes(testTupleDomain).orElseThrow(() -> new AssertionError("predicate pushdown error on Prometheus Column"));
Instant expected = ofEpochMilli(1570460709643L);
assertEquals(predicateTimes.getPredicateLowerTimeBound().orElseThrow(() -> new AssertionError("predicate pushdown error on Prometheus Column")), expected);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestPrometheusSplit method testQueryWithTableNameNeedingURLEncodeInSplits.
@Test
public void testQueryWithTableNameNeedingURLEncodeInSplits() throws URISyntaxException {
Instant now = LocalDateTime.of(2019, 10, 2, 7, 26, 56, 0).toInstant(UTC);
PrometheusConnectorConfig config = getCommonConfig(prometheusHttpServer.resolve("/prometheus-data/prom-metrics-non-standard-name.json"));
PrometheusClient client = new PrometheusClient(config, METRIC_CODEC, TYPE_MANAGER);
PrometheusTable table = client.getTable("default", "up+now");
PrometheusTableHandle tableHandle = new PrometheusTableHandle("default", table.getName());
TupleDomain<ColumnHandle> columnConstraints = TupleDomain.withColumnDomains(ImmutableMap.of(new PrometheusColumnHandle("value", BIGINT, 1), Domain.all(VARCHAR), new PrometheusColumnHandle("text", createUnboundedVarcharType(), 0), Domain.all(VARCHAR)));
PrometheusTableLayoutHandle tableLayoutHandle = new PrometheusTableLayoutHandle(tableHandle, columnConstraints);
PrometheusSplitManager splitManager = new PrometheusSplitManager(client, fixedClockAt(now), config);
ConnectorSplitSource splits = splitManager.getSplits(null, null, tableLayoutHandle, null);
PrometheusSplit split = (PrometheusSplit) splits.getNextBatch(NOT_PARTITIONED, 1).getNow(null).getSplits().get(0);
String queryInSplit = split.getUri().getQuery();
String timeShouldBe = decimalSecondString(now.toEpochMilli() - config.getMaxQueryRangeDuration().toMillis() + config.getQueryChunkSizeDuration().toMillis() - OFFSET_MILLIS * 20);
assertEquals(queryInSplit, new URI("http://doesnotmatter:9090/api/v1/query?query=up+now[" + getQueryChunkSizeDurationAsPrometheusCompatibleDurationString(config) + "]" + "&time=" + timeShouldBe).getQuery());
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class RaptorPageSourceProvider method createPageSource.
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, List<ColumnHandle> columns, SplitContext splitContext) {
RaptorSplit raptorSplit = (RaptorSplit) split;
OptionalInt bucketNumber = raptorSplit.getBucketNumber();
TupleDomain<RaptorColumnHandle> predicate = raptorSplit.getEffectivePredicate();
ReaderAttributes attributes = ReaderAttributes.from(session);
OptionalLong transactionId = raptorSplit.getTransactionId();
Optional<Map<String, Type>> columnTypes = raptorSplit.getColumnTypes();
boolean tableSupportsDeltaDelete = raptorSplit.isTableSupportsDeltaDelete();
HdfsContext context = new HdfsContext(session);
Map<UUID, UUID> shardDeltaMap = raptorSplit.getShardDeltaMap();
if (raptorSplit.getShardUuids().size() == 1) {
UUID shardUuid = raptorSplit.getShardUuids().iterator().next();
return createPageSource(context, DEFAULT_HIVE_FILE_CONTEXT, shardUuid, Optional.ofNullable(shardDeltaMap.get(shardUuid)), tableSupportsDeltaDelete, bucketNumber, columns, predicate, attributes, transactionId, columnTypes);
}
Iterator<ConnectorPageSource> iterator = raptorSplit.getShardUuids().stream().map(shardUuid -> createPageSource(context, DEFAULT_HIVE_FILE_CONTEXT, shardUuid, Optional.ofNullable(shardDeltaMap.get(shardUuid)), tableSupportsDeltaDelete, bucketNumber, columns, predicate, attributes, transactionId, columnTypes)).iterator();
return new ConcatPageSource(iterator);
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class AtopMetadata method getColumnHandles.
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) {
AtopTableHandle atopTableHandle = (AtopTableHandle) tableHandle;
ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder();
for (AtopColumn column : atopTableHandle.getTable().getColumns()) {
columnHandles.put(column.getName(), new AtopColumnHandle(column.getName()));
}
return columnHandles.build();
}
use of com.facebook.presto.spi.ColumnHandle in project presto by prestodb.
the class TestJdbcQueryBuilder method testBuildSqlWithFloat.
@Test
public void testBuildSqlWithFloat() throws SQLException {
TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.of(columns.get(10), Domain.create(SortedRangeSet.copyOf(REAL, ImmutableList.of(Range.equal(REAL, (long) floatToRawIntBits(100.0f + 0)), Range.equal(REAL, (long) floatToRawIntBits(100.008f + 0)), Range.equal(REAL, (long) floatToRawIntBits(100.0f + 14)))), false)));
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> longBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Float> floatBuilder = ImmutableSet.builder();
while (resultSet.next()) {
longBuilder.add((Long) resultSet.getObject("col_0"));
floatBuilder.add((Float) resultSet.getObject("col_10"));
}
assertEquals(longBuilder.build(), ImmutableSet.of(0L, 14L));
assertEquals(floatBuilder.build(), ImmutableSet.of(100.0f, 114.0f));
}
}
Aggregations