8000 [Feat] Implement function `map_filter` by ucasfl · Pull Request #22077 · risingwavelabs/risingwave · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feat] Implement function map_filter #22077

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ucasfl
Copy link
@ucasfl ucasfl commented Jun 2, 2025

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

What's changed and what's your intention?

Implement function map_filter. Closes #20919.

Example:

dev=> select map_filter(MAP {'key1': 1, 'key2': 2, 'key3': 3}, |k, v| v > 1);
   map_filter    
-----------------
 {key2:2,key3:3}
(1 row)

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • I have checked the Release Timeline and Currently Supported Versions to determine which release branches I need to cherry-pick this PR into.

Documentation

  • My PR needs documentation updates.
Release note

test_map_filter_case(
"(map_filter:map(varchar,int4) $0:map(varchar,int4) \
(function:boolean $0:varchar $1:int4 (greater_than:boolean $1:int4 1:int4)))",
"M<T,i> M<T,i>
Copy link
Author

Choose a reason for hiding this comment

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

I have no idea why the test can't run:

failures:

---- scalar::map_filter::tests::test_map_filter_basic stdout ----

thread 'scalar::map_filter::tests::test_map_filter_basic' panicked at /Users/fenglv/ucasfl/git/risingwave/src/expr/core/src/expr/build.rs:313:18:
expect type in "M<T,i>"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    scalar::map_filter::tests::test_map_filter_basic

@ucasfl
Copy link
Author
ucasfl commented Jun 3, 2025

@lmatz Hi, could you take a look at it?

@lmatz
Copy link
Contributor
lmatz commented Jun 4, 2025

My take is that during lexer, map(varchar, int4) is decomposed into token map ( varchar,int4 and ), so that in the next parsing stage, map is parsed alone without information about its key and value. And it panics.

SCR-20250604-tkt

while struct uses <> but it also hacked a bit by using _ to concatenate
SCR-20250604-tm7
SCR-20250604-tlz

async fn test_map_filter_basic() {
test_map_filter_case(
"(map_filter:map<varchar,int4> $0:map<varchar,int4> \
(function:boolean $0:varchar $1:int4 (greater_than:boolean $1:int4 1:int4)))",
Copy link
Author
@ucasfl ucasfl Jun 5, 2025

Choose a reason for hiding this comment

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

@lmatz I'm try to make the test work, but it's not easy to support lambda function in build_from_pretty .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development
3E12

Successfully merging this pull request may close these issues.

map_filter function
2 participants
0