-
Notifications
You must be signed in to change notification settings - Fork 228
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
feat(query) Implement @modifier. #1678
Conversation
credits to @alextheimer PR. |
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.
Thanks for the PR @yu-shipit -- just a couple of questions. Also, please add some tests that show the ExecPlans
for simple queries and typical @
use-cases.
coordinator/src/main/scala/filodb.coordinator/queryplanner/DefaultPlanner.scala
Outdated
Show resolved
Hide resolved
coordinator/src/main/scala/filodb.coordinator/queryplanner/DefaultPlanner.scala
Outdated
Show resolved
Hide resolved
coordinator/src/main/scala/filodb.coordinator/queryplanner/DefaultPlanner.scala
Show resolved
Hide resolved
d9786b5
to
1dfc95a
Compare
1. Override range param based on @modifier timestamp for PeriodicSamplesMapper. 2. Add RepeatTransformer and RepeatValueVector to populate data for all timestamps. 3. Add GRPC functions for RepeatValueVector.
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
atMs.forall(at => (at >= earliestRawTimeWithOffset && startMs >= earliestRawTimeWithOffset) | ||
|| (at < earliestRawTimeWithOffset && endMs < earliestRawTimeWithOffset)) |
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.
startMs
and endMs
don't necessarily correlate with the range of data a query will read. Consider the instant query:
rate(foo{...}[14d]) // startMs=endMs
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
@@ -1837,47 +1837,67 @@ class PlannerHierarchySpec extends AnyFunSpec with Matchers with PlanValidationS | |||
validatePlan(execPlan, expectedPlan) | |||
} | |||
|
|||
it("Modifier should have PeriodicSamplesMapper wrapped by RepeatTransformer") { | |||
it("Modifier should have PeriodicSamplesMapper wrapped by RepeatTransformer and all data in raw cluster") { |
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.
Could you add a test case for each possible scenario?
- query routed entirely to raw (already exists)
- query routed entirely to DS (already exists)
- query routed to both (should reject)
- query start/end are in raw, but lookback extends into DS (should reject)
- query start/end are in raw, but offset pushes it entirely into DS (ok)
- [any other important scenarios I'm forgetting]
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.
Thanks for all these tests 🙏
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
@@ -1837,47 +1837,67 @@ class PlannerHierarchySpec extends AnyFunSpec with Matchers with PlanValidationS | |||
validatePlan(execPlan, expectedPlan) | |||
} | |||
|
|||
it("Modifier should have PeriodicSamplesMapper wrapped by RepeatTransformer") { | |||
it("Modifier should have PeriodicSamplesMapper wrapped by RepeatTransformer and all data in raw cluster") { |
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.
Thanks for all these tests 🙏
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
This reverts commit 68298f2.
friendly messages.
coordinator/src/main/scala/filodb.coordinator/queryplanner/LongTimeRangePlanner.scala
Outdated
Show resolved
Hide resolved
8510f58
to
48670b2
Compare
val realScanStartMs = sqww.atMs.getOrElse(sqww.startMs) | ||
val realScanEndMs = sqww.atMs.getOrElse(sqww.endMs) | ||
val realScanStep = sqww.atMs.map(_ => 0L).getOrElse(sqww.stepMs) |
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.
Should these instead be something like this?:
val realScanStartMs = sqww.atMs.map(at => at - (sqww.endMs - sqww.startMs)).getOrElse(sqww.startMs)
val realScanEndMs = sqww.atMs.getOrElse(sqww.endMs)
// realScanStep remains unchanged
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.
Somehow an instant query requires 0 to be step .
atModifierTimestampsWithOffset.isEmpty | ||
} | ||
require(isAtModifierValid, s"@modifier $atModifierTimestampsWithOffset is not supported. Because it queries" + | ||
s"both down sampled and raw data. Please adjust the start and end time if you want to use @modifier.") |
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.
Should this instead say "please adjust query parameters"? (An instant query might lookback too far.)
case w: PeriodicSeriesWithWindowing => (w.startMs, w.stepMs, w.window, w.offsetMs.getOrElse(0L), | ||
w.atMs.getOrElse(0L), w.endMs) |
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.
Double-checking: no need to update these start/step/end values like we do for subqueries?
Some(LogicalPlanUtils.copyLogicalPlanWithUpdatedTimeRange(logicalPlan, TimeRange(newStartMs, boundParams._5))) | ||
Some(LogicalPlanUtils.copyLogicalPlanWithUpdatedTimeRange(logicalPlan, TimeRange(newStartMs, boundParams._6))) |
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.
Outside the scope of this PR, but it's probably safe to say it's time for those boundParams
to be given their own case class
😆
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. we have one more argument, which change the number to 6.
val realScanStartMs = lp.atMs.getOrElse(logicalPlanWithoutBucket.startMs) | ||
val realScanEndMs = lp.atMs.getOrElse(logicalPlanWithoutBucket.endMs) | ||
val realScanStepMs: Long = lp.atMs.map(_ => 0L).getOrElse(lp.stepMs) |
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.
Same as some other comments: should we keep the original duration between start/end?
override def rows(): RangeVectorCursor = { | ||
import NoCloseCursor._ | ||
// If rowReader is empty, iterate nothing. | ||
val it = Iterator.from(0, rowReader.map(_ => stepMs.toInt).getOrElse(0)) |
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.
Should this be getOrElse(1)
to prevent an infinite loop?
Pull Request checklist
Current behavior : (link exiting issues here : https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests)
New behavior :
Will support
@modifier
.The problem is described in this doc.
The prometheus PR.
Filodb will support advance usage such as
Other information: