github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/testutils/testexpr/test_expr.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 testexpr 12 13 import ( 14 "github.com/cockroachdb/cockroach/pkg/sql/opt" 15 "github.com/cockroachdb/cockroach/pkg/sql/opt/memo" 16 "github.com/cockroachdb/cockroach/pkg/sql/opt/props" 17 "github.com/cockroachdb/cockroach/pkg/sql/opt/props/physical" 18 ) 19 20 // Instance is a dummy RelExpr that contains various properties that can be 21 // extracted via that interface. It can be initialized with whatever subset of 22 // fields are required for the particular test; for example: 23 // 24 // e := &testexpr.Instance{ 25 // Rel: &props.Relational{...}, 26 // Provided: &physical.Provided{...}, 27 // } 28 // 29 type Instance struct { 30 Rel *props.Relational 31 Required *physical.Required 32 Provided *physical.Provided 33 Priv interface{} 34 35 // We embed a RelExpr to provide implementation for the unexported methods of 36 // RelExpr. This should not be initialized (resulting in a panic if any of 37 // those methods are called). 38 memo.RelExpr 39 } 40 41 var _ memo.RelExpr = &Instance{} 42 43 // Relational is part of the RelExpr interface. 44 func (e *Instance) Relational() *props.Relational { return e.Rel } 45 46 // RequiredPhysical is part of the RelExpr interface. 47 func (e *Instance) RequiredPhysical() *physical.Required { return e.Required } 48 49 // ProvidedPhysical is part of the RelExpr interface. 50 func (e *Instance) ProvidedPhysical() *physical.Provided { return e.Provided } 51 52 // Private is part of the RelExpr interface. 53 func (e *Instance) Private() interface{} { return e.Priv } 54 55 // Op is part of the RelExpr interface. 56 func (e *Instance) Op() opt.Operator { 57 // We implement this to keep checkExpr happy. It shouldn't match a real 58 // operator. 59 return 0xFFFF 60 } 61 62 // The rest of the methods are not implemented. Fields can be added to Instance 63 // to implement these as necessary. 64 65 // ChildCount is part of the RelExpr interface. 66 func (e *Instance) ChildCount() int { panic("not implemented") } 67 68 // Child is part of the RelExpr interface. 69 func (e *Instance) Child(nth int) opt.Expr { panic("not implemented") } 70 71 // String is part of the RelExpr interface. 72 func (e *Instance) String() string { panic("not implemented") } 73 74 // SetChild is part of the RelExpr interface. 75 func (e *Instance) SetChild(nth int, child opt.Expr) { panic("not implemented") } 76 77 // Memo is part of the RelExpr interface. 78 func (e *Instance) Memo() *memo.Memo { panic("not implemented") } 79 80 // FirstExpr is part of the RelExpr interface. 81 func (e *Instance) FirstExpr() memo.RelExpr { panic("not implemented") } 82 83 // NextExpr is part of the RelExpr interface. 84 func (e *Instance) NextExpr() memo.RelExpr { panic("not implemented") } 85 86 // Cost is part of the RelExpr interface. 87 func (e *Instance) Cost() memo.Cost { panic("not implemented") }