jayzhan211 commented on code in PR #8308:
URL: https://github.com/apache/arrow-datafusion/pull/8308#discussion_r1408589220


##########
datafusion/physical-expr/src/window/lead_lag.rs:
##########
@@ -235,11 +236,27 @@ fn get_default_value(
     default_value: Option<&ScalarValue>,
     dtype: &DataType,
 ) -> Result<ScalarValue> {
-    if let Some(value) = default_value {
-        if let ScalarValue::Int64(Some(val)) = value {
-            ScalarValue::try_from_string(val.to_string(), dtype)
+    if let Some(default_value) = default_value {
+        let default_value_type = default_value.data_type();
+        if can_coerce_from(dtype, &default_value_type)
+            || (dtype.is_integer() && default_value_type.is_integer())
+        {
+            ScalarValue::try_from_array(
+                &cast_with_options(
+                    &default_value.to_array()?,
+                    dtype,
+                    &CastOptions {
+                        safe: false,
+                        format_options: Default::default(),
+                    },
+                )?,
+                0,
+            )
         } else {
-            internal_err!("Expects default value to have Int64 type")
+            Err(DataFusionError::Internal(format!(

Review Comment:
   Can we use macro here? See 
https://github.com/apache/arrow-datafusion/issues/7360



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

Reply via email to