-
Notifications
You must be signed in to change notification settings - Fork 613
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(streaming): plan asof join #18683
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0ff2609
iinit
yuhao-su 8cc75e2
Merge branch 'main' of github.com:singularity-data/risingwave into yu…
yuhao-su d501577
stream node
yuhao-su ca0ea76
Merge branch 'main' of github.com:singularity-data/risingwave into yu…
yuhao-su 4153f2b
e2e
yuhao-su 40b0e8f
fix
yuhao-su 7cf0c0c
Merge branch 'main' of github.com:singularity-data/risingwave into yu…
yuhao-su 45fe957
fmt
yuhao-su f5abfdd
try bump node
yuhao-su 878d482
revert bump
yuhao-su bc8991f
improve
yuhao-su File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/frontend/src/optimizer/plan_node/stream_join_common.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2024 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use itertools::Itertools; | ||
use risingwave_common::util::iter_util::ZipEqFast; | ||
use risingwave_pb::plan_common::JoinType; | ||
|
||
use super::{generic, EqJoinPredicate}; | ||
use crate::optimizer::property::Distribution; | ||
use crate::utils::ColIndexMappingRewriteExt; | ||
use crate::PlanRef; | ||
|
||
pub struct StreamJoinCommon; | ||
|
||
impl StreamJoinCommon { | ||
pub(super) fn get_dist_key_in_join_key( | ||
left_dk_indices: &[usize], | ||
right_dk_indices: &[usize], | ||
eq_join_predicate: &EqJoinPredicate, | ||
) -> Vec<usize> { | ||
let left_jk_indices = eq_join_predicate.left_eq_indexes(); | ||
let right_jk_indices = &eq_join_predicate.right_eq_indexes(); | ||
assert_eq!(left_jk_indices.len(), right_jk_indices.len()); | ||
let mut dk_indices_in_jk = vec![]; | ||
for (l_dk_idx, r_dk_idx) in left_dk_indices.iter().zip_eq_fast(right_dk_indices.iter()) { | ||
for dk_idx_in_jk in left_jk_indices.iter().positions(|idx| idx == l_dk_idx) { | ||
if right_jk_indices[dk_idx_in_jk] == *r_dk_idx { | ||
dk_indices_in_jk.push(dk_idx_in_jk); | ||
break; | ||
} | ||
} | ||
} | ||
assert_eq!(dk_indices_in_jk.len(), left_dk_indices.len()); | ||
dk_indices_in_jk | ||
} | ||
|
||
pub(super) fn derive_dist( | ||
left: &Distribution, | ||
right: &Distribution, | ||
logical: &generic::Join<PlanRef>, | ||
) -> Distribution { | ||
match (left, right) { | ||
(Distribution::Single, Distribution::Single) => Distribution::Single, | ||
(Distribution::HashShard(_), Distribution::HashShard(_)) => { | ||
// we can not derive the hash distribution from the side where outer join can | ||
// generate a NULL row | ||
match logical.join_type { | ||
JoinType::Unspecified => { | ||
unreachable!() | ||
} | ||
JoinType::FullOuter => Distribution::SomeShard, | ||
JoinType::Inner | ||
| JoinType::LeftOuter | ||
| JoinType::LeftSemi | ||
| JoinType::LeftAnti | ||
| JoinType::AsofInner | ||
| JoinType::AsofLeftOuter => { | ||
let l2o = logical | ||
.l2i_col_mapping() | ||
.composite(&logical.i2o_col_mapping()); | ||
l2o.rewrite_provided_distribution(left) | ||
} | ||
JoinType::RightSemi | JoinType::RightAnti | JoinType::RightOuter => { | ||
let r2o = logical | ||
.r2i_col_mapping() | ||
.composite(&logical.i2o_col_mapping()); | ||
r2o.rewrite_provided_distribution(right) | ||
} | ||
} | ||
} | ||
(_, _) => unreachable!( | ||
"suspicious distribution: left: {:?}, right: {:?}", | ||
left, right | ||
), | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh seems a module is enough.