You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jackwener (via GitHub)" <gi...@apache.org> on 2023/04/06 14:21:12 UTC

[GitHub] [arrow-datafusion] jackwener opened a new pull request, #5896: fix: like and ilike not supported for LargeUtf8

jackwener opened a new pull request, #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5893.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


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


[GitHub] [arrow-datafusion] SimonSchneider commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "SimonSchneider (via GitHub)" <gi...@apache.org>.
SimonSchneider commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160046859


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   I guess a more comprehensive test would be 
   ```
   select arrow_cast('foobar', 'LargeUtf8') like '%oba%';
   —-
   true
   
   
   select arrow_cast('FooBar', 'LargeUtf8') I like '%oba%';
   —-
   true
   ```
   
   
   https://www.postgresql.org/docs/7.3/functions-matching.html#:~:text=The%20keyword%20ILIKE%20can%20be,and%20~~*%20corresponds%20to%20ILIKE%20.



##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   I guess a more comprehensive test would be 
   ```
   select arrow_cast('foobar', 'LargeUtf8') like '%oba%';
   —-
   true
   
   
   select arrow_cast('FooBar', 'LargeUtf8') ilike '%oba%';
   —-
   true
   ```
   
   
   https://www.postgresql.org/docs/7.3/functions-matching.html#:~:text=The%20keyword%20ILIKE%20can%20be,and%20~~*%20corresponds%20to%20ILIKE%20.



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


[GitHub] [arrow-datafusion] jackwener commented on pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#issuecomment-1501445960

   if there isn't new review, I prepare to merge this PR in the tomorrow due to some review already in this PR.


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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160030626


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   Sorry, it's not clear.
   This test cover issue in #5893



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


[GitHub] [arrow-datafusion] alamb commented on pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#issuecomment-1502067431

   I agree adding additional tests for unrelated functionality (e.g. general support for LargeUtf8) would be best done in some other PR


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


[GitHub] [arrow-datafusion] SimonSchneider commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "SimonSchneider (via GitHub)" <gi...@apache.org>.
SimonSchneider commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160046859


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   I guess a more comprehensive test would be 
   ```
   select arrow_cast('foobar', 'LargeUtf8') like '%oba%';
   —-
   true
   
   
   select arrow_cast('FooBar', 'LargeUtf8') like '%oba%';
   —-
   true
   ```
   
   
   https://www.postgresql.org/docs/7.3/functions-matching.html#:~:text=The%20keyword%20ILIKE%20can%20be,and%20~~*%20corresponds%20to%20ILIKE%20.



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


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160022312


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   > It's a case of issue
   
   Sorry, I still didn't get it, you mean inner value of Utf8("foo") not the same as inner value LargeUtf8("foo")?



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


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1159973551


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   cool, btw, why is it like '%foo%', not == 'foo' ?



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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160000732


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   It's a case of issue



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


[GitHub] [arrow-datafusion] mingmwang commented on pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "mingmwang (via GitHub)" <gi...@apache.org>.
mingmwang commented on PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#issuecomment-1499951860

   ```rust
   
   #[tokio::test]
   async fn sort_on_window_null_string() -> Result<()> {
       let d1: DictionaryArray<Int32Type> =
           vec![Some("one"), None, Some("three")].into_iter().collect();
       let d2: StringArray = vec![Some("ONE"), None, Some("THREE")].into_iter().collect();
       let d3: LargeStringArray =
           vec![Some("One"), None, Some("Three")].into_iter().collect();
   
       let batch = RecordBatch::try_from_iter(vec![
           ("d1", Arc::new(d1) as ArrayRef),
           ("d2", Arc::new(d2) as ArrayRef),
           ("d3", Arc::new(d3) as ArrayRef),
       ])
       .unwrap();
   
       let ctx = SessionContext::with_config(SessionConfig::new().with_target_partitions(1));
       ctx.register_batch("test", batch)?;
   
       let sql =
           "SELECT d1, row_number() OVER (partition by d1) as rn1 FROM test order by d1 asc";
   
       let actual = execute_to_batches(&ctx, sql).await;
       // NULLS LAST
       let expected = vec![
           "+-------+-----+",
           "| d1    | rn1 |",
           "+-------+-----+",
           "| one   | 1   |",
           "| three | 1   |",
           "|       | 1   |",
           "+-------+-----+",
       ];
       assert_batches_eq!(expected, &actual);
   
       let sql =
           "SELECT d2, row_number() OVER (partition by d2) as rn1 FROM test ORDER BY d2 asc";
       let actual = execute_to_batches(&ctx, sql).await;
       // NULLS LAST
       let expected = vec![
           "+-------+-----+",
           "| d2    | rn1 |",
           "+-------+-----+",
           "| ONE   | 1   |",
           "| THREE | 1   |",
           "|       | 1   |",
           "+-------+-----+",
       ];
       assert_batches_eq!(expected, &actual);
   
       let sql =
           "SELECT d2, row_number() OVER (partition by d2 order by d2 desc) as rn1 FROM test ORDER BY d2 desc";
   
       let actual = execute_to_batches(&ctx, sql).await;
       // NULLS FIRST
       let expected = vec![
           "+-------+-----+",
           "| d2    | rn1 |",
           "+-------+-----+",
           "|       | 1   |",
           "| THREE | 1   |",
           "| ONE   | 1   |",
           "+-------+-----+",
       ];
       assert_batches_eq!(expected, &actual);
   
       // FIXME sort on LargeUtf8 String has bug.
       // let sql =
       //     "SELECT d3, row_number() OVER (partition by d3) as rn1 FROM test";
       // let actual = execute_to_batches(&ctx, sql).await;
       // let expected = vec![
       //     "+-------+-----+",
       //     "| d3    | rn1 |",
       //     "+-------+-----+",
       //     "|       | 1   |",
       //     "| One   | 1   |",
       //     "| Three | 1   |",
       //     "+-------+-----+",
       // ];
       // assert_batches_eq!(expected, &actual);
   
       Ok(())
   }
   ```


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


