Skip to content

Commit 6c6acc7

Browse files
fix: Box WindowFunction in ExprFuncKind enum to reduce enum total size
As suggested by `clippy`: ``` warning: large size difference between variants --> datafusion/expr/src/expr_fn.rs:772:1 | 772 | / pub enum ExprFuncKind { 773 | | Aggregate(AggregateFunction), | | ---------------------------- the second-largest variant contains at least 72 bytes 774 | | Window(WindowFunction), | | ---------------------- the largest variant contains at least 288 bytes 775 | | } | |_^ the entire enum is at least 288 bytes | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant = note: `#[warn(clippy::large_enum_variant)]` on by default help: consider boxing the large fields to reduce the total size of the enum | 774 - Window(WindowFunction), 774 + Window(Box<WindowFunction>), | ```
1 parent 17c968a commit 6c6acc7

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

datafusion/expr/src/expr_fn.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ pub trait ExprFunctionExt {
771771
#[derive(Debug, Clone)]
772772
pub enum ExprFuncKind {
773773
Aggregate(AggregateFunction),
774-
Window(WindowFunction),
774+
Window(Box<WindowFunction>),
775775
}
776776

777777
/// Implementation of [`ExprFunctionExt`].
@@ -833,10 +833,11 @@ impl ExprFuncBuilder {
833833
udaf.params.null_treatment = null_treatment;
834834
Expr::AggregateFunction(udaf)
835835
}
836-
ExprFuncKind::Window(WindowFunction {
837-
fun,
838-
params: WindowFunctionParams { args, .. },
839-
}) => {
836+
ExprFuncKind::Window(wf) => {
837+
let WindowFunction {
838+
fun,
839+
params: WindowFunctionParams { args, .. },
840+
} = *wf;
840841
// FILTER is only supported for aggregate window functions
841842
if filter.is_some()
842843
&& matches!(fun, WindowFunctionDefinition::WindowUDF(_))
@@ -912,7 +913,7 @@ impl ExprFunctionExt for Expr {
912913
ExprFuncBuilder::new(Some(ExprFuncKind::Aggregate(udaf)))
913914
}
914915
Expr::WindowFunction(udwf) => {
915-
ExprFuncBuilder::new(Some(ExprFuncKind::Window(*udwf)))
916+
ExprFuncBuilder::new(Some(ExprFuncKind::Window(udwf)))
916917
}
917918
_ => ExprFuncBuilder::new(None),
918919
};
@@ -952,7 +953,7 @@ impl ExprFunctionExt for Expr {
952953
ExprFuncBuilder::new(Some(ExprFuncKind::Aggregate(udaf)))
953954
}
954955
Expr::WindowFunction(udwf) => {
955-
ExprFuncBuilder::new(Some(ExprFuncKind::Window(*udwf)))
956+
ExprFuncBuilder::new(Some(ExprFuncKind::Window(udwf)))
956957
}
957958
_ => ExprFuncBuilder::new(None),
958959
};
@@ -965,7 +966,7 @@ impl ExprFunctionExt for Expr {
965966
fn partition_by(self, partition_by: Vec<Expr>) -> ExprFuncBuilder {
966967
match self {
967968
Expr::WindowFunction(udwf) => {
968-
let mut builder = ExprFuncBuilder::new(Some(ExprFuncKind::Window(*udwf)));
969+
let mut builder = ExprFuncBuilder::new(Some(ExprFuncKind::Window(udwf)));
969970
builder.partition_by = Some(partition_by);
970971
builder
971972
}
@@ -976,7 +977,7 @@ impl ExprFunctionExt for Expr {
976977
fn window_frame(self, window_frame: WindowFrame) -> ExprFuncBuilder {
977978
match self {
978979
Expr::WindowFunction(udwf) => {
979-
let mut builder = ExprFuncBuilder::new(Some(ExprFuncKind::Window(*udwf)));
980+
let mut builder = ExprFuncBuilder::new(Some(ExprFuncKind::Window(udwf)));
980981
builder.window_frame = Some(window_frame);
981982
builder
982983
}

0 commit comments

Comments
 (0)