cockroachdb / cockroachdb/cockroach

opt: lookup joins can fail to maintain input ordering in v22.2

Open
#113,072 2 comments 0 reactions 0 assignees View on GitHub
C-bug O-support P-3 T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

In #84689 we added the ability for lookup joins to preserve an ordering not just on input rows, but also on the looked-up rows. This feature made it into release v22.2. However, it introduced a bug - when the ordering provided by the lookup join's input expression didn't match up with that required for the lookup-join's output (as can happen when equality between columns happens to be obscured), the new logic silently truncated the provided ordering. This would cause the lookup join to guarantee no ordering, and so it could freely reorder input rows. This could cause incorrect results for execution operators that depend on input ordering, e.g. a streaming DistinctOn. The bug was introduced in v22.2, and fixed inadvertently in v23.1 by #100776. We'll backport #100776 to get the immediate fix, but this issue tracks fixing the root cause in the lookup-join ordering logic.

Jira issue: CRDB-32738

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.