Skip to content

Support user defined display for UDF #10376

@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

The feature request is based on the need that I would like get_field(expr, key) to displayed as expr[key].

two reason

  1. Mimic the pattern as Expr::GetIndexedField for Remove Expr::GetIndexedField and GetFieldAccess and always use function get_field for indexing #10374
  2. expr[key] looks nicer!

Expr::GetIndexedField(GetIndexedField { field, expr }) => match field {
GetFieldAccess::NamedStructField { name } => {
write!(f, "({expr})[{name}]")
}
GetFieldAccess::ListIndex { key } => write!(f, "({expr})[{key}]"),
GetFieldAccess::ListRange {
start,
stop,
stride,
} => {
write!(f, "({expr})[{start}:{stop}:{stride}]")
}
},

Given the current function to build the name has only a fixed pattern, I think enable user-defined display is a good idea

fn create_function_name(fun: &str, distinct: bool, args: &[Expr]) -> Result<String> {
let names: Vec<String> = args.iter().map(create_name).collect::<Result<_>>()?;
let distinct_str = match distinct {
true => "DISTINCT ",
false => "",
};
Ok(format!("{}({}{})", fun, distinct_str, names.join(",")))
}

Describe the solution you'd like

No response

Adding display_name to ScalarUDFImpl

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions