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

Function remove_optimizer_rule

datafusion/core/src/execution/context/mod.rs:2888–2930  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
optimizerMethod · 0.80
into_optimized_planMethod · 0.80
sqlMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45
stateMethod · 0.45
nameMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…