Skip to content

Commit 5c370fa

Browse files
authored
Simplify GetFieldFunc's display_name, schema_name` (#17167)
There is no need to create intermediate `ScalarValue::Utf8` if all we want is the inner value.
1 parent 274cdba commit 5c370fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

datafusion/functions/src/core/getfield.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl ScalarUDFImpl for GetFieldFunc {
108108
let [base, field_name] = take_function_args(self.name(), args)?;
109109

110110
let name = match field_name {
111-
Expr::Literal(name, _) => name,
112-
other => &ScalarValue::Utf8(Some(other.schema_name().to_string())),
111+
Expr::Literal(name, _) => name.to_string(),
112+
other => other.schema_name().to_string(),
113113
};
114114

115115
Ok(format!("{base}[{name}]"))
@@ -118,8 +118,8 @@ impl ScalarUDFImpl for GetFieldFunc {
118118
fn schema_name(&self, args: &[Expr]) -> Result<String> {
119119
let [base, field_name] = take_function_args(self.name(), args)?;
120120
let name = match field_name {
121-
Expr::Literal(name, _) => name,
122-
other => &ScalarValue::Utf8(Some(other.schema_name().to_string())),
121+
Expr::Literal(name, _) => name.to_string(),
122+
other => other.schema_name().to_string(),
123123
};
124124

125125
Ok(format!("{}[{}]", base.schema_name(), name))

0 commit comments

Comments
 (0)