From f26622139e99c1b22397f3bcdb25b793f82dcd77 Mon Sep 17 00:00:00 2001 From: discord9 <55937128+discord9@users.noreply.github.com> Date: Wed, 9 Sep 2026 14:14:39 +0800 Subject: [PATCH] docs: explain instant LastRow filter eligibility Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --- src/query/src/optimizer/scan_hint.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/query/src/optimizer/scan_hint.rs b/src/query/src/optimizer/scan_hint.rs index 79f41c8f787..777527ba3f0 100644 --- a/src/query/src/optimizer/scan_hint.rs +++ b/src/query/src/optimizer/scan_hint.rs @@ -132,6 +132,17 @@ impl ScanHintRule { Ok(Transformed::yes(LogicalPlan::TableScan(table_scan))) } + /// Checks whether attached scan predicates permit instant-derived LastRow selection. + /// + /// Selecting the newest row too early can discard an older matching sample if a + /// predicate later rejects that row. Only recognized tag/time predicates are + /// allowed: tags select whole series, and supported time predicates constrain + /// the scan window before row selection. Field or unrecognized predicates are + /// conservatively rejected. Finer-than-millisecond timestamps are also excluded + /// because instant evaluation can conflate distinct samples at that precision. + /// + /// This checks only attached predicates; the rewriter separately rejects residual + /// Filter nodes between InstantManipulate and the scan. fn filters_preserve_last_row( table_scan: &datafusion_expr::logical_plan::TableScan, provider: &DummyTableProvider,