Search in sources :

Example 1 with OrderByExpression

use of io.trino.plugin.pinot.query.OrderByExpression in project trino by trinodb.

the class TestDynamicTable method testSelectNoFilter.

@Test
public void testSelectNoFilter() {
    String tableName = realtimeOnlyTable.getTableName();
    List<String> columnNames = getColumnNames(tableName);
    List<String> orderByColumns = columnNames.subList(0, 5);
    List<OrderByExpression> orderByExpressions = orderByColumns.stream().limit(4).map(columnName -> new OrderByExpression(quoteIdentifier(columnName), true)).collect(toList());
    long limit = 230;
    String query = format("select %s from %s order by %s limit %s", join(", ", columnNames), tableName, orderByColumns.stream().collect(joining(", ")) + " desc", limit);
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    assertEquals(dynamicTable.getProjections().stream().map(PinotColumnHandle::getColumnName).collect(toImmutableList()), columnNames);
    orderByExpressions.add(new OrderByExpression(quoteIdentifier(orderByColumns.get(4)), false));
    assertEquals(dynamicTable.getOrderBy(), orderByExpressions);
    assertEquals(dynamicTable.getLimit().getAsLong(), limit);
}
Also used : DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) REALTIME_SUFFIX(io.trino.plugin.pinot.query.DynamicTableBuilder.REALTIME_SUFFIX) ImmutableList(com.google.common.collect.ImmutableList) String.join(java.lang.String.join) Slices(io.airlift.slice.Slices) ColumnHandle(io.trino.spi.connector.ColumnHandle) OrderByExpression(io.trino.plugin.pinot.query.OrderByExpression) ENGLISH(java.util.Locale.ENGLISH) ImmutableMap(com.google.common.collect.ImmutableMap) Range(io.trino.spi.predicate.Range) Domain(io.trino.spi.predicate.Domain) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) OFFLINE_SUFFIX(io.trino.plugin.pinot.query.DynamicTableBuilder.OFFLINE_SUFFIX) DynamicTablePqlExtractor.extractPql(io.trino.plugin.pinot.query.DynamicTablePqlExtractor.extractPql) TupleDomain(io.trino.spi.predicate.TupleDomain) SchemaTableName(io.trino.spi.connector.SchemaTableName) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) ValueSet(io.trino.spi.predicate.ValueSet) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DynamicTableBuilder.buildFromPql(io.trino.plugin.pinot.query.DynamicTableBuilder.buildFromPql) OrderByExpression(io.trino.plugin.pinot.query.OrderByExpression) SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Slices (io.airlift.slice.Slices)1 DynamicTable (io.trino.plugin.pinot.query.DynamicTable)1 OFFLINE_SUFFIX (io.trino.plugin.pinot.query.DynamicTableBuilder.OFFLINE_SUFFIX)1 REALTIME_SUFFIX (io.trino.plugin.pinot.query.DynamicTableBuilder.REALTIME_SUFFIX)1 DynamicTableBuilder.buildFromPql (io.trino.plugin.pinot.query.DynamicTableBuilder.buildFromPql)1 DynamicTablePqlExtractor.extractPql (io.trino.plugin.pinot.query.DynamicTablePqlExtractor.extractPql)1 OrderByExpression (io.trino.plugin.pinot.query.OrderByExpression)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1 Domain (io.trino.spi.predicate.Domain)1 Range (io.trino.spi.predicate.Range)1 TupleDomain (io.trino.spi.predicate.TupleDomain)1 ValueSet (io.trino.spi.predicate.ValueSet)1 VARCHAR (io.trino.spi.type.VarcharType.VARCHAR)1 String.format (java.lang.String.format)1 String.join (java.lang.String.join)1 List (java.util.List)1