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(frontend): implement WITH ORDINALITY clause #12273

Merged
merged 10 commits into from
Sep 14, 2023
Merged

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Sep 13, 2023

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

What's changed and what's your intention?

fix #12043 fix #11167 (duplicate issues)

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

May refer to test cases, and https://www.postgresql.org/docs/current/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS

@xxchan
Copy link
Member Author

xxchan commented Sep 13, 2023

@lmatz @chenzl25 We may add the user's full query in tests if necessary/possible

@fuyufjh
Copy link
Member

fuyufjh commented Sep 13, 2023

@lmatz @chenzl25 We may add the user's full query in tests if necessary/possible

AFAIK, the users didn't tell us the specific query.

create materialized view mv as select * from t cross join unnest(t.arr) WITH ORDINALITY AS x(elts, num);

statement ok
insert into t values (Array['a','b', 'c']), (Array['d','e']);
Copy link
Member

Choose a reason for hiding this comment

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

What if update Array['a','b', 'c'] to Array['a', 'c']?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. Actually I'm not sure what's your intention 🤔

Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

Rest LGTM

};
Ok(LogicalValues::create(vec![vec![expr]], schema, self.ctx()))
if with_ordinality {
todo!()
Copy link
Member

Choose a reason for hiding this comment

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

ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. This is actually a different issue (scalar function WITH ORDINALITY)

@TennyZhuang
Copy link
Contributor

Seems related #12204

Copy link
Contributor

@chenzl25 chenzl25 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!

e2e_test/batch/basic/unnest.slt.part Outdated Show resolved Hide resolved
let projected_row_id = InputRef::new(0, DataType::Int64).into();
let ordinality = FunctionCall::new(
ExprType::Add,
vec![projected_row_id, ExprImpl::literal_bigint(1)],
Copy link
Contributor

Choose a reason for hiding this comment

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

Since projected_row_id starts from 0, we need to add one to align with with ordinality

@xxchan xxchan enabled auto-merge September 14, 2023 04:18
@xxchan xxchan added this pull request to the merge queue Sep 14, 2023
@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Merging #12273 (da6c2cb) into main (3c1f52f) will increase coverage by 0.00%.
Report is 11 commits behind head on main.
The diff coverage is 67.69%.

@@           Coverage Diff           @@
##             main   #12273   +/-   ##
=======================================
  Coverage   69.67%   69.68%           
=======================================
  Files        1410     1410           
  Lines      236128   236215   +87     
=======================================
+ Hits       164526   164599   +73     
- Misses      71602    71616   +14     
Flag Coverage Δ
rust 69.68% <67.69%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/sqlparser/src/keywords.rs 100.00% <ø> (ø)
src/frontend/src/binder/relation/table_function.rs 57.14% <26.19%> (-25.00%) ⬇️
...timizer/rule/table_function_to_project_set_rule.rs 64.91% <75.00%> (+12.82%) ⬆️
.../src/optimizer/plan_node/logical_table_function.rs 73.52% <80.00%> (+14.70%) ⬆️
src/frontend/src/binder/relation/mod.rs 71.56% <81.81%> (+0.32%) ⬆️
src/frontend/src/binder/relation/join.rs 93.71% <100.00%> (ø)
src/frontend/src/planner/relation.rs 82.50% <100.00%> (+1.13%) ⬆️
src/sqlparser/src/ast/query.rs 88.44% <100.00%> (+0.27%) ⬆️
src/sqlparser/src/parser.rs 86.50% <100.00%> (+0.02%) ⬆️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 14, 2023
@xxchan xxchan added this pull request to the merge queue Sep 14, 2023
Merged via the queue into main with commit 7b23eb2 Sep 14, 2023
10 of 11 checks passed
@xxchan xxchan deleted the xxchan/with-ordinality branch September 14, 2023 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support WITH ORDINALITY AS with table functions Support WITH ORDINALITY clause
4 participants