[GitHub] [arrow-datafusion] jackwener merged pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener merged PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896


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


[GitHub] [arrow-datafusion] jackwener commented on pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#issuecomment-1500913876

   @mingmwang Can we add it in following PR?
   


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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5896: fix: like and ilike not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1159870304


##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -233,7 +233,9 @@ macro_rules! compute_utf8_op_scalar {
             .as_any()
             .downcast_ref::<$DT>()
             .expect("compute_op failed to downcast left side array");
-        if let ScalarValue::Utf8(Some(string_value)) = $RIGHT {
+        if let ScalarValue::Utf8(Some(string_value))
+        | ScalarValue::LargeUtf8(Some(string_value)) = $RIGHT
+        {

Review Comment:
   I'm not sure if we should add 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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160145881


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   Another test that would be great to add would be to compare columns as well as constants (as that is the other binary expr codepath)
   
   Something like
   
   ```sql
   create table t as values 
     (arrow_cast('Foo', 'LargeUtf8') '%f'), 
     (arrow_cast('Bar', 'LargeUtf8') 'B%');
   
   select column1 like column2 from t;
   select column1 ilike column2 from t;
   select column1 not like column2 from t;
   select column1 not ilike column2 from t;
   ```



##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -233,7 +233,9 @@ macro_rules! compute_utf8_op_scalar {
             .as_any()
             .downcast_ref::<$DT>()
             .expect("compute_op failed to downcast left side array");
-        if let ScalarValue::Utf8(Some(string_value)) = $RIGHT {
+        if let ScalarValue::Utf8(Some(string_value))
+        | ScalarValue::LargeUtf8(Some(string_value)) = $RIGHT
+        {

Review Comment:
   I definitely think we should add this -- it is required to evaluate the like expression with a scalar.



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


[GitHub] [arrow-datafusion] mingmwang commented on pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "mingmwang (via GitHub)" <gi...@apache.org>.
mingmwang commented on PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#issuecomment-1499948957

   I remember there are some other issues with `LargeUtf8`, for example, can not `Sort`
   Maybe we need another unit test suite to cover all different Exprs with `LargeUtf8`.


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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160030626


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   Sorry, it's not clear.😂
   This test cover issue in #5893
   English isn't my native language, so I subconsciously thought `issue` is `github issue `



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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5896: fix: binaryExpr not supported for LargeUtf8

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5896:
URL: https://github.com/apache/arrow-datafusion/pull/5896#discussion_r1160030626


##########
datafusion/core/tests/sqllogictests/test_files/select.slt:
##########
@@ -230,3 +230,10 @@ select CASE
 END;
 ----
 2
+
+# like and ilike for LargeUtf8
+# issue: https://github.com/apache/arrow-datafusion/issues/5893
+query B
+select arrow_cast('foo', 'LargeUtf8') like '%foo%';

Review Comment:
   Sorry, it's not clear.😂
   This test cover issue in #5893



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