Conversation
…indow functions ## Summary Implemented Snowflake-compatible window functions CONDITIONAL_TRUE_EVENT and CONDITIONAL_CHANGE_EVENT using DataFusion's WindowUDFImpl and PartitionEvaluator traits. ## Changes - Add engine/src/functions/window.rs - CONDITIONAL_TRUE_EVENT: increments counter when condition is TRUE - CONDITIONAL_CHANGE_EVENT: increments counter when value changes - WindowUDFImpl and PartitionEvaluator implementations - Support for multiple data types (Int, Float, String, Boolean, Date/Time) - Update engine/src/functions/mod.rs - Add window module export - Update documentation - Update engine/src/executor.rs - Register Window UDFs (register_udwf) - Add integration tests for both functions ## Technical Details - Uses DataFusion 45 API (PartitionEvaluatorArgs, WindowUDFFieldArgs) - Implements evaluate_all() for full partition processing - supports_bounded_execution() = false for optimal performance - Handles NULL values correctly - Array value comparison across types ## Tests - Unit tests: 5 tests in window.rs - Integration tests: 2 tests in executor.rs - All tests passing (199 unit + 7 integration) ## Completes Phase 8 All Phase 8 window functions now implemented: - FIRST_VALUE/LAST_VALUE (Phase 5) - NTH_VALUE (Phase 5) - LEAD/LAG (existing) - NTILE (Phase 5) - PERCENT_RANK/CUME_DIST (Phase 8) - RATIO_TO_REPORT (Phase 8) - CONDITIONAL_TRUE_EVENT (this PR) - CONDITIONAL_CHANGE_EVENT (this PR)
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.
概要
Phase 8 の最終機能として、Snowflake 互換の Window Functions
CONDITIONAL_TRUE_EVENTとCONDITIONAL_CHANGE_EVENTを実装しました。変更内容
新規ファイル
CONDITIONAL_TRUE_EVENT: 条件が TRUE のときカウンタをインクリメントCONDITIONAL_CHANGE_EVENT: 値が前の行から変化したときカウンタをインクリメントWindowUDFImplおよびPartitionEvaluatorトレイトを実装変更ファイル
engine/src/functions/mod.rs
engine/src/executor.rs
register_udwf)技術詳細
DataFusion API 対応
PartitionEvaluatorArgsの引数追加WindowUDFFieldArgsの使用evaluate_all()メソッドでパーティション全体を一括処理supports_bounded_execution()=falseで最適なパフォーマンス機能詳細
CONDITIONAL_TRUE_EVENT
CONDITIONAL_CHANGE_EVENT
テスト結果
追加テスト
window.rs: 5 ユニットテストtest_conditional_true_event_basictest_conditional_true_event_with_nullstest_conditional_change_event_basictest_conditional_change_event_with_nullstest_conditional_change_event_stringsexecutor.rs: 2 統合テストtest_conditional_true_eventtest_conditional_change_eventPhase 8 完了
Phase 8 の全ての Window Functions が実装完了:
チェックリスト
関連
.claude/plans/phase-8-snowflake-emulator.md