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(stream): temporal join support pk prefix join condition #10627

Merged
merged 8 commits into from
Jul 12, 2023

Conversation

chenzl25
Copy link
Contributor

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

What's changed and what's your intention?

  • Loose temporal join restrictions to allow join condition containing only the prefix of the right table's pk. Tracking: Process time temporal join #8123
  • This is a necessary step to support index selection for the temporal join in the future.

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

Documentation

  • My PR contains 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

@codecov
Copy link

codecov bot commented Jul 3, 2023

Codecov Report

Merging #10627 (18367fb) into main (c4160d7) will decrease coverage by 0.02%.
The diff coverage is 39.00%.

@@            Coverage Diff             @@
##             main   #10627      +/-   ##
==========================================
- Coverage   70.23%   70.22%   -0.02%     
==========================================
  Files        1285     1285              
  Lines      219704   219836     +132     
==========================================
+ Hits       154311   154371      +60     
- Misses      65393    65465      +72     
Flag Coverage Δ
rust 70.22% <39.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...nd/src/optimizer/plan_node/stream_temporal_join.rs 63.63% <ø> (-0.28%) ⬇️
src/stream/src/executor/temporal_join.rs 0.00% <0.00%> (ø)
src/stream/src/from_proto/temporal_join.rs 0.00% <0.00%> (ø)
...ntend/src/optimizer/plan_node/eq_join_predicate.rs 84.82% <96.77%> (+2.08%) ⬆️
...c/frontend/src/optimizer/plan_node/logical_join.rs 90.45% <100.00%> (+0.18%) ⬆️

... and 1 file with indirect coverage changes

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

@chenzl25 chenzl25 requested review from BugenZhao, xxchan and fuyufjh July 5, 2023 06:36
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.

The rest LGTM

src/frontend/src/optimizer/plan_node/logical_join.rs Outdated Show resolved Hide resolved
@@ -271,40 +386,42 @@ impl<S: StateStore, const T: JoinTypePrimitive> TemporalJoinExecutor<S, T> {
.set(self.right_table.cache.len() as i64);
match msg? {
InternalMessage::Chunk(chunk) => {
// Compact chunk, otherwise the following keys and chunk rows might fail to zip.
let chunk = chunk.compact();
Copy link
Member

Choose a reason for hiding this comment

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

Why? chunk.rows() should only returns visible rows

Copy link
Contributor Author

@chenzl25 chenzl25 Jul 5, 2023

Choose a reason for hiding this comment

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

let keys = K::build(&self.left_join_keys, chunk.data_chunk())?;
for ((op, left_row), key) in chunk.rows().zip_eq_debug(keys.into_iter()) {

We need to align keys with rows, but keys can't handle visible ops. Previously I also thought like you, but encounter this issue. Stream hash joins work around by compact as well.

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 we can filter out the empty keys for now (but the assumption is really easy to break, we need further encapsulation for this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this pattern is quite common(HashJoin, TopN). We can do a refactor for this pattern later.

Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

LGTM

@chenzl25 chenzl25 added this pull request to the merge queue Jul 12, 2023
Merged via the queue into main with commit ae9803d Jul 12, 2023
@chenzl25 chenzl25 deleted the dylan/temporal_join_support_pk_prefix_join_condition branch July 12, 2023 07: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.

4 participants