MCPcopy Create free account
hub / github.com/apache/datafusion / test_window_frame_creation

Function test_window_frame_creation

datafusion/expr/src/window_frame.rs:502–547  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

500
501 #[test]
502 fn test_window_frame_creation() -> Result<()> {
503 let window_frame = ast::WindowFrame {
504 units: ast::WindowFrameUnits::Range,
505 start_bound: ast::WindowFrameBound::Following(None),
506 end_bound: None,
507 };
508 let err = WindowFrame::try_from(window_frame).unwrap_err();
509 assert_eq!(
510 err.strip_backtrace(),
511 "Error during planning: Invalid window frame: start bound cannot be UNBOUNDED FOLLOWING".to_owned()
512 );
513
514 let window_frame = ast::WindowFrame {
515 units: ast::WindowFrameUnits::Range,
516 start_bound: ast::WindowFrameBound::Preceding(None),
517 end_bound: Some(ast::WindowFrameBound::Preceding(None)),
518 };
519 let err = WindowFrame::try_from(window_frame).unwrap_err();
520 assert_eq!(
521 err.strip_backtrace(),
522 "Error during planning: Invalid window frame: end bound cannot be UNBOUNDED PRECEDING".to_owned()
523 );
524
525 let window_frame = ast::WindowFrame {
526 units: ast::WindowFrameUnits::Rows,
527 start_bound: ast::WindowFrameBound::Preceding(Some(Box::new(
528 ast::Expr::value(ast::Value::Number("2".to_string(), false)),
529 ))),
530 end_bound: Some(ast::WindowFrameBound::Preceding(Some(Box::new(
531 ast::Expr::value(ast::Value::Number("1".to_string(), false)),
532 )))),
533 };
534
535 let window_frame = WindowFrame::try_from(window_frame)?;
536 assert_eq!(window_frame.units, WindowFrameUnits::Rows);
537 assert_eq!(
538 window_frame.start_bound,
539 WindowFrameBound::Preceding(ScalarValue::UInt64(Some(2)))
540 );
541 assert_eq!(
542 window_frame.end_bound,
543 WindowFrameBound::Preceding(ScalarValue::UInt64(Some(1)))
544 );
545
546 Ok(())
547 }
548
549 macro_rules! test_bound {
550 ($unit:ident, $value:expr, $expected:expr) => {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
valueFunction · 0.85
unwrap_errMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…