use of io.trino.plugin.pinot.query.DynamicTable in project trino by trinodb.
the class PinotMetadata method getDynamicTableColumnHandles.
private Map<String, ColumnHandle> getDynamicTableColumnHandles(PinotTableHandle pinotTableHandle) {
checkState(pinotTableHandle.getQuery().isPresent(), "dynamic table not present");
DynamicTable dynamicTable = pinotTableHandle.getQuery().get();
ImmutableMap.Builder<String, ColumnHandle> columnHandlesBuilder = ImmutableMap.builder();
for (PinotColumnHandle pinotColumnHandle : dynamicTable.getProjections()) {
columnHandlesBuilder.put(pinotColumnHandle.getColumnName().toLowerCase(ENGLISH), pinotColumnHandle);
}
dynamicTable.getAggregateColumns().forEach(columnHandle -> columnHandlesBuilder.put(columnHandle.getColumnName().toLowerCase(ENGLISH), columnHandle));
return columnHandlesBuilder.buildOrThrow();
}
use of io.trino.plugin.pinot.query.DynamicTable in project trino by trinodb.
the class TestDynamicTable method testDoubleWithScientificNotation.
@Test
public void testDoubleWithScientificNotation() {
// Pinot recognizes double literals with scientific notation as of version 0.8.0
String tableName = "primitive_types_table";
String query = "SELECT string_col FROM " + tableName + " WHERE double_col = 3.5E5";
String expected = "select \"string_col\" from primitive_types_table where (\"double_col\") = '350000.0' limit 10";
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 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);
}
use of io.trino.plugin.pinot.query.DynamicTable in project trino by trinodb.
the class TestDynamicTable method testLimitAndOffset.
@Test
public void testLimitAndOffset() {
String tableName = hybridTable.getTableName();
String tableNameWithSuffix = tableName + REALTIME_SUFFIX;
String query = format("select * from %s limit 70, 40", tableNameWithSuffix);
DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
String expectedPql = format("select %s from %s limit 70, 40", getColumnNames(tableName).stream().map(TestDynamicTable::quoteIdentifier).collect(joining(", ")), 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 testQuotesInAlias.
@Test
public void testQuotesInAlias() {
String tableName = "quotes_in_column_names";
String tableNameWithSuffix = tableName + REALTIME_SUFFIX;
String query = format("select non_quoted AS \"non\"\"quoted\" from %s limit 50", tableNameWithSuffix);
DynamicTable dynamicTable = buildFromPql(pinotMetadata, new SchemaTableName("default", query), mockClusterInfoFetcher);
String expectedPql = format("select \"non_quoted\" AS \"non\"\"quoted\" from %s limit 50", tableNameWithSuffix);
assertEquals(extractPql(dynamicTable, TupleDomain.all(), ImmutableList.of()), expectedPql);
assertEquals(dynamicTable.getTableName(), tableName);
}
Aggregations