Search in sources :

Example 21 with DynamicTable

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

the class TestPinotSplitManager method testSplitsBroker.

@Test
public void testSplitsBroker() {
    SchemaTableName schemaTableName = new SchemaTableName("default", format("SELECT %s, %s FROM %s LIMIT %d", "AirlineID", "OriginStateName", "airlineStats", 100));
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, schemaTableName, mockClusterInfoFetcher);
    PinotTableHandle pinotTableHandle = new PinotTableHandle("default", dynamicTable.getTableName(), TupleDomain.all(), OptionalLong.empty(), Optional.of(dynamicTable));
    List<PinotSplit> splits = getSplitsHelper(pinotTableHandle, 1, false);
    assertSplits(splits, 1, BROKER);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Example 22 with DynamicTable

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

the class TestDynamicTable method testOfflineDynamicTable.

@Test
public void testOfflineDynamicTable() {
    String tableName = hybridTable.getTableName();
    String tableNameWithSuffix = tableName + OFFLINE_SUFFIX;
    String query = format("select * from %s limit 70", tableNameWithSuffix);
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    String expectedPql = format("select %s from %s limit 70", getColumnNames(tableName).stream().map(TestDynamicTable::quoteIdentifier).collect(joining(", ")), tableNameWithSuffix);
    assertEquals(extractPql(dynamicTable, TupleDomain.all(), ImmutableList.of()), expectedPql);
    assertEquals(dynamicTable.getTableName(), tableName);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Example 23 with DynamicTable

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

the class TestDynamicTable method testGroupBy.

@Test
public void testGroupBy() {
    String tableName = realtimeOnlyTable.getTableName();
    long limit = 25;
    String query = format("SELECT Origin, AirlineID, max(CarrierDelay), avg(CarrierDelay) FROM %s GROUP BY Origin, AirlineID LIMIT %s", tableName, limit);
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    assertEquals(dynamicTable.getGroupingColumns().stream().map(PinotColumnHandle::getColumnName).collect(toImmutableList()), ImmutableList.builder().add("Origin").add("AirlineID").build());
    assertEquals(dynamicTable.getLimit().getAsLong(), limit);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Example 24 with DynamicTable

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

the class TestDynamicTable method testFilterWithCast.

@Test
public void testFilterWithCast() {
    String tableName = "primitive_types_table";
    String query = "SELECT string_col, long_col" + " FROM " + tableName + " WHERE string_col = CAST(123 AS STRING) AND long_col = CAST('123' AS LONG) LIMIT 60";
    String expected = "select \"string_col\", \"long_col\" from primitive_types_table " + "where AND((\"string_col\") = (CAST('123' AS string)), (\"long_col\") = (CAST('123' AS long))) limit 60";
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    assertEquals(extractPql(dynamicTable, TupleDomain.all(), ImmutableList.of()), expected);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Example 25 with DynamicTable

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

the class TestDynamicTable method testFilterWithUdf.

@Test
public void testFilterWithUdf() {
    String tableName = realtimeOnlyTable.getTableName();
    String query = format("select FlightNum from %s where DivLongestGTimes = FLOOR(EXP(2 * LN(3))) AND 5 < EXP(CarrierDelay) limit 60", tableName.toLowerCase(ENGLISH));
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    String expectedPql = "select \"FlightNum\" from realtimeonly where AND((\"DivLongestGTimes\") = '9.0', (exp(\"CarrierDelay\")) > '5') limit 60";
    assertEquals(extractPql(dynamicTable, TupleDomain.all(), ImmutableList.of()), expectedPql);
}
Also used : SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Aggregations

DynamicTable (io.trino.plugin.pinot.query.DynamicTable)28 SchemaTableName (io.trino.spi.connector.SchemaTableName)25 Test (org.testng.annotations.Test)24 ColumnHandle (io.trino.spi.connector.ColumnHandle)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)1 Slices (io.airlift.slice.Slices)1 PinotColumnHandle.fromColumnMetadata (io.trino.plugin.pinot.PinotColumnHandle.fromColumnMetadata)1 AggregateExpression (io.trino.plugin.pinot.query.AggregateExpression)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 PinotQueryInfo (io.trino.plugin.pinot.query.PinotQueryInfo)1 AggregateFunction (io.trino.spi.connector.AggregateFunction)1 Assignment (io.trino.spi.connector.Assignment)1 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)1