jonahgao commented on code in PR #21454:
URL: https://github.com/apache/datafusion/pull/21454#discussion_r3061609452


##########
datafusion/sql/src/expr/mod.rs:
##########
@@ -306,10 +306,22 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
                 data_type,
                 value,
                 uses_odbc_syntax: _,
-            }) => Ok(Expr::Cast(Cast::new_from_field(
-                Box::new(lit(value.into_string().unwrap())),
-                self.convert_data_type_to_field(&data_type)?,
-            ))),
+            }) => {
+                let raw_value = value.to_string();

Review Comment:
   `raw_value` is only used in the error branch,introducing a redundant string 
allocation on the happy path. 
   How about excluding it from the error message?
   ```rust
   let value = value.into_string().ok_or_else(|| {
         plan_datafusion_err!("Typed literal requires a string payload")
     })?;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to