-
Notifications
You must be signed in to change notification settings - Fork 707
feat(streaming): support union all for streaming query #6397
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d250b05
support union all for streaming query
chenzl25 593fcba
Merge branch 'main' into dylan/support_streaming_union
chenzl25 f6279e7
fmt
chenzl25 bc5c6d1
add stream_dist_plan for union
chenzl25 34d67fa
resolve conflict
chenzl25 85a8724
Merge branch 'main' into dylan/support_streaming_union
mergify[bot] 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 hidden or 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,57 @@ | ||
| statement ok | ||
| SET RW_IMPLICIT_FLUSH TO true; | ||
|
|
||
| statement ok | ||
| create table t1 (v1 int, v2 int); | ||
|
|
||
| statement ok | ||
| create table t2 (v1 int, v3 int); | ||
|
|
||
| statement ok | ||
| create materialized view v as select * from t1 union all select * from t2; | ||
|
|
||
| query II | ||
| select * from v; | ||
| ---- | ||
|
|
||
| statement ok | ||
| insert into t1 values(1, 2); | ||
|
|
||
| query II | ||
| select * from v; | ||
| ---- | ||
| 1 2 | ||
|
|
||
| statement ok | ||
| insert into t2 values(1, 2); | ||
|
|
||
|
|
||
| query II | ||
| select * from v; | ||
| ---- | ||
| 1 2 | ||
| 1 2 | ||
|
|
||
| statement ok | ||
| delete from t1 where v1 = 1; | ||
|
|
||
| query II | ||
| select * from v; | ||
| ---- | ||
| 1 2 | ||
|
|
||
| statement ok | ||
| delete from t2 where v1 = 1; | ||
|
|
||
| query II | ||
| select * from v; | ||
| ---- | ||
|
|
||
| statement ok | ||
| drop materialized view v; | ||
|
|
||
| statement ok | ||
| drop table t1; | ||
|
|
||
| statement ok | ||
| drop table t2; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -385,3 +385,29 @@ impl<PlanRef: GenericPlanRef> GenericPlanNode for Expand<PlanRef> { | |
| self.input.ctx() | ||
| } | ||
| } | ||
|
|
||
| impl<PlanRef: GenericPlanRef> GenericPlanNode for Union<PlanRef> { | ||
| fn schema(&self) -> Schema { | ||
| self.inputs[0].schema().clone() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add the hidden column here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not. The input schema already contains the hidden column and we can find them by |
||
| } | ||
|
|
||
| fn logical_pk(&self) -> Option<Vec<usize>> { | ||
| // Union all its inputs pks + source_col if exists | ||
| let mut pk_indices = vec![]; | ||
| for input in &self.inputs { | ||
| for pk in input.logical_pk() { | ||
| if !pk_indices.contains(pk) { | ||
| pk_indices.push(*pk); | ||
| } | ||
| } | ||
| } | ||
| if let Some(source_col) = self.source_col { | ||
| pk_indices.push(source_col) | ||
| } | ||
| Some(pk_indices) | ||
| } | ||
|
|
||
| fn ctx(&self) -> OptimizerContextRef { | ||
| self.inputs[0].ctx() | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.