Support PPL timewrap command #5241
Conversation
PR Reviewer Guide 🔍(Review updated until commit 4ba32b8)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 61d68f3 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 4ba32b8
Suggestions up to commit 219a704
Suggestions up to commit e0a03f0
Suggestions up to commit 6276cba
Suggestions up to commit e0a03f0
|
|
Persistent review updated to latest commit 6276cba |
6276cba to
e0a03f0
Compare
|
Persistent review updated to latest commit e0a03f0 |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 4ba32b8.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 219a704 |
Implement the timewrap command that reshapes timechart output by wrapping each time period into a separate data series, enabling day-over-day, week-over-week, and other recurring interval comparisons. Signed-off-by: Jialiang Li <jialiang.li@hey.com> Signed-off-by: Kai Huang <ahkcs@amazon.com>
Add timewrap_test to SHOW TABLES expected output (25 tables). Signed-off-by: Jialiang Li <jialiang.li@hey.com> Signed-off-by: Kai Huang <ahkcs@amazon.com>
…etic - Extract all timewrap helper methods to TimewrapUtils.java in calcite/utils/ - Add precise EXTRACT-based period computation for month/quarter/year - Add cumDaysBeforeMonth with leap year CASE expression for precise quarter offset - Month/quarter/year period assignment now uses calendar arithmetic instead of approximate fixed-length conversions Signed-off-by: Jialiang Li <jialiang.li@hey.com> Signed-off-by: Kai Huang <ahkcs@amazon.com>
- Remove Calcite PIVOT from timewrap: no more MAX_PERIODS limit or crash risk - Add post-processing pivot in execution engine: dynamically builds columns from actual data using HashMap grouping - Add series parameter: series=relative (default), series=short (s0, s1) - Add series=exact grammar support (falls back to short at runtime) - Add time_format grammar support for series=exact - Benchmark: 1000 period columns in ~50ms (Calcite PIVOT crashed at 1000) - 32 IT tests, all using verifySchema + verifyDataRows Signed-off-by: Jialiang Li <jialiang.li@hey.com> Signed-off-by: Kai Huang <ahkcs@amazon.com>
219a704 to
4ba32b8
Compare
|
Persistent review updated to latest commit 4ba32b8 |
The timewrap pivot (turning the unpivoted [display_ts, value, __base_offset__, __period__] rows into Splunk-style period columns) was done as post-processing in OpenSearchExecutionEngine.buildResultSet, gated on CalcitePlanContext thread-locals. The analytics-engine route executes the RelNode via AnalyticsExecutionEngine and never reaches that code, so timewrap queries came back unpivoted (CalciteTimewrapCommandIT 0/32 on the analytics route). Extract the pivot into a shared core helper (TimewrapPivot) and call it from both execution engines so they produce identical output. AnalyticsExecutionEngine captures the timewrap signals at execute() entry via TimewrapSignals because the result callback runs on a different worker thread than the planning thread that set the thread-locals. CalciteTimewrapCommandIT: 32/32 on both the Calcite/v2 and analytics-engine routes. Signed-off-by: Kai Huang <ahkcs@amazon.com>
Description
Adds the
timewrapcommand to PPL, which reshapestimechartoutput by wrapping each time period into separate columns for side-by-side comparison (day-over-day, week-over-week, etc.). Behavior verified against Splunk.Syntax:
... | timechart <agg> | timewrap <span> [align=end|now]Key features
<agg>_<N><unit>_before,<agg>_latest_<unit>,<agg>_<N><unit>_afteralign=end(default): uses WHERE upper bound as reference for deterministic column namesalign=now: uses current time as referenceImplementation
timewrapCommandrule reusing existingspanLiteralTimewrapnode with unit, value, alignUNIX_TIMESTAMP/FROM_UNIXTIMEfor epoch conversion__base_offset__, and handlelatest_<unit>naming@timestamp <=filter foralign=endreferenceKnown limitations
BYclause not yet supportedTesting
Issues Resolved
Resolves #5237
Check List
--signoff