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

fix: when target is table, the sink downstream pk is not set #19515

Merged
merged 9 commits into from
Nov 22, 2024

Conversation

st1page
Copy link
Contributor

@st1page st1page commented Nov 21, 2024

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

What's changed and what's your intention?

image

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • 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

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.


statement ok
SET STREAMING_PARALLELISM TO 3;

statement ok
create sink s_simple_1 into m_simple as select v1, v2 from t_simple;
create sink s_simple_1 into m_simple as select v1, v2 from t_simple with (type = 'append-only');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change the query because if there is primary key, the original sink plan will be

dev=> explain create sink s_simple_1 into m_simple as select v1, v2 from t_simple;
;
                                                QUERY PLAN                                                
----------------------------------------------------------------------------------------------------------
 StreamProject { exprs: [t_simple.v1, t_simple.v2] }
 └─StreamSink { type: upsert, columns: [v1, v2, t_simple._row_id(hidden)], downstream_pk: [t_simple.v1] }
   └─StreamExchange { dist: HashShard(t_simple.v1) }
     └─StreamTableScan { table: t_simple, columns: [v1, v2, _row_id] }
(4 rows)

@graphite-app graphite-app bot requested a review from a team November 21, 2024 11:30
Comment on lines +277 to +286
let target_table_mapping = target_table_mapping.unwrap();

t.pk()
.iter()
.map(|c| {
target_table_mapping[c.column_index].ok_or(
ErrorCode::SinkError(Box::new(Error::new(ErrorKind::InvalidInput,
"When using non append only sink into table, the primary key of the table must be included in the sink result.".to_string()
))).into())})
.try_collect::<_, _, RwError>()?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

main changes it to get the down stream pk here, and to get it, the target_table_mapping is needed

@st1page st1page added this pull request to the merge queue Nov 22, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 22, 2024
@st1page st1page added this pull request to the merge queue Nov 22, 2024
Merged via the queue into main with commit fd5d091 Nov 22, 2024
30 of 31 checks passed
@st1page st1page deleted the sts/fix_sink_into_table_sink_compaction branch November 22, 2024 10:15
xxchan pushed a commit that referenced this pull request Nov 27, 2024
cyliu0 pushed a commit to cyliu0/risingwave that referenced this pull request Nov 30, 2024
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.

2 participants