-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert BuiltInWindowFunction::{Lead, Lag}
to a user defined window function
#12857
Merged
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
9efb417
Move `lead-lag` to `functions-window` package
jcsherin 6f05a9c
Builds with warnings
jcsherin d2ebd3a
Adds `PartitionEvaluatorArgs`
jcsherin e5e5ab9
Extracts `shift_offset` from input expressions
jcsherin 303b74b
Computes shift offset
jcsherin 689ed3a
Get default value from input expression
jcsherin 0774a58
Implements `partition_evaluator`
jcsherin 009a1be
Fixes compiler warnings
jcsherin 8dc161f
Comments out failing tests
jcsherin 45e259e
Fixes `cargo test` errors and warnings
jcsherin 0d2aa99
Minor: taplo formatting
jcsherin 5ccb795
Delete code
jcsherin 7d8b3e6
Define `lead`, `lag` user-defined window functions
jcsherin ba9d24a
Fixes `cargo build` errors
jcsherin 402dcac
Export udwf and expression public APIs
jcsherin 2ce0883
Mark result field as nullable
jcsherin 95e8f87
Delete `return_type` tests for `lead` and `lag`
jcsherin 04f30ec
Disables test: window function case insensitive
jcsherin d034082
Fixes: lowercase name in logical plan
jcsherin 513df2a
Reverts to old methods for computing `shift_offset`, `default_value`
jcsherin bb0bd8b
Implements expression reversal
jcsherin 0e576bb
Fixes: lowercase name in logical plans
jcsherin 5490860
Fixes: doc test compilation errors
jcsherin f0c0e72
Temporarily quite clippy errors
jcsherin 9051d2f
Fixes proto defintion
jcsherin b4cdc10
Merge branch 'main' into convert-lead-lag-udwf
jcsherin be74322
Minor: fixes formatting
jcsherin c9ac517
Fixes: doc tests
jcsherin e37752f
Uses macro for defining `lag_udwf()` and `leag_udwf()`
jcsherin 6fb12e6
Fixes: window fuzz test cases
jcsherin ae26cb6
Copies doc comments verbatim from `BuiltInWindowFunction` enum
jcsherin 51652d7
Deletes from window function case insensitive test
jcsherin 723ca68
Deletes `BuiltInWindowFunction` expression APIs
jcsherin 742c196
Delete from `create_built_in_window_expr`
jcsherin 99093f5
Deletes proto serialization
jcsherin 0925785
Delete from `BuiltInWindowFunction` enum
jcsherin 6f05818
Deletes test for finding built-in window function
jcsherin 0be8500
Merge branch 'main' into convert-lead-lag-udwf
jcsherin 5854f77
Merge branch 'main' into convert-lead-lag-udwf
jcsherin e69463f
Fixes build errors + deletes redundant code
jcsherin d0baa94
Deletes more code
jcsherin 9199943
Delete unnecessary structs
jcsherin 000ceb7
Refactors shift offset computation
jcsherin ae0b91b
Passes range unit test
jcsherin a0973f9
Fixes: clippy::get-first error
jcsherin 9ddf1c9
Rewrite unit tests for WindowUDF
jcsherin 3a084ed
Fixes: unit test for lag with default value
jcsherin 82abc5c
Consistent input expressions and data types in unit tests
jcsherin d1a35d7
Merge branch 'main' into convert-lead-lag-udwf
jcsherin e648033
Minor: fixes formatting
jcsherin ea811c6
Restore original helper method for unit tests
jcsherin 3b6bc5d
Revert "Refactors shift offset computation"
jcsherin ab8a83c
Moves helper functions into `functions-window-common` package
jcsherin 66c4f5e
Uses common helper functions in `{lead, lag}`
jcsherin c25ba86
Minor: formatting
jcsherin 5f3df05
Revert "Moves helper functions into `functions-window-common` package"
jcsherin 6b16550
Moves common functions to utils
jcsherin a65ef26
Merge branch 'main' into convert-lead-lag-udwf
jcsherin 072d748
Minor: formatting fixes
jcsherin 952dee0
Update lowercase names in explain output
jcsherin 4ba4a62
Adds doc for `lead()` and `lag()` expression functions
jcsherin 873736a
Add doc for `WindowShiftKind::shift_offset`
jcsherin 3eb0985
Remove `arrow` dev dependency
jcsherin 0f9ad76
Minor: formatting
jcsherin df7cff4
Update inner doc comment
jcsherin 5550015
Serialize 1 or more window function arguments
jcsherin 9e5916d
Adds logical plan roundtrip test cases
jcsherin c6e8235
Refactor: readability of unit tests
jcsherin d7ee287
Minor: rename variable bindings
jcsherin 4fe2135
Minor: copy edit
jcsherin 7dbb7e8
Revert "Remove `arrow` dev dependency"
jcsherin 7892e05
Merge branch 'main' into convert-lead-lag-udwf
jcsherin 7d00e3a
Merge remote-tracking branch 'apache/main' into convert-lead-lag-udwf
alamb 47c2b9c
Merge branch 'main' into convert-lead-lag-udwf
jcsherin 4385f21
Move null argument handling helper to utils
jcsherin 270a203
Disable failing sqllogic tests for handling NULL input
jcsherin 93569ed
Revert "Disable failing sqllogic tests for handling NULL input"
jcsherin 814a9b7
Fixes: incorrect NULL handling in `lead`/`lag` window function
jcsherin c4b8840
Adds more tests cases
jcsherin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use datafusion_common::arrow::datatypes::DataType; | ||
use datafusion_physical_expr_common::physical_expr::PhysicalExpr; | ||
use std::sync::Arc; | ||
|
||
/// Arguments passed to user-defined window function | ||
#[derive(Debug, Default)] | ||
pub struct ExpressionArgs<'a> { | ||
/// The expressions passed as arguments to the user-defined window | ||
/// function. | ||
input_exprs: &'a [Arc<dyn PhysicalExpr>], | ||
/// The corresponding data types of expressions passed as arguments | ||
/// to the user-defined window function. | ||
input_types: &'a [DataType], | ||
} | ||
|
||
impl<'a> ExpressionArgs<'a> { | ||
/// Create an instance of [`ExpressionArgs`]. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `input_exprs` - The expressions passed as arguments | ||
/// to the user-defined window function. | ||
/// * `input_types` - The data types corresponding to the | ||
/// arguments to the user-defined window function. | ||
/// | ||
pub fn new( | ||
input_exprs: &'a [Arc<dyn PhysicalExpr>], | ||
input_types: &'a [DataType], | ||
) -> Self { | ||
Self { | ||
input_exprs, | ||
input_types, | ||
} | ||
} | ||
|
||
/// Returns the expressions passed as arguments to the user-defined | ||
/// window function. | ||
pub fn input_exprs(&self) -> &'a [Arc<dyn PhysicalExpr>] { | ||
self.input_exprs | ||
} | ||
|
||
/// Returns the [`DataType`]s corresponding to the input expressions | ||
/// to the user-defined window function. | ||
pub fn input_types(&self) -> &'a [DataType] { | ||
self.input_types | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