github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/lookup_join.go (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package sql
    12  
    13  import (
    14  	"context"
    15  
    16  	"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
    17  	"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
    18  )
    19  
    20  type lookupJoinNode struct {
    21  	input planNode
    22  	table *scanNode
    23  
    24  	// joinType is either INNER or LEFT_OUTER.
    25  	joinType sqlbase.JoinType
    26  
    27  	// eqCols identifies the columns from the input which are used for the
    28  	// lookup. These correspond to a prefix of the index columns (of the index we
    29  	// are looking up into).
    30  	eqCols []int
    31  
    32  	// eqColsAreKey is true when each lookup can return at most one row.
    33  	eqColsAreKey bool
    34  
    35  	// columns are the produced columns, namely the input columns and (unless the
    36  	// join type is semi or anti join) the columns in the table scanNode.
    37  	columns sqlbase.ResultColumns
    38  
    39  	// onCond is any ON condition to be used in conjunction with the implicit
    40  	// equality condition on eqCols.
    41  	onCond tree.TypedExpr
    42  
    43  	reqOrdering ReqOrdering
    44  }
    45  
    46  // CanParallelize indicates whether the fetchers can parallelize the
    47  // batches of lookups that can be performed. As of now, this is true if
    48  // the equality columns that the lookup joiner uses form keys that
    49  // can return at most 1 row.
    50  func (lj *lookupJoinNode) CanParallelize() bool {
    51  	return lj.eqColsAreKey
    52  }
    53  
    54  func (lj *lookupJoinNode) startExec(params runParams) error {
    55  	panic("lookupJoinNode cannot be run in local mode")
    56  }
    57  
    58  func (lj *lookupJoinNode) Next(params runParams) (bool, error) {
    59  	panic("lookupJoinNode cannot be run in local mode")
    60  }
    61  
    62  func (lj *lookupJoinNode) Values() tree.Datums {
    63  	panic("lookupJoinNode cannot be run in local mode")
    64  }
    65  
    66  func (lj *lookupJoinNode) Close(ctx context.Context) {
    67  	lj.input.Close(ctx)
    68  	lj.table.Close(ctx)
    69  }