From ccee93d595f68df4dde551db32e0901767dab5e1 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Mon, 22 Nov 2021 07:16:35 +0100 Subject: [PATCH] refactor: move collation check inside canHashJoin function Signed-off-by: Andres Taylor --- go/vt/vtgate/planbuilder/querytree_transformers.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/go/vt/vtgate/planbuilder/querytree_transformers.go b/go/vt/vtgate/planbuilder/querytree_transformers.go index 1292812a200..bf371001694 100644 --- a/go/vt/vtgate/planbuilder/querytree_transformers.go +++ b/go/vt/vtgate/planbuilder/querytree_transformers.go @@ -501,11 +501,6 @@ func transformJoinPlan(ctx *planningContext, n *joinTree) (logicalPlan, error) { opCode = engine.LeftJoin } - if lhsInfo.typ.Collation != rhsInfo.typ.Collation { - // joins with different collations are not yet supported - canHashJoin = false - } - if canHashJoin { coercedType, err := evalengine.CoerceTo(lhsInfo.typ.Type, rhsInfo.typ.Type) if err != nil { @@ -580,6 +575,13 @@ func canHashJoin(ctx *planningContext, n *joinTree) (canHash bool, lhs, rhs join if !found { return } + + if colType.Collation != argType.Collation { + // joins with different collations are not yet supported + canHash = false + return + } + if colOnLeft { lhs.typ = colType rhs.typ = argType