(
schema: &SchemaRef,
rng: &mut StdRng,
is_linear: bool,
)
| 327 | } |
| 328 | |
| 329 | fn get_random_function( |
| 330 | schema: &SchemaRef, |
| 331 | rng: &mut StdRng, |
| 332 | is_linear: bool, |
| 333 | ) -> (WindowFunctionDefinition, Vec<Arc<dyn PhysicalExpr>>, String) { |
| 334 | let arg = if is_linear { |
| 335 | // In linear test for the test version with WindowAggExec we use insert SortExecs to the plan to be able to generate |
| 336 | // same result with BoundedWindowAggExec which doesn't use any SortExec. To make result |
| 337 | // non-dependent on table order. We should use column a in the window function |
| 338 | // (Given that we do not use ROWS for the window frame. ROWS also introduces dependency to the table order.). |
| 339 | col("a", schema).unwrap() |
| 340 | } else { |
| 341 | col("x", schema).unwrap() |
| 342 | }; |
| 343 | let mut window_fn_map = HashMap::new(); |
| 344 | // HashMap values consists of tuple first element is WindowFunction, second is additional argument |
| 345 | // window function requires if any. For most of the window functions additional argument is empty |
| 346 | window_fn_map.insert( |
| 347 | "sum", |
| 348 | ( |
| 349 | WindowFunctionDefinition::AggregateUDF(sum_udaf()), |
| 350 | vec![arg.clone()], |
| 351 | ), |
| 352 | ); |
| 353 | window_fn_map.insert( |
| 354 | "count", |
| 355 | ( |
| 356 | WindowFunctionDefinition::AggregateUDF(count_udaf()), |
| 357 | vec![arg.clone()], |
| 358 | ), |
| 359 | ); |
| 360 | window_fn_map.insert( |
| 361 | "min", |
| 362 | ( |
| 363 | WindowFunctionDefinition::AggregateUDF(min_udaf()), |
| 364 | vec![arg.clone()], |
| 365 | ), |
| 366 | ); |
| 367 | window_fn_map.insert( |
| 368 | "max", |
| 369 | ( |
| 370 | WindowFunctionDefinition::AggregateUDF(max_udaf()), |
| 371 | vec![arg.clone()], |
| 372 | ), |
| 373 | ); |
| 374 | if !is_linear { |
| 375 | // row_number, rank, lead, lag doesn't use its window frame to calculate result. Their results are calculated |
| 376 | // according to table scan order. This adds the dependency to table order. Hence do not use these functions in |
| 377 | // Partition by linear test. |
| 378 | window_fn_map.insert( |
| 379 | "row_number", |
| 380 | ( |
| 381 | WindowFunctionDefinition::WindowUDF(row_number_udwf()), |
| 382 | vec![], |
| 383 | ), |
| 384 | ); |
| 385 | window_fn_map.insert( |
| 386 | "rank", |
no test coverage detected
searching dependent graphs…