(sql: &str)
| 645 | } |
| 646 | |
| 647 | fn test_sql(sql: &str) -> Result<LogicalPlan> { |
| 648 | // parse the SQL |
| 649 | let dialect = GenericDialect {}; // or AnsiDialect, or your own dialect ... |
| 650 | let ast: Vec<Statement> = Parser::parse_sql(&dialect, sql).unwrap(); |
| 651 | let statement = &ast[0]; |
| 652 | let context_provider = MyContextProvider::default() |
| 653 | .with_udaf(sum_udaf()) |
| 654 | .with_udaf(count_udaf()) |
| 655 | .with_udaf(avg_udaf()) |
| 656 | .with_expr_planners(vec![ |
| 657 | Arc::new(AggregateFunctionPlanner), |
| 658 | Arc::new(WindowFunctionPlanner), |
| 659 | ]) |
| 660 | .with_schema( |
| 661 | "test", |
| 662 | Schema::new_with_metadata( |
| 663 | vec![ |
| 664 | Field::new("col_int32", DataType::Int32, true), |
| 665 | Field::new("col_uint32", DataType::UInt32, true), |
| 666 | Field::new("col_utf8", DataType::Utf8, true), |
| 667 | Field::new("col_date32", DataType::Date32, true), |
| 668 | Field::new("col_date64", DataType::Date64, true), |
| 669 | // timestamp with no timezone |
| 670 | Field::new( |
| 671 | "col_ts_nano_none", |
| 672 | DataType::Timestamp(TimeUnit::Nanosecond, None), |
| 673 | true, |
| 674 | ), |
| 675 | // timestamp with UTC timezone |
| 676 | Field::new( |
| 677 | "col_ts_nano_utc", |
| 678 | DataType::Timestamp(TimeUnit::Nanosecond, Some("+00:00".into())), |
| 679 | true, |
| 680 | ), |
| 681 | ], |
| 682 | HashMap::new(), |
| 683 | ), |
| 684 | ); |
| 685 | |
| 686 | let sql_to_rel = SqlToRel::new(&context_provider); |
| 687 | let plan = sql_to_rel.sql_statement_to_plan(statement.clone())?; |
| 688 | |
| 689 | let config = OptimizerContext::new().with_skip_failing_rules(false); |
| 690 | let analyzer = Analyzer::new(); |
| 691 | let optimizer = Optimizer::new(); |
| 692 | // analyze and optimize the logical plan |
| 693 | let plan = analyzer.execute_and_check(plan, &config.options(), |_, _| {})?; |
| 694 | optimizer.optimize(plan, &config, observe) |
| 695 | } |
| 696 | |
| 697 | fn observe(_plan: &LogicalPlan, _rule: &dyn OptimizerRule) {} |
| 698 |
no test coverage detected
searching dependent graphs…