Run the test, panic'ing on error
(self)
| 825 | |
| 826 | /// Run the test, panic'ing on error |
| 827 | async fn run(self) { |
| 828 | let Self { |
| 829 | query, |
| 830 | expected_errors, |
| 831 | memory_limit, |
| 832 | memory_pool, |
| 833 | config, |
| 834 | scenario, |
| 835 | disk_manager_builder, |
| 836 | expected_plan, |
| 837 | expected_success, |
| 838 | } = self; |
| 839 | |
| 840 | let table = scenario.table(); |
| 841 | |
| 842 | let mut builder = RuntimeEnvBuilder::new() |
| 843 | // disk manager setting controls the spilling |
| 844 | .with_disk_manager_builder(disk_manager_builder) |
| 845 | .with_memory_limit(memory_limit, MEMORY_FRACTION); |
| 846 | |
| 847 | if let Some(pool) = memory_pool { |
| 848 | builder = builder.with_memory_pool(pool); |
| 849 | }; |
| 850 | let runtime = builder.build_arc().unwrap(); |
| 851 | |
| 852 | // Configure execution |
| 853 | let builder = SessionStateBuilder::new() |
| 854 | .with_config(config) |
| 855 | .with_runtime_env(runtime) |
| 856 | .with_default_features(); |
| 857 | let builder = match scenario.rules() { |
| 858 | Some(rules) => builder.with_physical_optimizer_rules(rules), |
| 859 | None => builder, |
| 860 | }; |
| 861 | |
| 862 | let ctx = SessionContext::new_with_state(builder.build()); |
| 863 | ctx.register_table("t", table).expect("registering table"); |
| 864 | |
| 865 | let query = query.expect("Test error: query not specified"); |
| 866 | let df = ctx.sql(&query).await.expect("Planning query"); |
| 867 | |
| 868 | if !expected_plan.is_empty() { |
| 869 | let expected_plan: Vec<_> = |
| 870 | expected_plan.iter().map(|s| s.as_str()).collect(); |
| 871 | let actual_plan = df |
| 872 | .clone() |
| 873 | .explain(false, false) |
| 874 | .unwrap() |
| 875 | .collect() |
| 876 | .await |
| 877 | .unwrap(); |
| 878 | assert_batches_eq!(expected_plan, &actual_plan); |
| 879 | } |
| 880 | |
| 881 | match df.collect().await { |
| 882 | Ok(_batches) => { |
| 883 | if !expected_success { |
| 884 | panic!( |
no test coverage detected