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/05/27 11:00:44 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2627: Like, NotLike expressions work with literal `NULL`

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


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1202,6 +1202,36 @@ async fn nested_subquery() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn like_nlike_with_null_lt() {
+    let ctx = SessionContext::new();
+    let sql = "SELECT column1 like NULL from (values('a'), ('b'), (NULL)) as t";

Review Comment:
   Can you also add a test when the arguments are reversed? For example,:
   
   
   ```suggestion
       let sql = "SELECT column1 like NULL as col_null, NULL like column1 as null_col from (values('a'), ('b'), (NULL)) as t";
   ```



##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1202,6 +1202,36 @@ async fn nested_subquery() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn like_nlike_with_null_lt() {
+    let ctx = SessionContext::new();
+    let sql = "SELECT column1 like NULL from (values('a'), ('b'), (NULL)) as t";
+    let actual = execute_to_batches(&ctx, sql).await;
+    let expected = vec![
+        "+---------------------+",
+        "| t.column1 Like NULL |",
+        "+---------------------+",
+        "|                     |",
+        "|                     |",
+        "|                     |",
+        "+---------------------+",
+    ];
+    assert_batches_eq!(expected, &actual);
+
+    let sql = "SELECT column1 not like NULL from (values('a'), ('b'), (NULL)) as t";

Review Comment:
   ```suggestion
       let sql = "SELECT column1 not like NULL as col_null, NULL not like column as null_col from (values('a'), ('b'), (NULL)) as t";
   ```



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