andygrove commented on code in PR #3730:
URL: https://github.com/apache/datafusion-comet/pull/3730#discussion_r2965860459


##########
native/spark-expr/src/conversion_funcs/string.rs:
##########
@@ -959,8 +974,20 @@ fn get_timestamp_values<T: TimeZone>(
     timestamp_type: &str,
     tz: &T,
 ) -> SparkResult<Option<i64>> {
-    let values: Vec<_> = value.split(['T', '-', ':', '.']).collect();
-    let year = values[0].parse::<i32>().unwrap_or_default();
+    // Handle negative year: strip leading '-' and remember the sign.
+    let (sign, date_part) = if let Some(stripped) = value.strip_prefix('-') {
+        (-1i32, stripped)
+    } else {
+        (1i32, value)
+    };
+    let values: Vec<_> = date_part.split(['T', ' ', '-', ':', '.']).collect();

Review Comment:
   This is pre-existing code, but worth noting that this is allocating multiple 
strings and a vec for each date. This seems expensive.



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