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

Method plan_wildcard_options

datafusion/sql/src/select.rs:908–950  ·  view source on GitHub ↗

If there is a REPLACE statement in the projected expression in the form of "REPLACE (some_column_within_an_expr AS some_column)", we should plan the replace expressions first.

(
        &self,
        plan: &LogicalPlan,
        empty_from: bool,
        planner_context: &mut PlannerContext,
        options: WildcardAdditionalOptions,
    )

Source from the content-addressed store, hash-verified

906 /// "REPLACE (some_column_within_an_expr AS some_column)", we should plan the
907 /// replace expressions first.
908 fn plan_wildcard_options(
909 &self,
910 plan: &LogicalPlan,
911 empty_from: bool,
912 planner_context: &mut PlannerContext,
913 options: WildcardAdditionalOptions,
914 ) -> Result<WildcardOptions> {
915 let planned_option = WildcardOptions {
916 ilike: options.opt_ilike,
917 exclude: options.opt_exclude,
918 except: options.opt_except,
919 replace: None,
920 rename: options.opt_rename,
921 };
922 if let Some(replace) = options.opt_replace {
923 let replace_expr = replace
924 .items
925 .iter()
926 .map(|item| {
927 self.sql_select_to_rex(
928 SelectItem::UnnamedExpr(item.expr.clone()),
929 plan,
930 empty_from,
931 planner_context,
932 )
933 })
934 .collect::<Result<Vec<_>>>()?
935 .into_iter()
936 .filter_map(|expr| match expr {
937 SelectExpr::Expression(expr) => Some(expr),
938 _ => None,
939 })
940 .collect::<Vec<_>>();
941
942 let planned_replace = PlannedReplaceSelectItem {
943 items: replace.items.into_iter().map(|i| *i).collect(),
944 planned_expressions: replace_expr,
945 };
946 Ok(planned_option.with_replace(planned_replace))
947 } else {
948 Ok(planned_option)
949 }
950 }
951
952 /// Wrap a plan in a projection
953 pub(crate) fn project(

Callers 1

sql_select_to_rexMethod · 0.80

Calls 7

sql_select_to_rexMethod · 0.80
collectMethod · 0.80
with_replaceMethod · 0.80
into_iterMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected