Backport aggregation related enhance#1073
Merged
Conversation
…, now limit to header level)
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.
gemini:
This appears to be a substantial feature addition and refactoring aimed at supporting Session Windows based on custom start/end events (via
EMIT AFTER SESSION CLOSE) and introducing TTL (Time-To-Live) support for Hybrid Hash Tables (spill-to-disk storage) using RocksDB compaction filters.Here is a summary and review of the changes:
1. RocksDB Integration Refactoring
The existing
RocksHandlerandRocksclasses are being replaced/renamed toRocksDBColumnFamilyHandlerandRocksDB.RocksDBclass now managesrocksdb::DBand handles the lifecycle of column families.__tp_meta_ttl__.<cf_name>) into the default column family so that when the DB is reopened, the correct TTLs are applied to specific column families.RocksDBTTLCompactionFilteris implemented to filter out expired keys during RocksDB compaction based on a timestamp suffix appended to the value.HybridHashTable(used in Joins and Aggregations) to automatically clean up old state on disk without explicit cleanup scans, which is crucial for long-running streaming queries.2. Hybrid Hash Table Updates
HybridHashTableConfignow includesttlandkv_options.HybridHashTable(andHybridKeyList) now optionally appends a timestamp if TTL is enabled.HybridKeyList(used for tracking timeouts) was refactored to support removing specific keys (removeKey) and handling timeouts more efficiently (removeTimedOutKeys), including refilling from disk when the in-memory buffer is exhausted.3. EMIT AFTER SESSION CLOSE
This is the core functional addition.
EMIT AFTER SESSION CLOSE IDENTIFIED BY (ts_col, start_cond, end_cond) WITH MAXSPAN ....HybridAggregator):executeAndFinalizeAfterSessionCloseis added.start_condis true (or implied), a new session is created.merge_open_sessionsis enabled, new start events merge into existing sessions. Otherwise, the old session is closed (emitted) and a new one starts.end_condis true, the session is finalized and emitted. Theinclude_session_endsetting controls if the ending row is included in the aggregate.HybridKeyListtracks the creation timestamp of sessions. If a session exceedsMAXSPAN(checked per row) orTIMEOUT(checked viaremoveTimedOutKeys), it is forcibly closed/emitted.4. Integration
AggregatingStepandAggregatingTransformare updated to initialize the RocksDB/Hybrid configuration with the new TTL settings passed from query settings (aggregate_state_ttl_sec).ParserEmitQueryis updated to parse the new syntax, supporting various overloads ofIDENTIFIED BY(e.g., tuple for start/end columns).Code Quality & Correctness Checks
HybridAggregator_ExecuteAndFinalize.cppcovers edge cases like "End event without start" (orphan events) and "Start event while open".std::shared_ptrforRocksDBinstances and handlers seems correct to manage lifecycles.99109_emit_after_session_close.sqlcovers many permutations (only maxspan, start/end columns, merging). Unit tests for the newRocksDBwrapper are included.