You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/04 17:56:15 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2142: implement 'StringConcat' operator to support sql like "select 'aa' || 'b' "

alamb commented on code in PR #2142:
URL: https://github.com/apache/arrow-datafusion/pull/2142#discussion_r842002406


##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -484,6 +485,20 @@ fn bitwise_or(left: ArrayRef, right: ArrayRef) -> Result<ArrayRef> {
     }
 }
 
+/// Use datafusion build-in expression `concat` to evaluate `StringConcat` operator
+fn string_concat(left: ArrayRef, right: ArrayRef) -> Result<ArrayRef> {
+    let result = string_expressions::concat(&[
+        ColumnarValue::Array(left),
+        ColumnarValue::Array(right),
+    ])?;
+    match result {
+        ColumnarValue::Array(array_ref) => Ok(array_ref),
+        _ => Err(DataFusionError::Execution(
+            "string_concat return type should be Array, but Scalar found".to_string(),
+        )),
+    }

Review Comment:
   I think you could use `ColumnarValue::into_array` here rather than error
   
   https://github.com/apache/arrow-datafusion/blob/41b4e491663029f653e491b110d0b5e74d08a0b6/datafusion/expr/src/columnar_value.rs#L45-L50
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org