From da25095996b9b66a99a49e2cd5567c1a08f8c6aa Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Tue, 10 Oct 2023 17:10:17 -0700 Subject: [PATCH] Fix join with nulls (#4801) For auto join sorts make sure nulls are max or last. Closes #4800 --- runtime/op/join/join.go | 4 ++-- runtime/op/join/ztests/auto-sort.yaml | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/op/join/join.go b/runtime/op/join/join.go index d4238a93b4..e115d3abd5 100644 --- a/runtime/op/join/join.go +++ b/runtime/op/join/join.go @@ -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 } diff --git a/runtime/op/join/ztests/auto-sort.yaml b/runtime/op/join/ztests/auto-sort.yaml index e6a5f76ba3..56c17167e9 100644 --- a/runtime/op/join/ztests/auto-sort.yaml +++ b/runtime/op/join/ztests/auto-sort.yaml @@ -14,30 +14,38 @@ script: | inputs: - name: a.zson data: | + {a:null(int64)} {a:1} {a:2} - 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)}