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

RFC: Add shuffle for iceberg sink #77

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

liurenjie1024
Copy link
Contributor

@liurenjie1024 liurenjie1024 commented Nov 14, 2023

@liurenjie1024 liurenjie1024 changed the title feat: Add shuffle for iceberg sink RFC: Add shuffle for iceberg sink Nov 14, 2023
rfcs/0077-iceberg-sink-shuffle.md Outdated Show resolved Hide resolved

There are two possible implementations for this feature:

1. Add a new `IcebergPartitionOperator`, which calculates the partition value of each record and adds it to the record, then asking the dispatcher executor to do hash shuffle according to the partition value. The plan is like following:
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, our common sinks also have such a Shuffle when the sink's PK doesn't match its stream key. cc. @st1page

This is very similar with this design, the only problem is that previously we didn't distinguish partition key from primary key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also cc. @xiangjinwu @tabVersion

Previously in channel #wg-new-source-ddl and risingwavelabs/risingwave#9443, we decided to use the sink property primary_key for both PK and partition key, depending on different connectors, for example,

  • Kafka upsert sink will use primary_key as partition key & PK
  • Kafka append-only sink will use primary_key as partition key only

While this RFC proposes to introduce 2 different properties: partition_key and primary_key respectively, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, our common sinks also have such a Shuffle when the sink's PK doesn't match its stream key

clarify the condition can lead to the issue: when the partition key does not contain the whole stream key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While this RFC proposes to introduce 2 different properties: partition_key and primary_key respectively, right?

In fact, by primary_key here I mean stream_key of sink's input. I think for iceberg we don't need user to specify primary_key here?

Copy link
Contributor

@st1page st1page Nov 15, 2023

Choose a reason for hiding this comment

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

The optimizer must know the downstream's partition requirements. in the past, we were just concerned about correctness issues such as "make sure the order of operations for the specific key" or "no multiple parallelisms modifying the same key, which can bring dead-lock". And in this RFC, if the downstream system has a stronger partition key to achieving better performance, we can use it as the distribution strategy and the correctness issues should be guaranteed by the downstream system.

About if the user needs to specify the primary_key/partition key in the CREATE SINK statement.

  • for kafka/redis, the primary key/partition key has not a table level's catalog or config, user must give it in CREATE SINK statement to define the behavior of the RW sink.
  • for MySQL/JDBC, current behavior is that requiring users to specify the primary_key in the CREATE SINK statement. It will be validated in the meta node if the user-specified pk is the same as the JDBC catalog. It is because currently, frontend can not query the JDBC's catalog without java runtime c.c. @StrikeW correct me if I am wrong
  • and for iceberg in this RFC, I think user do not need to specify any information in the CREATE SINK because our fe node can get the information from the downstream system's catalog

@ZENOTME
Copy link

ZENOTME commented Nov 16, 2023

There is also probability that cardinality of range only partition be ten thousands. E.g. the partition is year, month,day,hour.🤣 But the probability of this may be not high and we can solve it in risingwavelabs/risingwave#12016.

@liurenjie1024
Copy link
Contributor Author

There is also probability that cardinality of range only partition be ten thousands. E.g. the partition is year, month,day,hour.🤣 But the probability of this may be not high and we can solve it in risingwavelabs/risingwave#12016.

Yes, that's possible in an extreme case: when we are catching up with history data.

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.

None yet

5 participants