()
| 363 | |
| 364 | #[test] |
| 365 | fn test_analyze_boundary_exprs() { |
| 366 | let schema = Arc::new(Schema::new(vec![make_field("a", DataType::Int32)])); |
| 367 | |
| 368 | /// Test case containing (expression tree, lower bound, upper bound) |
| 369 | type TestCase = (Expr, Option<i32>, Option<i32>); |
| 370 | |
| 371 | let test_cases: Vec<TestCase> = vec![ |
| 372 | // a > 10 |
| 373 | (col("a").gt(lit(10)), Some(11), None), |
| 374 | // a < 20 |
| 375 | (col("a").lt(lit(20)), None, Some(19)), |
| 376 | // a > 10 AND a < 20 |
| 377 | ( |
| 378 | col("a").gt(lit(10)).and(col("a").lt(lit(20))), |
| 379 | Some(11), |
| 380 | Some(19), |
| 381 | ), |
| 382 | // a >= 10 |
| 383 | (col("a").gt_eq(lit(10)), Some(10), None), |
| 384 | // a <= 20 |
| 385 | (col("a").lt_eq(lit(20)), None, Some(20)), |
| 386 | // a >= 10 AND a <= 20 |
| 387 | ( |
| 388 | col("a").gt_eq(lit(10)).and(col("a").lt_eq(lit(20))), |
| 389 | Some(10), |
| 390 | Some(20), |
| 391 | ), |
| 392 | // a > 10 AND a < 20 AND a < 15 |
| 393 | ( |
| 394 | col("a") |
| 395 | .gt(lit(10)) |
| 396 | .and(col("a").lt(lit(20))) |
| 397 | .and(col("a").lt(lit(15))), |
| 398 | Some(11), |
| 399 | Some(14), |
| 400 | ), |
| 401 | // (a > 10 AND a < 20) AND (a > 15 AND a < 25) |
| 402 | ( |
| 403 | col("a") |
| 404 | .gt(lit(10)) |
| 405 | .and(col("a").lt(lit(20))) |
| 406 | .and(col("a").gt(lit(15))) |
| 407 | .and(col("a").lt(lit(25))), |
| 408 | Some(16), |
| 409 | Some(19), |
| 410 | ), |
| 411 | ]; |
| 412 | for (expr, lower, upper) in test_cases { |
| 413 | let boundaries = ExprBoundaries::try_new_unbounded(&schema).unwrap(); |
| 414 | let df_schema = DFSchema::try_from(Arc::clone(&schema)).unwrap(); |
| 415 | let physical_expr = |
| 416 | create_physical_expr(&expr, &df_schema, &ExecutionProps::new()).unwrap(); |
| 417 | let analysis_result = analyze( |
| 418 | &physical_expr, |
| 419 | AnalysisContext::new(boundaries), |
| 420 | df_schema.as_ref(), |
| 421 | ) |
| 422 | .unwrap(); |
nothing calls this directly
no test coverage detected
searching dependent graphs…