use of io.trino.spi.connector.SortOrder.ASC_NULLS_FIRST in project trino by trinodb.
the class TestPartialTopNWithPresortedInput method createLocalQueryRunner.
@Override
protected LocalQueryRunner createLocalQueryRunner() {
Session session = testSessionBuilder().setCatalog(MOCK_CATALOG).setSchema(TEST_SCHEMA).build();
LocalQueryRunner queryRunner = LocalQueryRunner.builder(session).build();
MockConnectorFactory mockFactory = MockConnectorFactory.builder().withGetTableProperties((connectorSession, handle) -> {
MockConnectorTableHandle tableHandle = (MockConnectorTableHandle) handle;
if (tableHandle.getTableName().equals(tableA)) {
return new ConnectorTableProperties(TupleDomain.all(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(new SortingProperty<>(columnHandleA, ASC_NULLS_FIRST)));
}
throw new IllegalArgumentException();
}).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(tableA)) {
return ImmutableList.of(new ColumnMetadata(columnNameA, VARCHAR), new ColumnMetadata(columnNameB, VARCHAR));
}
throw new IllegalArgumentException();
}).build();
queryRunner.createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
return queryRunner;
}
use of io.trino.spi.connector.SortOrder.ASC_NULLS_FIRST in project trino by trinodb.
the class TestValidateLimitWithPresortedInput method createLocalQueryRunner.
@Override
protected LocalQueryRunner createLocalQueryRunner() {
Session session = testSessionBuilder().setCatalog(MOCK_CATALOG).setSchema(TEST_SCHEMA).build();
LocalQueryRunner queryRunner = LocalQueryRunner.builder(session).build();
MockConnectorFactory mockFactory = MockConnectorFactory.builder().withGetTableProperties((connectorSession, handle) -> {
MockConnectorTableHandle tableHandle = (MockConnectorTableHandle) handle;
if (tableHandle.getTableName().equals(MOCK_TABLE_NAME)) {
return new ConnectorTableProperties(TupleDomain.all(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(new SortingProperty<>(COLUMN_HANDLE_A, ASC_NULLS_FIRST), new SortingProperty<>(COLUMN_HANDLE_C, ASC_NULLS_FIRST)));
}
throw new IllegalArgumentException();
}).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(MOCK_TABLE_NAME)) {
return ImmutableList.of(new ColumnMetadata(COLUMN_NAME_A, VARCHAR), new ColumnMetadata(COLUMN_NAME_B, VARCHAR), new ColumnMetadata(COLUMN_NAME_C, VARCHAR));
}
throw new IllegalArgumentException();
}).build();
queryRunner.createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
return queryRunner;
}
use of io.trino.spi.connector.SortOrder.ASC_NULLS_FIRST 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);
}
Aggregations