Skip to content

Commit

Permalink
fix bug and test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsultana committed Jan 30, 2025
1 parent a0c98b6 commit 66fefee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ QueryContext compileQueryContext(LeafTimeSeriesPlanNode leafNode, TimeSeriesExec
ExpressionContext aggregation = TimeSeriesAggregationFunction.create(context.getLanguage(),
leafNode.getValueExpression(), timeTransform, timeBuckets, leafNode.getAggInfo());
Map<String, String> queryOptions = new HashMap<>(leafNode.getQueryOptions());
queryOptions.put(QueryOptionKey.TIMEOUT_MS, Long.toString(context.getRemainingTimeMs()));
queryOptions.put(QueryOptionKey.TIMEOUT_MS, Long.toString(Math.max(0L, context.getRemainingTimeMs())));
return new QueryContext.Builder()
.setTableName(leafNode.getTableName())
.setFilter(filterContext)
.setGroupByExpressions(groupByExpressions)
.setSelectExpressions(List.of(aggregation))
.setQueryOptions(queryOptions)
.setAliasList(Collections.emptyList())
.setQueryOptions(leafNode.getQueryOptions())
.setLimit(leafNode.getLimit())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.pinot.query.runtime.timeseries;

import com.google.common.collect.ImmutableMap;
import java.time.Duration;
import java.util.Collections;
import java.util.Map;
Expand All @@ -28,6 +29,7 @@
import org.apache.pinot.core.query.request.context.QueryContext;
import org.apache.pinot.spi.utils.CommonConstants.Broker.Request.QueryOptionKey;
import org.apache.pinot.tsdb.spi.AggInfo;
import org.apache.pinot.tsdb.spi.RangeTimeSeriesRequest;
import org.apache.pinot.tsdb.spi.TimeBuckets;
import org.apache.pinot.tsdb.spi.plan.LeafTimeSeriesPlanNode;
import org.apache.pinot.tsdb.spi.series.SimpleTimeSeriesBuilderFactory;
Expand Down Expand Up @@ -74,16 +76,18 @@ public void testCompileQueryContext() {
assertEquals(queryContext.getFilter().toString(),
"(cityName = 'Chicago' AND orderTime > '990' AND orderTime <= '1990')");
assertTrue(isNumber(queryContext.getQueryOptions().get(QueryOptionKey.TIMEOUT_MS)));
assertEquals(queryContext.getLimit(), SERIES_LIMIT);
}
// Case-2: With offset, complex group-by expression, complex value, and non-empty filter
// Case-2: With offset, complex group-by expression, complex value, non-empty filter, 0 limit, query options.
{
Map<String, String> queryOptions = ImmutableMap.of("numGroupsLimit", "1000");
TimeSeriesExecutionContext context =
new TimeSeriesExecutionContext(LANGUAGE, TimeBuckets.ofSeconds(1000L, Duration.ofSeconds(10), 100),
DUMMY_DEADLINE_MS, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap());
LeafTimeSeriesPlanNode leafNode =
new LeafTimeSeriesPlanNode(planId, Collections.emptyList(), tableName, timeColumn, TimeUnit.SECONDS, 10L,
filterExpr, "orderCount*2", aggInfo, Collections.singletonList("concat(cityName, stateName, '-')"),
SERIES_LIMIT, QUERY_OPTIONS);
0 /* limit */, queryOptions);
QueryContext queryContext = serverPlanVisitor.compileQueryContext(leafNode, context);
assertNotNull(queryContext);
assertNotNull(queryContext.getGroupByExpressions());
Expand All @@ -92,6 +96,8 @@ public void testCompileQueryContext() {
assertEquals(queryContext.getFilter().toString(),
"(cityName = 'Chicago' AND orderTime > '980' AND orderTime <= '1980')");
assertTrue(isNumber(queryContext.getQueryOptions().get(QueryOptionKey.TIMEOUT_MS)));
assertEquals(queryContext.getLimit(), RangeTimeSeriesRequest.DEFAULT_SERIES_LIMIT);
assertEquals(queryContext.getQueryOptions().get("numGroupsLimit"), "1000");
}
}

Expand Down

0 comments on commit 66fefee

Please sign in to comment.