Skip to content

Commit

Permalink
disable extending lookback in favor of erroring the query
Browse files Browse the repository at this point in the history
  • Loading branch information
vishramachandran committed Nov 14, 2024
1 parent 3f5a13c commit 71b0113
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions query/src/main/scala/filodb/query/exec/PeriodicSamplesMapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,22 @@ final case class PeriodicSamplesMapper(startMs: Long,
* will lead to incorrect results.
*/
private[exec] def extendLookback(rv: RangeVector, window: Long): Long = {
if (functionId.contains(InternalRangeFunction.Rate)) { // only extend for rate function
val pubInt = rv match {
case rvrd: RawDataRangeVector =>
if (rvrd.partition.schema.hasCumulativeTemporalityColumn) // only extend for cumulative schemas
rvrd.partition.publishInterval.getOrElse(0L)
else 0L
case _ => 0L
}
if (window < 2 * pubInt) 2 * pubInt // 2 * publish interval since we want 2 samples for rate
else window
} else {
window
}
// TODO consider returning an error when known publish interval is less than 2*windowLength for increase function
// instead of silently returning empty rate (and implicitly zero for sum functions) for the window
window
// following code is commented, but uncomment when we want to extend window for rate function

// if (functionId.contains(InternalRangeFunction.Rate)) { // only extend for rate function
// val pubInt = rv match {
// case rvrd: RawDataRangeVector =>
// if (rvrd.partition.schema.hasCumulativeTemporalityColumn) // only extend for cumulative schemas
// rvrd.partition.publishInterval.getOrElse(0L)
// else 0L
// case _ => 0L
// }
// if (window < 2 * pubInt) 2 * pubInt // 2 * publish interval since we want 2 samples for rate
// else window
// } else {
// window
// }
}

// Transform source double or long to double schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ class DownsamplerMainSpec extends AnyFunSpec with Matchers with BeforeAndAfterAl
InProcessPlanDispatcher(QueryConfig.unitTestingQueryConfig), batchDownsampler.rawDatasetRef, 0, queryFilters,
AllChunkScan, "_metric_")
// window should be auto-extended to 10m
exec.addRangeVectorTransformer(PeriodicSamplesMapper(74373042000L, 10, 74373042000L,Some(310000),
exec.addRangeVectorTransformer(PeriodicSamplesMapper(74373042000L, 10, 74373042000L,Some(610000),
Some(InternalRangeFunction.Rate), qc))

val querySession = QuerySession(QueryContext(), queryConfig)
Expand Down

0 comments on commit 71b0113

Please sign in to comment.