Skip to content
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

fix(query) Fixes for split partition queries #1701

Merged
merged 7 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -647,82 +647,82 @@ object PlannerUtil extends StrictLogging {
//scalastyle:off method.length
def rewritePlanWithRemoteRawExport(lp: LogicalPlan,
rangeSelector: IntervalSelector,
additionalLookback: Long = 0): LogicalPlan =
additionalLookbackMs: Long = 0): LogicalPlan =
lp match {
case lp: ApplyInstantFunction =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan],
functionArgs = lp.functionArgs.map(
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookback).asInstanceOf[FunctionArgsPlan]))
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookbackMs).asInstanceOf[FunctionArgsPlan]))
case lp: ApplyInstantFunctionRaw =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[RawSeries],
functionArgs = lp.functionArgs.map(
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookback).asInstanceOf[FunctionArgsPlan]))
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookbackMs).asInstanceOf[FunctionArgsPlan]))
case lp: Aggregate =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: BinaryJoin =>
lp.copy(lhs = rewritePlanWithRemoteRawExport(lp.lhs, rangeSelector, additionalLookback)
lp.copy(lhs = rewritePlanWithRemoteRawExport(lp.lhs, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan],
rhs = rewritePlanWithRemoteRawExport(lp.rhs, rangeSelector, additionalLookback)
rhs = rewritePlanWithRemoteRawExport(lp.rhs, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ScalarVectorBinaryOperation =>
lp.copy(scalarArg = rewritePlanWithRemoteRawExport(lp.scalarArg, rangeSelector, additionalLookback)
lp.copy(scalarArg = rewritePlanWithRemoteRawExport(lp.scalarArg, rangeSelector, additionalLookbackMs)
.asInstanceOf[ScalarPlan],
vector = rewritePlanWithRemoteRawExport(lp.vector, rangeSelector, additionalLookback)
vector = rewritePlanWithRemoteRawExport(lp.vector, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ApplyMiscellaneousFunction =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ApplySortFunction =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ScalarVaryingDoublePlan =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan],
functionArgs = lp.functionArgs.map(
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookback).asInstanceOf[FunctionArgsPlan]))
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookbackMs).asInstanceOf[FunctionArgsPlan]))
case lp: ScalarTimeBasedPlan => lp
case lp: VectorPlan =>
lp.copy(scalars = rewritePlanWithRemoteRawExport(lp.scalars, rangeSelector, additionalLookback)
lp.copy(scalars = rewritePlanWithRemoteRawExport(lp.scalars, rangeSelector, additionalLookbackMs)
.asInstanceOf[ScalarPlan])
case lp: ScalarFixedDoublePlan => lp
case lp: ApplyAbsentFunction =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ApplyLimitFunction =>
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookback)
lp.copy(vectors = rewritePlanWithRemoteRawExport(lp.vectors, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan])
case lp: ScalarBinaryOperation => lp
case lp: SubqueryWithWindowing =>
lp.copy(innerPeriodicSeries =
rewritePlanWithRemoteRawExport(lp.innerPeriodicSeries, rangeSelector, additionalLookback)
rewritePlanWithRemoteRawExport(lp.innerPeriodicSeries, rangeSelector, additionalLookbackMs)
.asInstanceOf[PeriodicSeriesPlan],
functionArgs = lp.functionArgs.map(
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookback).asInstanceOf[FunctionArgsPlan]))
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookbackMs).asInstanceOf[FunctionArgsPlan]))
case lp: TopLevelSubquery =>
lp.copy(innerPeriodicSeries =
rewritePlanWithRemoteRawExport(lp.innerPeriodicSeries, rangeSelector, additionalLookback = additionalLookback)
.asInstanceOf[PeriodicSeriesPlan])
rewritePlanWithRemoteRawExport(lp.innerPeriodicSeries, rangeSelector,
additionalLookbackMs = additionalLookbackMs).asInstanceOf[PeriodicSeriesPlan])
case lp: RawSeries =>
// IMPORTANT: When we export raw data over remote data call, offset does not mean anything, instead
// do a raw lookback of original lookback + offset and set offset to 0
val newLookback = lp.lookbackMs.getOrElse(0L) + lp.offsetMs.getOrElse(0L) + additionalLookback
val newLookback = lp.lookbackMs.getOrElse(0L) + lp.offsetMs.getOrElse(0L) + additionalLookbackMs
lp.copy(supportsRemoteDataCall = true, rangeSelector = rangeSelector,
lookbackMs = if (newLookback == 0) None else Some(newLookback), offsetMs = None)
case lp: RawChunkMeta => lp
case lp: PeriodicSeries =>
lp.copy(rawSeries = rewritePlanWithRemoteRawExport(lp.rawSeries, rangeSelector, additionalLookback)
lp.copy(rawSeries = rewritePlanWithRemoteRawExport(lp.rawSeries, rangeSelector, additionalLookbackMs)
.asInstanceOf[RawSeriesLikePlan], startMs = rangeSelector.from, endMs = rangeSelector.to)
case lp: PeriodicSeriesWithWindowing =>
val rs = rangeSelector.asInstanceOf[IntervalSelector]
lp.copy(
startMs = rs.from,
endMs = rs.to,
functionArgs = lp.functionArgs.map(
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookback).asInstanceOf[FunctionArgsPlan]),
series = rewritePlanWithRemoteRawExport(lp.series, rangeSelector, additionalLookback)
rewritePlanWithRemoteRawExport(_, rangeSelector, additionalLookbackMs).asInstanceOf[FunctionArgsPlan]),
series = rewritePlanWithRemoteRawExport(lp.series, rangeSelector, additionalLookbackMs)
.asInstanceOf[RawSeriesLikePlan])
case lp: MetadataQueryPlan => lp
case lp: TsCardinalities => lp
Expand Down
Loading
Loading