Fix last_by returning null row after deleting all table data (#16985)#17411
Open
PDGGK wants to merge 1 commit intoapache:masterfrom
Open
Fix last_by returning null row after deleting all table data (#16985)#17411PDGGK wants to merge 1 commit intoapache:masterfrom
PDGGK wants to merge 1 commit intoapache:masterfrom
Conversation
…16985) After deleting all data of a device in table model, queries like `select last_by(s0, time)` could still return one row with null values instead of returning no rows. Three related issues were fixed: 1. LastQueryAggTableScanOperator: skip emitting a result row when all aggregators are LastByAccumulator and none has an initialized result. Applied to both the normal aggregation path and the cache-hit path. 2. FileLoaderUtils: read time-column modifications using AlignedFullPath.VECTOR_PLACEHOLDER instead of the concrete measurement ID, matching aligned deletion semantics used in other paths. 3. ModificationUtils: set modified=true when an aligned value chunk is fully deleted, preventing statistics-based shortcuts from using stale metadata. Signed-off-by: Zihan Dai <1436286758@qq.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #16985
In table model, after deleting all data of a device,
last_byqueries still returned one row with null values instead of returning no rows:Root Cause
Three related issues:
LastQueryAggTableScanOperatorcould still emit a result row for non-groupedlast_byscans even when everyLastByAccumulatorhad no initialized result, causingevaluateFinal()to produce a null row.FileLoaderUtilsread aligned time-column modifications using the concrete measurement ID instead ofAlignedFullPath.VECTOR_PLACEHOLDER, inconsistent with aligned deletion semantics used in other paths.ModificationUtilsdid not setmodified = truewhen an aligned value chunk was fully deleted, allowing statistics-based shortcuts to use stale metadata.Changes
LastQueryAggTableScanOperator.javaLastByAccumulatorand none has initialized result. Applied to both normal aggregation and cache-hit paths.FileLoaderUtils.javaAlignedFullPath.VECTOR_PLACEHOLDERfor time-column modification lookupsModificationUtils.javamodified = truewhen value chunk is fully removedIoTDBDeletionTableIT.javalast_byafter deleteSemantic Note
This changes non-grouped
last_byon empty results from returning one null row to returning zero rows, consistent with grouped-query behavior (which already returns zero rows for empty devices). Other aggregations likecount/max/lastare not affected by this change. Please confirm this is the intended semantics.Verification
Integration tests pass locally:
Result: 2 tests run, 0 failures, 0 errors.