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

Method try_optimize_sort

datafusion/optimizer/src/common_subexpr_eliminate.rs:96–125  ·  view source on GitHub ↗
(
        &self,
        sort: Sort,
        config: &dyn OptimizerConfig,
    )

Source from the content-addressed store, hash-verified

94 }
95
96 fn try_optimize_sort(
97 &self,
98 sort: Sort,
99 config: &dyn OptimizerConfig,
100 ) -> Result<Transformed<LogicalPlan>> {
101 let Sort { expr, input, fetch } = sort;
102 let input = Arc::unwrap_or_clone(input);
103 let (sort_expressions, sort_params): (Vec<_>, Vec<(_, _)>) = expr
104 .into_iter()
105 .map(|sort| (sort.expr, (sort.asc, sort.nulls_first)))
106 .unzip();
107 let new_sort = self
108 .try_unary_plan(sort_expressions, input, config)?
109 .update_data(|(new_expr, new_input)| {
110 LogicalPlan::Sort(Sort {
111 expr: new_expr
112 .into_iter()
113 .zip(sort_params)
114 .map(|(expr, (asc, nulls_first))| SortExpr {
115 expr,
116 asc,
117 nulls_first,
118 })
119 .collect(),
120 input: Arc::new(new_input),
121 fetch,
122 })
123 });
124 Ok(new_sort)
125 }
126
127 fn try_optimize_filter(
128 &self,

Callers 1

rewriteMethod · 0.80

Calls 7

newFunction · 0.85
update_dataMethod · 0.80
try_unary_planMethod · 0.80
collectMethod · 0.80
SortClass · 0.50
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected