-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[timeseries] Add Support for limit and numGroupsLimit #14945
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,10 @@ | |
import com.google.common.base.Preconditions; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
@@ -78,7 +80,8 @@ public BaseTimeSeriesPlanNode planQuery(RangeTimeSeriesRequest request) { | |
switch (command) { | ||
case "fetch": | ||
List<String> tokens = commands.get(commandId).subList(1, commands.get(commandId).size()); | ||
currentNode = handleFetchNode(planIdGenerator.generateId(), tokens, children, aggInfo, groupByColumns); | ||
currentNode = handleFetchNode(planIdGenerator.generateId(), tokens, children, aggInfo, groupByColumns, | ||
request); | ||
break; | ||
case "sum": | ||
case "min": | ||
|
@@ -118,7 +121,8 @@ public BaseTimeSeriesPlanNode planQuery(RangeTimeSeriesRequest request) { | |
} | ||
|
||
public BaseTimeSeriesPlanNode handleFetchNode(String planId, List<String> tokens, | ||
List<BaseTimeSeriesPlanNode> children, AggInfo aggInfo, List<String> groupByColumns) { | ||
List<BaseTimeSeriesPlanNode> children, AggInfo aggInfo, List<String> groupByColumns, | ||
RangeTimeSeriesRequest request) { | ||
Preconditions.checkState(tokens.size() % 2 == 0, "Mismatched args"); | ||
String tableName = null; | ||
String timeColumn = null; | ||
|
@@ -152,7 +156,11 @@ public BaseTimeSeriesPlanNode handleFetchNode(String planId, List<String> tokens | |
Preconditions.checkNotNull(timeColumn, "Time column not set. Set via time_col="); | ||
Preconditions.checkNotNull(timeUnit, "Time unit not set. Set via time_unit="); | ||
Preconditions.checkNotNull(valueExpr, "Value expression not set. Set via value="); | ||
Map<String, String> queryOptions = new HashMap<>(); | ||
if (request.getNumGroupsLimit() > 0) { | ||
queryOptions.put("numGroupsLimit", Integer.toString(request.getNumGroupsLimit())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can put "numGroupsLimit" in a constant class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Can address in a follow-up. This module is mostly a throw away.. we'll open source the full M3 Plugin after time series support is marked as GA. |
||
} | ||
return new LeafTimeSeriesPlanNode(planId, children, tableName, timeColumn, timeUnit, 0L, filter, valueExpr, aggInfo, | ||
groupByColumns); | ||
groupByColumns, request.getLimit(), queryOptions); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the change for promQL to pass request param in the leaf stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you just need to set the
limit
andnumGroupsLimit
in theLeafTimeSeriesPlanNode
of the returned plan