Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private DynamicTablePqlExtractor()
public static String extractPql(DynamicTable table, TupleDomain<ColumnHandle> tupleDomain)
{
StringBuilder builder = new StringBuilder();
builder.append("select ");
builder.append("SELECT ");
if (!table.getProjections().isEmpty()) {
builder.append(table.getProjections().stream()
.map(DynamicTablePqlExtractor::formatExpression)
Expand All @@ -49,34 +49,34 @@ public static String extractPql(DynamicTable table, TupleDomain<ColumnHandle> tu
.map(DynamicTablePqlExtractor::formatExpression)
.collect(joining(", ")));
}
builder.append(" from ");
builder.append(" FROM ");
builder.append(table.getTableName());
builder.append(table.getSuffix().orElse(""));

Optional<String> filter = getFilter(table.getFilter(), tupleDomain, false);
if (filter.isPresent()) {
builder.append(" where ")
builder.append(" WHERE ")
.append(filter.get());
}
if (!table.getGroupingColumns().isEmpty()) {
builder.append(" group by ");
builder.append(" GROUP BY ");
builder.append(table.getGroupingColumns().stream()
.map(PinotColumnHandle::getExpression)
.collect(joining(", ")));
}
Optional<String> havingClause = getFilter(table.getHavingExpression(), tupleDomain, true);
if (havingClause.isPresent()) {
builder.append(" having ")
builder.append(" HAVING ")
.append(havingClause.get());
}
if (!table.getOrderBy().isEmpty()) {
builder.append(" order by ")
builder.append(" ORDER BY ")
.append(table.getOrderBy().stream()
.map(DynamicTablePqlExtractor::convertOrderByExpressionToPql)
.collect(joining(", ")));
}
if (table.getLimit().isPresent()) {
builder.append(" limit ");
builder.append(" LIMIT ");
if (table.getOffset().isPresent()) {
builder.append(table.getOffset().getAsLong())
.append(", ");
Expand Down Expand Up @@ -108,7 +108,7 @@ private static String convertOrderByExpressionToPql(OrderByExpression orderByExp
StringBuilder builder = new StringBuilder()
.append(orderByExpression.getExpression());
if (!orderByExpression.isAsc()) {
builder.append(" desc");
builder.append(" DESC");
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,12 +1298,11 @@ public void testBrokerQueryWithTooManyRowsForSegmentQuery()

@Test
public void testMaxLimitForPassthroughQueries()
throws InterruptedException
Comment thread
hashhar marked this conversation as resolved.
{
assertQueryFails("SELECT string_col, updated_at_seconds" +
" FROM \"SELECT updated_at_seconds, string_col FROM " + TOO_MANY_BROKER_ROWS_TABLE +
" LIMIT " + (MAX_ROWS_PER_SPLIT_FOR_BROKER_QUERIES + 1) + "\"",
"Broker query returned '13' rows, maximum allowed is '12' rows. with query \"select \"updated_at_seconds\", \"string_col\" from too_many_broker_rows limit 13\"");
"Broker query returned '13' rows, maximum allowed is '12' rows. with query \"SELECT \"updated_at_seconds\", \"string_col\" FROM too_many_broker_rows LIMIT 13\"");

// Pinot issue preventing Integer.MAX_VALUE from being a limit: https://github.com/apache/incubator-pinot/issues/7110
// This is now resolved in pinot 0.8.0
Expand All @@ -1312,7 +1311,7 @@ public void testMaxLimitForPassthroughQueries()
// Pinot broker requests do not handle limits greater than Integer.MAX_VALUE
// Note that -2147483648 is due to an integer overflow in Pinot: https://github.com/apache/pinot/issues/7242
assertQueryFails("SELECT * FROM \"SELECT string_col, long_col FROM " + ALL_TYPES_TABLE + " LIMIT " + ((long) Integer.MAX_VALUE + 1) + "\"",
"(?s)Query select \"string_col\", \"long_col\" from alltypes limit -2147483648 encountered exception .* with query \"select \"string_col\", \"long_col\" from alltypes limit -2147483648\"");
"(?s)Query SELECT \"string_col\", \"long_col\" FROM alltypes LIMIT -2147483648 encountered exception .* with query \"SELECT \"string_col\", \"long_col\" FROM alltypes LIMIT -2147483648\"");

List<String> tooManyBrokerRowsTableValues = new ArrayList<>();
for (int i = 0; i < MAX_ROWS_PER_SPLIT_FOR_BROKER_QUERIES; i++) {
Expand Down
Loading