Search in sources :

Example 11 with DynamicTable

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

the class TestDynamicTable method testFilterWithPushdownConstraint.

@Test
public void testFilterWithPushdownConstraint() {
    String tableName = realtimeOnlyTable.getTableName();
    String query = format("select FlightNum from %s limit 60", tableName.toLowerCase(ENGLISH));
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    PinotColumnHandle columnHandle = new PinotColumnHandle("OriginCityName", VARCHAR);
    TupleDomain<ColumnHandle> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.<ColumnHandle, Domain>builder().put(columnHandle, Domain.create(ValueSet.ofRanges(Range.equal(VARCHAR, Slices.utf8Slice("Catfish Paradise"))), false)).buildOrThrow());
    String expectedPql = "select \"FlightNum\" from realtimeonly where (\"OriginCityName\" = 'Catfish Paradise') limit 60";
    assertEquals(extractPql(dynamicTable, tupleDomain, ImmutableList.<PinotColumnHandle>builder().add(columnHandle).build()), expectedPql);
}
Also used : ColumnHandle(io.trino.spi.connector.ColumnHandle) SchemaTableName(io.trino.spi.connector.SchemaTableName) DynamicTable(io.trino.plugin.pinot.query.DynamicTable) Test(org.testng.annotations.Test)

Example 12 with DynamicTable

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

the class TestDynamicTable method testTextMatch.

@Test
public void testTextMatch() {
    String tableName = hybridTable.getTableName();
    String tableNameWithSuffix = tableName + REALTIME_SUFFIX;
    String query = format("select origincityname from %s where text_match(origincityname, 'new AND york') limit 70", tableNameWithSuffix);
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    String expectedPql = format("select \"OriginCityName\" from %s where text_match(\"OriginCityName\", 'new and york') limit 70", 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 13 with DynamicTable

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

the class TestDynamicTable method testFilterWithCaseStatements.

@Test
public void testFilterWithCaseStatements() {
    String tableName = realtimeOnlyTable.getTableName();
    String query = format("select FlightNum, AirlineID from %s " + "where case when cancellationcode = 'strike' then 3 else 4 end != 5 " + "AND case origincityname when 'nyc' then 'pizza' when 'la' then 'burrito' when 'boston' then 'clam chowder' " + "else 'burger' end != 'salad'", tableName.toLowerCase(ENGLISH));
    String expected = format("select \"FlightNum\", \"AirlineID\" from %s where AND((CASE WHEN equals(\"CancellationCode\", 'strike') " + "THEN '3' ELSE '4' END) != '5', (CASE WHEN equals(\"OriginCityName\", 'nyc') " + "THEN 'pizza' WHEN equals(\"OriginCityName\", 'la') THEN 'burrito' WHEN equals(\"OriginCityName\", 'boston') " + "THEN 'clam chowder' ELSE 'burger' END) != 'salad') limit 10", tableName.toLowerCase(ENGLISH));
    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 14 with DynamicTable

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

the class TestDynamicTable method testSelectStarDynamicTable.

@Test
public void testSelectStarDynamicTable() {
    String tableName = realtimeOnlyTable.getTableName();
    String query = format("select * from %s limit 70", tableName.toLowerCase(ENGLISH));
    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(", ")), tableName.toLowerCase(ENGLISH));
    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)

Example 15 with DynamicTable

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

the class TestDynamicTable method testRegexpLike.

@Test
public void testRegexpLike() {
    String tableName = hybridTable.getTableName();
    String tableNameWithSuffix = tableName + REALTIME_SUFFIX;
    String query = format("select origincityname from %s where regexp_like(origincityname, '.*york.*') limit 70", tableNameWithSuffix);
    DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
    String expectedPql = format("select \"OriginCityName\" from %s where regexp_like(\"OriginCityName\", '.*york.*') limit 70", 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)

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