use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.
the class TestRaptorMetadata method testTransactionSelect.
@Test
public void testTransactionSelect() {
metadata.createTable(SESSION, getOrdersTable(), false);
// reads do not create a transaction
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
assertInstanceOf(tableHandle, RaptorTableHandle.class);
assertFalse(((RaptorTableHandle) tableHandle).getTransactionId().isPresent());
}
use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.
the class TestRaptorMetadata method testAddColumn.
@Test
public void testAddColumn() {
assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
metadata.createTable(SESSION, buildTable(ImmutableMap.of(TABLE_SUPPORTS_DELTA_DELETE, false), tableMetadataBuilder(DEFAULT_TEST_ORDERS).column("orderkey", BIGINT).column("price", BIGINT)), false);
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
assertInstanceOf(tableHandle, RaptorTableHandle.class);
RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
metadata.addColumn(SESSION, raptorTableHandle, new ColumnMetadata("new_col", BIGINT));
assertNotNull(metadata.getColumnHandles(SESSION, raptorTableHandle).get("new_col"));
}
use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.
the class TestMetadataManager method testGetTableStatisticsThrows.
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetTableStatisticsThrows() {
Session session = testSessionBuilder().setSystemProperty(IGNORE_STATS_CALCULATOR_FAILURES, "false").build();
TableHandle tableHandle = new TableHandle(new ConnectorId("upper_case_schema_catalog"), new ConnectorTableHandle() {
}, TestingTransactionHandle.create(), Optional.empty());
TransactionBuilder.transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl()).execute(session, transactionSession -> {
queryRunner.getMetadata().getCatalogHandle(transactionSession, "upper_case_schema_catalog");
assertEquals(queryRunner.getMetadata().getTableStatistics(transactionSession, tableHandle, ImmutableList.of(), alwaysTrue()), TableStatistics.empty());
});
}
use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.
the class RaptorMetadata method beginInsert.
@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle) {
RaptorTableHandle handle = (RaptorTableHandle) tableHandle;
long tableId = handle.getTableId();
ImmutableList.Builder<RaptorColumnHandle> columnHandles = ImmutableList.builder();
ImmutableList.Builder<Type> columnTypes = ImmutableList.builder();
for (TableColumn column : dao.listTableColumns(tableId)) {
columnHandles.add(new RaptorColumnHandle(connectorId, 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);
Optional<RaptorColumnHandle> temporalColumnHandle = Optional.ofNullable(dao.getTemporalColumnId(tableId)).map(temporalColumnId -> getOnlyElement(columnHandles.build().stream().filter(columnHandle -> columnHandle.getColumnId() == temporalColumnId).collect(toList())));
return new RaptorInsertTableHandle(connectorId, transactionId, tableId, columnHandles.build(), columnTypes.build(), externalBatchId, sortColumnHandles, nCopies(sortColumnHandles.size(), ASC_NULLS_FIRST), handle.getBucketCount(), bucketColumnHandles, temporalColumnHandle);
}
use of com.facebook.presto.spi.ConnectorTableHandle in project presto by prestodb.
the class TestPrometheusRecordSetProvider method testGetRecordSet.
@Test
public void testGetRecordSet() {
ConnectorTableHandle tableHandle = new PrometheusTableHandle("schema", "table");
PrometheusRecordSetProvider recordSetProvider = new PrometheusRecordSetProvider(client);
RecordSet recordSet = recordSetProvider.getRecordSet(PrometheusTransactionHandle.INSTANCE, SESSION, new PrometheusSplit(dataUri), ImmutableList.of(new PrometheusColumnHandle("labels", varcharMapType, 0), new PrometheusColumnHandle("timestamp", TIMESTAMP_WITH_TIME_ZONE, 1), new PrometheusColumnHandle("value", DoubleType.DOUBLE, 2)));
assertNotNull(recordSet, "recordSet is null");
RecordCursor cursor = recordSet.cursor();
assertNotNull(cursor, "cursor is null");
Map<Instant, Map<?, ?>> actual = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
actual.put((Instant) cursor.getObject(1), getMapFromBlock(varcharMapType, (Block) cursor.getObject(0)));
}
Map<Instant, Map<String, String>> expected = ImmutableMap.<Instant, Map<String, String>>builder().put(ofEpochMilli(1565962969044L), ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")).put(ofEpochMilli(1565962984045L), ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")).put(ofEpochMilli(1565962999044L), ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")).put(ofEpochMilli(1565963014044L), ImmutableMap.of("instance", "localhost:9090", "__name__", "up", "job", "prometheus")).build();
assertEquals(actual, expected);
}
Aggregations