Creates a window function call that is a fused version of all the calls in the group. `new_col` is the column index where the fused call will be inserted at.
(self, new_col: usize)
| 500 | /// Creates a window function call that is a fused version of all the calls in the group. |
| 501 | /// `new_col` is the column index where the fused call will be inserted at. |
| 502 | fn fuse(self, new_col: usize) -> (HirScalarExpr, Vec<HirScalarExpr>) { |
| 503 | let fused = match self.options { |
| 504 | WindowFuncCallOptions::Value(options) => { |
| 505 | let (fused_funcs, fused_args): (Vec<_>, Vec<_>) = self |
| 506 | .calls |
| 507 | .iter() |
| 508 | .map(|(_idx, call)| { |
| 509 | if let HirScalarExpr::Windowing( |
| 510 | WindowExpr { |
| 511 | func: |
| 512 | WindowExprType::Value(ValueWindowExpr { |
| 513 | func, |
| 514 | args, |
| 515 | order_by: _, |
| 516 | window_frame: _, |
| 517 | ignore_nulls: _, |
| 518 | }), |
| 519 | partition_by: _, |
| 520 | order_by: _, |
| 521 | }, |
| 522 | _name, |
| 523 | ) = call |
| 524 | { |
| 525 | (func.clone(), (**args).clone()) |
| 526 | } else { |
| 527 | panic!("unknown window function in FusionGroup") |
| 528 | } |
| 529 | }) |
| 530 | .unzip(); |
| 531 | let fused_args = HirScalarExpr::call_variadic( |
| 532 | RecordCreate { |
| 533 | // These field names are not important, because this record will only be an |
| 534 | // intermediate expression, which we'll manipulate further before it ends up |
| 535 | // anywhere where a column name would be visible. |
| 536 | field_names: iter::repeat(ColumnName::from("")) |
| 537 | .take(fused_args.len()) |
| 538 | .collect(), |
| 539 | }, |
| 540 | fused_args, |
| 541 | ); |
| 542 | HirScalarExpr::windowing(WindowExpr { |
| 543 | func: WindowExprType::Value(ValueWindowExpr { |
| 544 | func: ValueWindowFunc::Fused(fused_funcs), |
| 545 | args: Box::new(fused_args), |
| 546 | order_by: options.inner_order_by, |
| 547 | window_frame: options.window_frame, |
| 548 | ignore_nulls: options.ignore_nulls, |
| 549 | }), |
| 550 | partition_by: options.partition_by, |
| 551 | order_by: options.outer_order_by, |
| 552 | }) |
| 553 | } |
| 554 | WindowFuncCallOptions::Agg(options) => { |
| 555 | let (fused_funcs, fused_args): (Vec<_>, Vec<_>) = self |
| 556 | .calls |
| 557 | .iter() |
| 558 | .map(|(_idx, call)| { |
| 559 | if let HirScalarExpr::Windowing( |
no test coverage detected