Initializes window frame from units (type), start bound and end bound.
(
units: WindowFrameUnits,
start_bound: WindowFrameBound,
end_bound: WindowFrameBound,
)
| 207 | |
| 208 | /// Initializes window frame from units (type), start bound and end bound. |
| 209 | pub fn new_bounds( |
| 210 | units: WindowFrameUnits, |
| 211 | start_bound: WindowFrameBound, |
| 212 | end_bound: WindowFrameBound, |
| 213 | ) -> Self { |
| 214 | let causal = match units { |
| 215 | WindowFrameUnits::Rows => match &end_bound { |
| 216 | WindowFrameBound::Following(value) => { |
| 217 | if value.is_null() { |
| 218 | // Unbounded following |
| 219 | false |
| 220 | } else { |
| 221 | let zero = ScalarValue::new_zero(&value.data_type()); |
| 222 | zero.map(|zero| value.eq(&zero)).unwrap_or(false) |
| 223 | } |
| 224 | } |
| 225 | _ => true, |
| 226 | }, |
| 227 | WindowFrameUnits::Range | WindowFrameUnits::Groups => match &end_bound { |
| 228 | WindowFrameBound::Preceding(value) => { |
| 229 | if value.is_null() { |
| 230 | // Unbounded preceding |
| 231 | true |
| 232 | } else { |
| 233 | let zero = ScalarValue::new_zero(&value.data_type()); |
| 234 | zero.map(|zero| value.gt(&zero)).unwrap_or(false) |
| 235 | } |
| 236 | } |
| 237 | _ => false, |
| 238 | }, |
| 239 | }; |
| 240 | Self { |
| 241 | units, |
| 242 | start_bound, |
| 243 | end_bound, |
| 244 | causal, |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | /// Regularizes the ORDER BY clause of the window frame. |
| 249 | pub fn regularize_order_bys(&self, order_by: &mut Vec<Sort>) -> Result<()> { |