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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations