getChan commented on code in PR #24046:
URL: https://github.com/apache/datafusion/pull/24046#discussion_r3698436248


##########
datafusion/sql/src/expr/value.rs:
##########
@@ -74,10 +73,22 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
         unsigned_number: &str,
         negative: bool,
     ) -> Result<Expr> {
-        let signed_number: Cow<str> = if negative {
-            Cow::Owned(format!("-{unsigned_number}"))
+        let mut signed_number =
+            String::with_capacity(unsigned_number.len() + 
usize::from(negative));
+        if negative {
+            signed_number.push('-');
+        }
+        // remove underscores, since the Rust parser used here does not 
support them
+        unsigned_number.bytes().for_each(|b| {
+            if b != b'_' {
+                signed_number.push(b as char);
+            }
+        });
+
+        let unsigned_number = if negative {
+            &signed_number[1..]
         } else {
-            Cow::Borrowed(unsigned_number)
+            signed_number.as_str()

Review Comment:
   nit : how about `retain()`?  for cleanup
   ```
   let mut signed_number = if negative {                                        
                                        
       format!("-{unsigned_number}")                                            
                                        
   } else {                                                                     
                                        
       unsigned_number.to_string()                                              
                                        
   };                                                                           
                                        
   signed_number.retain(|c| c != '_');                 
   ```
   same memory and iteration



-- 
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