Reset the 'curIdxOff2KeyOff', 'curNotUsedIndexCols' and 'curNotUsedColLens' by innerKeys and idxCols * For each idxCols, If column can be found in innerKeys save offset of innerKeys in 'curIdxOff2KeyOff' Else, save -1 in 'curIdxOff2KeyOff' */ For example, innerKeys[t1.a, t1.sum_b, t1.c], idxCo
( sctx planctx.PlanContext, indexJoinInfo *indexJoinPathInfo, idxCols []*expression.Column, colLens []int)
| 483 | // For example, innerKeys[t1.a, t1.sum_b, t1.c], idxCols [a, b, c] |
| 484 | // 'curIdxOff2KeyOff' = [0, -1, 2] |
| 485 | func indexJoinPathTmpInit( |
| 486 | sctx planctx.PlanContext, |
| 487 | indexJoinInfo *indexJoinPathInfo, |
| 488 | idxCols []*expression.Column, |
| 489 | colLens []int) *indexJoinPathTmp { |
| 490 | tmpSchema := expression.NewSchema(indexJoinInfo.innerJoinKeys...) |
| 491 | buildTmp := new(indexJoinPathTmp) |
| 492 | buildTmp.curIdxOff2KeyOff = make([]int, len(idxCols)) |
| 493 | buildTmp.curNotUsedIndexCols = make([]*expression.Column, 0, len(idxCols)) |
| 494 | buildTmp.curNotUsedColLens = make([]int, 0, len(idxCols)) |
| 495 | for i, idxCol := range idxCols { |
| 496 | buildTmp.curIdxOff2KeyOff[i] = tmpSchema.ColumnIndex(idxCol) |
| 497 | if buildTmp.curIdxOff2KeyOff[i] >= 0 { |
| 498 | // Don't use the join columns if their collations are unmatched and the new collation is enabled. |
| 499 | if collate.NewCollationEnabled() && types.IsString(idxCol.RetType.GetType()) && types.IsString(indexJoinInfo.outerJoinKeys[buildTmp.curIdxOff2KeyOff[i]].RetType.GetType()) { |
| 500 | et, err := expression.CheckAndDeriveCollationFromExprs(sctx.GetExprCtx(), "equal", types.ETInt, idxCol, indexJoinInfo.outerJoinKeys[buildTmp.curIdxOff2KeyOff[i]]) |
| 501 | if err != nil { |
| 502 | logutil.BgLogger().Error("Unexpected error happened during constructing index join", zap.Stack("stack")) |
| 503 | } |
| 504 | if !collate.CompatibleCollate(idxCol.GetStaticType().GetCollate(), et.Collation) { |
| 505 | buildTmp.curIdxOff2KeyOff[i] = -1 |
| 506 | } |
| 507 | } |
| 508 | continue |
| 509 | } |
| 510 | buildTmp.curNotUsedIndexCols = append(buildTmp.curNotUsedIndexCols, idxCol) |
| 511 | buildTmp.curNotUsedColLens = append(buildTmp.curNotUsedColLens, colLens[i]) |
| 512 | } |
| 513 | return buildTmp |
| 514 | } |
| 515 | |
| 516 | // indexJoinPathFindUsefulEQIn analyzes the PushedDownConds held by inner child and split them to three parts. |
| 517 | // usefulEqOrInFilters is the continuous eq/in conditions on current unused index columns. |
no test coverage detected