Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support array containment @>, <@ (#13180) #13253

Merged
merged 6 commits into from
Nov 7, 2023

Conversation

thexiay
Copy link
Contributor

@thexiay thexiay commented Nov 5, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@wangrunji0408 wangrunji0408 requested review from wangrunji0408 and xiangjinwu and removed request for wangrunji0408 November 5, 2023 09:50
Copy link
Contributor

@xiangjinwu xiangjinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Thank you!

Btw there is a darker side of PostgreSQL:

test=# select array[[2, 3], [4, 5]] @> array[3, 4];
 ?column? 
----------
 t
(1 row)

My suggestions is to merge the current matching-dimension version first, and consider this as an optional add-on. Although we do have ListRef::flatten (instead of ListRef::iter) and DataType::unnest_list (instead of DataType::as_list), the type handling logic may still be more complicated.

src/frontend/src/binder/expr/function.rs Outdated Show resolved Hide resolved
src/frontend/src/binder/expr/binary_op.rs Outdated Show resolved Hide resolved
src/frontend/src/binder/expr/binary_op.rs Outdated Show resolved Hide resolved
src/expr/impl/src/scalar/array_contain.rs Outdated Show resolved Hide resolved
src/tests/regress/data/sql/arrays.sql Outdated Show resolved Hide resolved
Copy link
Contributor

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@thexiay
Copy link
Contributor Author

thexiay commented Nov 6, 2023

Generally LGTM. Thank you!

Btw there is a darker side of PostgreSQL:

test=# select array[[2, 3], [4, 5]] @> array[3, 4];
 ?column? 
----------
 t
(1 row)

My suggestions is to merge the current matching-dimension version first, and consider this as an optional add-on. Although we do have ListRef::flatten (instead of ListRef::iter) and DataType::unnest_list (instead of DataType::as_list), the type handling logic may still be more complicated.

ok,I will consider this situation.

@xiangjinwu
Copy link
Contributor

ok,I will consider this situation.

To clarify, I am suggesting us to fix the e2e, skip the regress test, merge this PR of matching-dimension arrays, and then handle the flatten/unnest case in a separate PR (optional).

@thexiay
Copy link
Contributor Author

thexiay commented Nov 6, 2023

ok,I will consider this situation.

To clarify, I am suggesting us to fix the e2e, skip the regress test, merge this PR of matching-dimension arrays, and then handle the flatten/unnest case in a separate PR (optional).

ok,I will fix it later. And Launch two issues to track this unfinished work

  1. handle the flatten/unnest case for array_contains
  2. (optional) reuse the same ExprType (if needed) for jsonb contains or array contains or any other range contains(not impelemented)

Copy link
Contributor

@TennyZhuang TennyZhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM

@thexiay
Copy link
Contributor Author

thexiay commented Nov 6, 2023

Track the handling of nested types here: #13274

@xiangjinwu xiangjinwu added this pull request to the merge queue Nov 7, 2023
Merged via the queue into risingwavelabs:main with commit 6fbb271 Nov 7, 2023
27 of 28 checks passed
Comment on lines +842 to +845
("array_contains", raw_call(ExprType::ArrayContains)),
("arraycontains", raw_call(ExprType::ArrayContains)),
("array_contained", raw_call(ExprType::ArrayContained)),
("arraycontained", raw_call(ExprType::ArrayContained)),
Copy link
Contributor

@stdrc stdrc Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that these functions are not provided by PG, do we really need to expose these functions to our users? BTW, even if we decide to expose them, arraycontains and arraycontained seem unnecessary and for array_contains and array_contained we need to think about potential inalignment with PG if PG adds these functions with different signatures in the future.

@xiangjinwu xiangjinwu added the user-facing-changes Contains changes that are visible to users label Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants