Skip to content

Commit

Permalink
Fix join with nulls
Browse files Browse the repository at this point in the history
For auto join sorts make sure nulls are max or last.

Closes #4800
  • Loading branch information
mattnibs committed Oct 11, 2023
1 parent e0f4839 commit c6a3122
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runtime/op/join/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func New(octx *op.Context, anti, inner bool, left, right zbuf.Puller, leftKey, r
}
// Add sorts if needed.
if !leftDir.HasOrder(o) {
left, err = sort.New(octx, left, []expr.Evaluator{leftKey}, o, true)
left, err = sort.New(octx, left, []expr.Evaluator{leftKey}, o, false)
if err != nil {
return nil, err
}
}
if !rightDir.HasOrder(o) {
right, err = sort.New(octx, right, []expr.Evaluator{rightKey}, o, true)
right, err = sort.New(octx, right, []expr.Evaluator{rightKey}, o, false)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions runtime/op/join/ztests/auto-sort.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,36 @@ inputs:
data: |
{a:1}
{a:2}
{a:null(int64)}
- name: b.zson
data: |
{b:2}
{b:1}
{b:null(int64)}
outputs:
- name: stdout
data: |
{a:1}
{a:2}
{a:null(int64)}
// ===
{a:2}
{a:1}
{a:null(int64)}
// ===
{a:1}
{a:2}
{a:null(int64)}
// ===
{a:1}
{a:2}
{a:null(int64)}
// ===
{a:2}
{a:1}
{a:null(int64)}
// ===
{a:2}
{a:1}
{a:null(int64)}

0 comments on commit c6a3122

Please sign in to comment.