()
| 2886 | |
| 2887 | #[tokio::test] |
| 2888 | async fn remove_optimizer_rule() -> Result<()> { |
| 2889 | let get_optimizer_rules = |ctx: &SessionContext| { |
| 2890 | ctx.state() |
| 2891 | .optimizer() |
| 2892 | .rules |
| 2893 | .iter() |
| 2894 | .map(|r| r.name().to_owned()) |
| 2895 | .collect::<HashSet<_>>() |
| 2896 | }; |
| 2897 | |
| 2898 | let ctx = SessionContext::new(); |
| 2899 | assert!(get_optimizer_rules(&ctx).contains("simplify_expressions")); |
| 2900 | |
| 2901 | // default plan |
| 2902 | let plan = ctx |
| 2903 | .sql("select 1 + 1") |
| 2904 | .await? |
| 2905 | .into_optimized_plan()? |
| 2906 | .to_string(); |
| 2907 | assert_snapshot!(plan, @r" |
| 2908 | Projection: Int64(2) AS Int64(1) + Int64(1) |
| 2909 | EmptyRelation: rows=1 |
| 2910 | "); |
| 2911 | |
| 2912 | assert!(ctx.remove_optimizer_rule("simplify_expressions")); |
| 2913 | assert!(!get_optimizer_rules(&ctx).contains("simplify_expressions")); |
| 2914 | |
| 2915 | // plan without the simplify_expressions rule |
| 2916 | let plan = ctx |
| 2917 | .sql("select 1 + 1") |
| 2918 | .await? |
| 2919 | .into_optimized_plan()? |
| 2920 | .to_string(); |
| 2921 | assert_snapshot!(plan, @r" |
| 2922 | Projection: Int64(1) + Int64(1) |
| 2923 | EmptyRelation: rows=1 |
| 2924 | "); |
| 2925 | |
| 2926 | // attempting to remove a non-existing rule returns false |
| 2927 | assert!(!ctx.remove_optimizer_rule("simplify_expressions")); |
| 2928 | |
| 2929 | Ok(()) |
| 2930 | } |
| 2931 | |
| 2932 | #[test] |
| 2933 | fn test_parse_duration() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…