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

optimizer: Improve stream key derivation for stream join #12820

Closed
fuyufjh opened this issue Oct 12, 2023 · 1 comment · Fixed by #12831
Closed

optimizer: Improve stream key derivation for stream join #12820

fuyufjh opened this issue Oct 12, 2023 · 1 comment · Fixed by #12831
Assignees
Milestone

Comments

@fuyufjh
Copy link
Member

fuyufjh commented Oct 12, 2023

If one side is N-to-1 mapping (such as joining a dimension table with its PK), then both the join key and stream key from that side does not need to be included in output stream key.

For example:

Assuming

PK of orders = [order.id]
PK of customers = [customer.id]

Then for this query

select * from orders left join customers on orders.custumer_id = customers.id

Because orders.custumer_id = customers.id is an N-to-1 mapping (from left to right), the Join's (output) stream key can be [orders.id], instead of [orders.id, customers.id] or [orders.id, customers.id, orders.custumer_id].

@fuyufjh
Copy link
Member Author

fuyufjh commented Oct 13, 2023

Thanks to @st1page for the correction, I was wrong. The join key must be included the stream key under any circumstance.

Taking fact table-dimension table join as an example

select * from orders left join customers on orders.customer_id = customers.id

If orders.customer_id is updated, it would generate a pair of U- and U+, which then becomes - and + and sent to 2 actors of the next fragment, saying, a Materialize.

Only by including the customer_id in the stream key can it prevent the + from arriving at Materialize before -, causing a sanity check panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants