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): properly handled insert given misaligned source #9208

Merged
merged 17 commits into from
Apr 19, 2023

Conversation

y-wei
Copy link
Contributor

@y-wei y-wei commented Apr 15, 2023

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

What's changed and what's your intention?

insert given misaligned source is properly handled (following postgres' behavior).

Checklist For Contributors

  • 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).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

- [ ] My PR DOES NOT contain user-facing changes.

Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

`insert` follows postgres' behavior.

@y-wei y-wei requested review from BugenZhao and xxchan April 15, 2023 19:54
@y-wei y-wei changed the title feat(frontend): postgres' behavior of misaligned insert feat(frontend): properly handled insert given misaligned source Apr 15, 2023
@y-wei y-wei changed the title feat(frontend): properly handled insert given misaligned source feat(frontend): properly handled insert given misaligned source Apr 15, 2023
.0
.first()
.expect("values list should not be empty")
.len();
let values = self.bind_values(values.clone(), Some(expected_types))?;
Copy link
Contributor

Choose a reason for hiding this comment

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

since we decided to punt the NULL padding to the batch executor, perhaps the NULL padding logic in bing_values should be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, actually I just forgot to remove deprecated comments :)

@@ -119,6 +126,13 @@ impl InsertExecutor {
columns = ordered_cols
Copy link
Contributor

@broccoliSpicy broccoliSpicy Apr 17, 2023

Choose a reason for hiding this comment

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

I think there might be a segmentation fault here
ordered_cols[*idx] = columns[i].clone()
if the NULL padding is still not executed here, then the ordered_cols might not have enough capacity to hold the values at the correct index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out! I believe it's resolved now :)

Copy link
Member

@BugenZhao BugenZhao 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. Good work!

proto/batch_plan.proto Show resolved Hide resolved
proto/batch_plan.proto Outdated Show resolved Hide resolved
proto/batch_plan.proto Outdated Show resolved Hide resolved
src/frontend/planner_test/tests/testdata/insert.yaml Outdated Show resolved Hide resolved
src/frontend/src/optimizer/plan_node/logical_insert.rs Outdated Show resolved Hide resolved
src/frontend/src/binder/values.rs Outdated Show resolved Hide resolved
src/frontend/src/binder/insert.rs Outdated Show resolved Hide resolved

for (idx, expr) in &self.sorted_default_columns {
let column = Column::new(expr.eval(&dummy_chunk).await?);
ordered_columns.push((*idx, column));
Copy link
Member

Choose a reason for hiding this comment

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

I guess the performance won't be too bad if we simply use insert here, since there won't be too many columns. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that's not mainly about performance but to resolve potential insert index out of range😁

y-wei added 5 commits April 18, 2023 10:38
Signed-off-by: Clearlove <yifei.c.wei@gmail.com>
Signed-off-by: Clearlove <yifei.c.wei@gmail.com>
Signed-off-by: Clearlove <yifei.c.wei@gmail.com>
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

LGTM!

src/frontend/src/optimizer/plan_node/logical_insert.rs Outdated Show resolved Hide resolved
src/frontend/src/optimizer/plan_node/logical_insert.rs Outdated Show resolved Hide resolved
@y-wei y-wei enabled auto-merge April 19, 2023 13:13
@y-wei y-wei added this pull request to the merge queue Apr 19, 2023
Merged via the queue into risingwavelabs:main with commit 1b749ac Apr 19, 2023
@y-wei y-wei deleted the Eurekaaw/issue9036 branch April 19, 2023 14:02
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

Successfully merging this pull request may close these issues.

3 participants