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/03 15:32:58 UTC

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

WinkerDu commented on a change in pull request #2142:
URL: https://github.com/apache/arrow-datafusion/pull/2142#discussion_r841239314



##########
File path: datafusion/core/tests/sql/expr.rs
##########
@@ -280,6 +280,47 @@ async fn query_scalar_minus_array() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn test_string_concat_operator() -> Result<()> {
+    let ctx = SessionContext::new();
+    // concat 2 strings
+    let sql = "SELECT 'aa' || 'b'";
+    let actual = execute_to_batches(&ctx, sql).await;
+    let expected = vec![
+        "+-------------------------+",
+        "| Utf8(\"aa\") || Utf8(\"b\") |",
+        "+-------------------------+",
+        "| aab                     |",
+        "+-------------------------+",
+    ];
+    assert_batches_eq!(expected, &actual);
+
+    // concat 4 strings as a string concat pipe.
+    let sql = "SELECT 'aa' || 'b' || 'cc' || 'd'";
+    let expected = vec![
+        "+----------------------------------------------------+",
+        "| Utf8(\"aa\") || Utf8(\"b\") || Utf8(\"cc\") || Utf8(\"d\") |",
+        "+----------------------------------------------------+",
+        "| aabccd                                             |",
+        "+----------------------------------------------------+",
+    ];
+    let actual = execute_to_batches(&ctx, sql).await;
+    assert_batches_eq!(expected, &actual);
+
+    // concat 3 strings with one is NULL
+    let sql = "SELECT 'aa' || NULL || 'd'";
+    let expected = vec![

Review comment:
       @jackwener Thanks,  I am a bit conservative on what GP behaves like, we can discuss more on it 




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