Conversation
Open
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
Closes #18532
Adds
LTTB(Largest-Triangle-Three-Buckets) as a built-in Table Model table function for visualization-oriented downsampling, following the conventions of the existingM4table function.Function definition
DATA(set semantics) /TIMECOL/SIZE/SLIDE/ORIGINreuse theM4argument semantics and window construction (half-open[start, start+SIZE)windows,ORIGINalignment, count windows for integerSIZE).Nselects target-count mode: the whole partition is buffered and standard LTTB reduces each participant column to exactlyNpoints (all points whenM <= N), always preserving the first and last eligible points. Buckets follow[floor(i*(M-2)/(N-2))+1, floor((i+1)*(M-2)/(N-2))+1); the final bucket uses the last point as vertexC. Output useswindow_index = 0.SIZEselects window/bucket mode: each window is one LTTB bucket. Per participant column the anchor is chained across windows (the first eligible point seeds it), vertexCis the average point of the next window that carries data for the column (or the window's own last eligible point when there is none), and empty buckets leave the anchor untouched.INT32/INT64/FLOAT/DOUBLE; other types are rejected with the shared "not allowed columns" message).NULL/non-finite values are ignored per column; columns with no eligible points emitNULL. Area ties resolve to the earliest timestamp (stable input order). Integral columns keep exactlongvalues in the output.M4:window_start, window_end | window_index, partition columns, then<col>_time, <col>per participant column, aligned by output position and padded withNULL.Validation
Rejected at analysis time: neither/both of
NandSIZE;N < 3;Ngiven as a duration;NwithSLIDE/ORIGIN;SLIDE/ORIGINwithoutSIZE;ORIGINin count-window mode;SLIDEmode differing fromSIZE; descendingORDER BY; non-TIMESTAMPTIMECOL; unsupported participant types. All new messages are i18n constants in bothenandzhCommonMessages.Execution and distribution
TableDistributedPlanGenerator.canSplitTableFunctionProcessornow excludesLTTB(likeFFT), so the whole partition is gathered and ordered (MergeSortover exchanges) before the function runs — fragment-local LTTB samples are not mergeable.MAX_BUFFERED_POINTS), mirroring the row caps used byLOWPASS/XCORR; window mode keeps bounded state (current/next windows plus per-column anchor).Alternatives considered
SIZEmode (no chained anchor) would simplify overlapping windows but diverges from the issue's "previously selected point / next-bucket average" definition; chained anchors were chosen.M4TableFunction'sValueOperatorwas rejected because LTTB requires numeric values for triangle areas.This PR has:
LTTBTableFunctionTest,TableFunctionTest#testLTTB*— verified under bothenandzhlocales).IoTDBLTTBTableFunctionIT, passes with-PTableSimpleIT).Key changed/added classes (or packages if there are too many classes) in this PR
org.apache.iotdb.commons.udf.builtin.relational.tvf.LTTBTableFunction(new)org.apache.iotdb.commons.queryengine.plan.relational.function.TableBuiltinTableFunctionorg.apache.iotdb.db.queryengine.plan.relational.analyzer.StatementAnalyzer(tryAppendLTTBModeArgument)org.apache.iotdb.db.queryengine.plan.relational.planner.RelationPlannerorg.apache.iotdb.db.queryengine.plan.relational.planner.distribute.TableDistributedPlanGeneratororg.apache.iotdb.commons.i18n.CommonMessages(en/zh)🤖 Generated with Claude Code