github.com/dolthub/go-mysql-server@v0.18.0/sql/memo/memo.og.go (about)

     1  // Code generated by optgen; DO NOT EDIT.
     2  
     3  package memo
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  
     9  	"github.com/dolthub/go-mysql-server/sql"
    10  	"github.com/dolthub/go-mysql-server/sql/plan"
    11  )
    12  
    13  type CrossJoin struct {
    14  	*JoinBase
    15  }
    16  
    17  var _ RelExpr = (*CrossJoin)(nil)
    18  var _ JoinRel = (*CrossJoin)(nil)
    19  
    20  func (r *CrossJoin) String() string {
    21  	return FormatExpr(r)
    22  }
    23  
    24  func (r *CrossJoin) JoinPrivate() *JoinBase {
    25  	return r.JoinBase
    26  }
    27  
    28  type InnerJoin struct {
    29  	*JoinBase
    30  }
    31  
    32  var _ RelExpr = (*InnerJoin)(nil)
    33  var _ JoinRel = (*InnerJoin)(nil)
    34  
    35  func (r *InnerJoin) String() string {
    36  	return FormatExpr(r)
    37  }
    38  
    39  func (r *InnerJoin) JoinPrivate() *JoinBase {
    40  	return r.JoinBase
    41  }
    42  
    43  type LeftJoin struct {
    44  	*JoinBase
    45  }
    46  
    47  var _ RelExpr = (*LeftJoin)(nil)
    48  var _ JoinRel = (*LeftJoin)(nil)
    49  
    50  func (r *LeftJoin) String() string {
    51  	return FormatExpr(r)
    52  }
    53  
    54  func (r *LeftJoin) JoinPrivate() *JoinBase {
    55  	return r.JoinBase
    56  }
    57  
    58  type SemiJoin struct {
    59  	*JoinBase
    60  }
    61  
    62  var _ RelExpr = (*SemiJoin)(nil)
    63  var _ JoinRel = (*SemiJoin)(nil)
    64  
    65  func (r *SemiJoin) String() string {
    66  	return FormatExpr(r)
    67  }
    68  
    69  func (r *SemiJoin) JoinPrivate() *JoinBase {
    70  	return r.JoinBase
    71  }
    72  
    73  type AntiJoin struct {
    74  	*JoinBase
    75  }
    76  
    77  var _ RelExpr = (*AntiJoin)(nil)
    78  var _ JoinRel = (*AntiJoin)(nil)
    79  
    80  func (r *AntiJoin) String() string {
    81  	return FormatExpr(r)
    82  }
    83  
    84  func (r *AntiJoin) JoinPrivate() *JoinBase {
    85  	return r.JoinBase
    86  }
    87  
    88  type LookupJoin struct {
    89  	*JoinBase
    90  	Lookup    *IndexScan
    91  	Injective bool
    92  }
    93  
    94  var _ RelExpr = (*LookupJoin)(nil)
    95  var _ JoinRel = (*LookupJoin)(nil)
    96  
    97  func (r *LookupJoin) String() string {
    98  	return FormatExpr(r)
    99  }
   100  
   101  func (r *LookupJoin) JoinPrivate() *JoinBase {
   102  	return r.JoinBase
   103  }
   104  
   105  type RangeHeapJoin struct {
   106  	*JoinBase
   107  	RangeHeap *RangeHeap
   108  }
   109  
   110  var _ RelExpr = (*RangeHeapJoin)(nil)
   111  var _ JoinRel = (*RangeHeapJoin)(nil)
   112  
   113  func (r *RangeHeapJoin) String() string {
   114  	return FormatExpr(r)
   115  }
   116  
   117  func (r *RangeHeapJoin) JoinPrivate() *JoinBase {
   118  	return r.JoinBase
   119  }
   120  
   121  type ConcatJoin struct {
   122  	*JoinBase
   123  	Concat []*IndexScan
   124  }
   125  
   126  var _ RelExpr = (*ConcatJoin)(nil)
   127  var _ JoinRel = (*ConcatJoin)(nil)
   128  
   129  func (r *ConcatJoin) String() string {
   130  	return FormatExpr(r)
   131  }
   132  
   133  func (r *ConcatJoin) JoinPrivate() *JoinBase {
   134  	return r.JoinBase
   135  }
   136  
   137  type HashJoin struct {
   138  	*JoinBase
   139  	RightAttrs []sql.Expression
   140  	LeftAttrs  []sql.Expression
   141  }
   142  
   143  var _ RelExpr = (*HashJoin)(nil)
   144  var _ JoinRel = (*HashJoin)(nil)
   145  
   146  func (r *HashJoin) String() string {
   147  	return FormatExpr(r)
   148  }
   149  
   150  func (r *HashJoin) JoinPrivate() *JoinBase {
   151  	return r.JoinBase
   152  }
   153  
   154  type MergeJoin struct {
   155  	*JoinBase
   156  	InnerScan *IndexScan
   157  	OuterScan *IndexScan
   158  	SwapCmp   bool
   159  	Injective bool
   160  	CmpCnt    int
   161  }
   162  
   163  var _ RelExpr = (*MergeJoin)(nil)
   164  var _ JoinRel = (*MergeJoin)(nil)
   165  
   166  func (r *MergeJoin) String() string {
   167  	return FormatExpr(r)
   168  }
   169  
   170  func (r *MergeJoin) JoinPrivate() *JoinBase {
   171  	return r.JoinBase
   172  }
   173  
   174  type FullOuterJoin struct {
   175  	*JoinBase
   176  }
   177  
   178  var _ RelExpr = (*FullOuterJoin)(nil)
   179  var _ JoinRel = (*FullOuterJoin)(nil)
   180  
   181  func (r *FullOuterJoin) String() string {
   182  	return FormatExpr(r)
   183  }
   184  
   185  func (r *FullOuterJoin) JoinPrivate() *JoinBase {
   186  	return r.JoinBase
   187  }
   188  
   189  type LateralJoin struct {
   190  	*JoinBase
   191  }
   192  
   193  var _ RelExpr = (*LateralJoin)(nil)
   194  var _ JoinRel = (*LateralJoin)(nil)
   195  
   196  func (r *LateralJoin) String() string {
   197  	return FormatExpr(r)
   198  }
   199  
   200  func (r *LateralJoin) JoinPrivate() *JoinBase {
   201  	return r.JoinBase
   202  }
   203  
   204  type TableScan struct {
   205  	*sourceBase
   206  	Table plan.TableIdNode
   207  }
   208  
   209  var _ RelExpr = (*TableScan)(nil)
   210  var _ SourceRel = (*TableScan)(nil)
   211  
   212  func (r *TableScan) String() string {
   213  	return FormatExpr(r)
   214  }
   215  
   216  func (r *TableScan) Name() string {
   217  	return strings.ToLower(r.Table.Name())
   218  }
   219  
   220  func (r *TableScan) TableId() sql.TableId {
   221  	return TableIdForSource(r.g.Id)
   222  }
   223  
   224  func (r *TableScan) TableIdNode() plan.TableIdNode {
   225  	return r.Table
   226  }
   227  
   228  func (r *TableScan) OutputCols() sql.Schema {
   229  	return r.Table.Schema()
   230  }
   231  
   232  func (r *TableScan) Children() []*ExprGroup {
   233  	return nil
   234  }
   235  
   236  type IndexScan struct {
   237  	*sourceBase
   238  	Table *plan.IndexedTableAccess
   239  	Index *Index
   240  	Alias string
   241  	Stats sql.Statistic
   242  }
   243  
   244  var _ RelExpr = (*IndexScan)(nil)
   245  var _ SourceRel = (*IndexScan)(nil)
   246  
   247  func (r *IndexScan) String() string {
   248  	return FormatExpr(r)
   249  }
   250  
   251  func (r *IndexScan) Name() string {
   252  	return strings.ToLower(r.Table.Name())
   253  }
   254  
   255  func (r *IndexScan) TableId() sql.TableId {
   256  	return TableIdForSource(r.g.Id)
   257  }
   258  
   259  func (r *IndexScan) TableIdNode() plan.TableIdNode {
   260  	return r.Table
   261  }
   262  
   263  func (r *IndexScan) OutputCols() sql.Schema {
   264  	return r.Table.Schema()
   265  }
   266  
   267  func (r *IndexScan) Children() []*ExprGroup {
   268  	return nil
   269  }
   270  
   271  type Values struct {
   272  	*sourceBase
   273  	Table *plan.ValueDerivedTable
   274  }
   275  
   276  var _ RelExpr = (*Values)(nil)
   277  var _ SourceRel = (*Values)(nil)
   278  
   279  func (r *Values) String() string {
   280  	return FormatExpr(r)
   281  }
   282  
   283  func (r *Values) Name() string {
   284  	return strings.ToLower(r.Table.Name())
   285  }
   286  
   287  func (r *Values) TableId() sql.TableId {
   288  	return TableIdForSource(r.g.Id)
   289  }
   290  
   291  func (r *Values) TableIdNode() plan.TableIdNode {
   292  	return r.Table
   293  }
   294  
   295  func (r *Values) OutputCols() sql.Schema {
   296  	return r.Table.Schema()
   297  }
   298  
   299  func (r *Values) Children() []*ExprGroup {
   300  	return nil
   301  }
   302  
   303  type TableAlias struct {
   304  	*sourceBase
   305  	Table *plan.TableAlias
   306  }
   307  
   308  var _ RelExpr = (*TableAlias)(nil)
   309  var _ SourceRel = (*TableAlias)(nil)
   310  
   311  func (r *TableAlias) String() string {
   312  	return FormatExpr(r)
   313  }
   314  
   315  func (r *TableAlias) Name() string {
   316  	return strings.ToLower(r.Table.Name())
   317  }
   318  
   319  func (r *TableAlias) TableId() sql.TableId {
   320  	return TableIdForSource(r.g.Id)
   321  }
   322  
   323  func (r *TableAlias) TableIdNode() plan.TableIdNode {
   324  	return r.Table
   325  }
   326  
   327  func (r *TableAlias) OutputCols() sql.Schema {
   328  	return r.Table.Schema()
   329  }
   330  
   331  func (r *TableAlias) Children() []*ExprGroup {
   332  	return nil
   333  }
   334  
   335  type RecursiveTable struct {
   336  	*sourceBase
   337  	Table *plan.RecursiveTable
   338  }
   339  
   340  var _ RelExpr = (*RecursiveTable)(nil)
   341  var _ SourceRel = (*RecursiveTable)(nil)
   342  
   343  func (r *RecursiveTable) String() string {
   344  	return FormatExpr(r)
   345  }
   346  
   347  func (r *RecursiveTable) Name() string {
   348  	return strings.ToLower(r.Table.Name())
   349  }
   350  
   351  func (r *RecursiveTable) TableId() sql.TableId {
   352  	return TableIdForSource(r.g.Id)
   353  }
   354  
   355  func (r *RecursiveTable) TableIdNode() plan.TableIdNode {
   356  	return r.Table
   357  }
   358  
   359  func (r *RecursiveTable) OutputCols() sql.Schema {
   360  	return r.Table.Schema()
   361  }
   362  
   363  func (r *RecursiveTable) Children() []*ExprGroup {
   364  	return nil
   365  }
   366  
   367  type RecursiveCte struct {
   368  	*sourceBase
   369  	Table *plan.RecursiveCte
   370  }
   371  
   372  var _ RelExpr = (*RecursiveCte)(nil)
   373  var _ SourceRel = (*RecursiveCte)(nil)
   374  
   375  func (r *RecursiveCte) String() string {
   376  	return FormatExpr(r)
   377  }
   378  
   379  func (r *RecursiveCte) Name() string {
   380  	return strings.ToLower(r.Table.Name())
   381  }
   382  
   383  func (r *RecursiveCte) TableId() sql.TableId {
   384  	return TableIdForSource(r.g.Id)
   385  }
   386  
   387  func (r *RecursiveCte) TableIdNode() plan.TableIdNode {
   388  	return r.Table
   389  }
   390  
   391  func (r *RecursiveCte) OutputCols() sql.Schema {
   392  	return r.Table.Schema()
   393  }
   394  
   395  func (r *RecursiveCte) Children() []*ExprGroup {
   396  	return nil
   397  }
   398  
   399  type SubqueryAlias struct {
   400  	*sourceBase
   401  	Table *plan.SubqueryAlias
   402  }
   403  
   404  var _ RelExpr = (*SubqueryAlias)(nil)
   405  var _ SourceRel = (*SubqueryAlias)(nil)
   406  
   407  func (r *SubqueryAlias) String() string {
   408  	return FormatExpr(r)
   409  }
   410  
   411  func (r *SubqueryAlias) Name() string {
   412  	return strings.ToLower(r.Table.Name())
   413  }
   414  
   415  func (r *SubqueryAlias) TableId() sql.TableId {
   416  	return TableIdForSource(r.g.Id)
   417  }
   418  
   419  func (r *SubqueryAlias) TableIdNode() plan.TableIdNode {
   420  	return r.Table
   421  }
   422  
   423  func (r *SubqueryAlias) OutputCols() sql.Schema {
   424  	return r.Table.Schema()
   425  }
   426  
   427  func (r *SubqueryAlias) Children() []*ExprGroup {
   428  	return nil
   429  }
   430  
   431  type TableFunc struct {
   432  	*sourceBase
   433  	Table sql.TableFunction
   434  }
   435  
   436  var _ RelExpr = (*TableFunc)(nil)
   437  var _ SourceRel = (*TableFunc)(nil)
   438  
   439  func (r *TableFunc) String() string {
   440  	return FormatExpr(r)
   441  }
   442  
   443  func (r *TableFunc) Name() string {
   444  	return strings.ToLower(r.Table.Name())
   445  }
   446  
   447  func (r *TableFunc) TableId() sql.TableId {
   448  	return TableIdForSource(r.g.Id)
   449  }
   450  
   451  func (r *TableFunc) TableIdNode() plan.TableIdNode {
   452  	return nil
   453  }
   454  
   455  func (r *TableFunc) OutputCols() sql.Schema {
   456  	return r.Table.Schema()
   457  }
   458  
   459  func (r *TableFunc) Children() []*ExprGroup {
   460  	return nil
   461  }
   462  
   463  type JSONTable struct {
   464  	*sourceBase
   465  	Table *plan.JSONTable
   466  }
   467  
   468  var _ RelExpr = (*JSONTable)(nil)
   469  var _ SourceRel = (*JSONTable)(nil)
   470  
   471  func (r *JSONTable) String() string {
   472  	return FormatExpr(r)
   473  }
   474  
   475  func (r *JSONTable) Name() string {
   476  	return strings.ToLower(r.Table.Name())
   477  }
   478  
   479  func (r *JSONTable) TableId() sql.TableId {
   480  	return TableIdForSource(r.g.Id)
   481  }
   482  
   483  func (r *JSONTable) TableIdNode() plan.TableIdNode {
   484  	return r.Table
   485  }
   486  
   487  func (r *JSONTable) OutputCols() sql.Schema {
   488  	return r.Table.Schema()
   489  }
   490  
   491  func (r *JSONTable) Children() []*ExprGroup {
   492  	return nil
   493  }
   494  
   495  type EmptyTable struct {
   496  	*sourceBase
   497  	Table *plan.EmptyTable
   498  }
   499  
   500  var _ RelExpr = (*EmptyTable)(nil)
   501  var _ SourceRel = (*EmptyTable)(nil)
   502  
   503  func (r *EmptyTable) String() string {
   504  	return FormatExpr(r)
   505  }
   506  
   507  func (r *EmptyTable) Name() string {
   508  	return strings.ToLower(r.Table.Name())
   509  }
   510  
   511  func (r *EmptyTable) TableId() sql.TableId {
   512  	return TableIdForSource(r.g.Id)
   513  }
   514  
   515  func (r *EmptyTable) TableIdNode() plan.TableIdNode {
   516  	return r.Table
   517  }
   518  
   519  func (r *EmptyTable) OutputCols() sql.Schema {
   520  	return r.Table.Schema()
   521  }
   522  
   523  func (r *EmptyTable) Children() []*ExprGroup {
   524  	return nil
   525  }
   526  
   527  type SetOp struct {
   528  	*sourceBase
   529  	Table *plan.SetOp
   530  }
   531  
   532  var _ RelExpr = (*SetOp)(nil)
   533  var _ SourceRel = (*SetOp)(nil)
   534  
   535  func (r *SetOp) String() string {
   536  	return FormatExpr(r)
   537  }
   538  
   539  func (r *SetOp) Name() string {
   540  	return ""
   541  }
   542  
   543  func (r *SetOp) TableId() sql.TableId {
   544  	return TableIdForSource(r.g.Id)
   545  }
   546  
   547  func (r *SetOp) TableIdNode() plan.TableIdNode {
   548  	return r.Table
   549  }
   550  
   551  func (r *SetOp) OutputCols() sql.Schema {
   552  	return r.Table.Schema()
   553  }
   554  
   555  func (r *SetOp) Children() []*ExprGroup {
   556  	return nil
   557  }
   558  
   559  type Project struct {
   560  	*relBase
   561  	Child       *ExprGroup
   562  	Projections []sql.Expression
   563  }
   564  
   565  var _ RelExpr = (*Project)(nil)
   566  
   567  func (r *Project) String() string {
   568  	return FormatExpr(r)
   569  }
   570  
   571  func (r *Project) Children() []*ExprGroup {
   572  	return []*ExprGroup{r.Child}
   573  }
   574  
   575  func (r *Project) outputCols() sql.ColSet {
   576  	return getProjectColset(r)
   577  }
   578  
   579  type Distinct struct {
   580  	*relBase
   581  	Child *ExprGroup
   582  }
   583  
   584  var _ RelExpr = (*Distinct)(nil)
   585  
   586  func (r *Distinct) String() string {
   587  	return FormatExpr(r)
   588  }
   589  
   590  func (r *Distinct) Children() []*ExprGroup {
   591  	return []*ExprGroup{r.Child}
   592  }
   593  
   594  func (r *Distinct) outputCols() sql.ColSet {
   595  	return r.Child.RelProps.OutputCols()
   596  }
   597  
   598  type Max1Row struct {
   599  	*relBase
   600  	Child *ExprGroup
   601  }
   602  
   603  var _ RelExpr = (*Max1Row)(nil)
   604  
   605  func (r *Max1Row) String() string {
   606  	return FormatExpr(r)
   607  }
   608  
   609  func (r *Max1Row) Children() []*ExprGroup {
   610  	return []*ExprGroup{r.Child}
   611  }
   612  
   613  func (r *Max1Row) outputCols() sql.ColSet {
   614  	return r.Child.RelProps.OutputCols()
   615  }
   616  
   617  type Filter struct {
   618  	*relBase
   619  	Child   *ExprGroup
   620  	Filters []sql.Expression
   621  }
   622  
   623  var _ RelExpr = (*Filter)(nil)
   624  
   625  func (r *Filter) String() string {
   626  	return FormatExpr(r)
   627  }
   628  
   629  func (r *Filter) Children() []*ExprGroup {
   630  	return []*ExprGroup{r.Child}
   631  }
   632  
   633  func (r *Filter) outputCols() sql.ColSet {
   634  	return r.Child.RelProps.OutputCols()
   635  }
   636  
   637  func FormatExpr(r exprType) string {
   638  	switch r := r.(type) {
   639  	case *CrossJoin:
   640  		return fmt.Sprintf("crossjoin %d %d", r.Left.Id, r.Right.Id)
   641  	case *InnerJoin:
   642  		return fmt.Sprintf("innerjoin %d %d", r.Left.Id, r.Right.Id)
   643  	case *LeftJoin:
   644  		return fmt.Sprintf("leftjoin %d %d", r.Left.Id, r.Right.Id)
   645  	case *SemiJoin:
   646  		return fmt.Sprintf("semijoin %d %d", r.Left.Id, r.Right.Id)
   647  	case *AntiJoin:
   648  		return fmt.Sprintf("antijoin %d %d", r.Left.Id, r.Right.Id)
   649  	case *LookupJoin:
   650  		return fmt.Sprintf("lookupjoin %d %d", r.Left.Id, r.Right.Id)
   651  	case *RangeHeapJoin:
   652  		return fmt.Sprintf("rangeheapjoin %d %d", r.Left.Id, r.Right.Id)
   653  	case *ConcatJoin:
   654  		return fmt.Sprintf("concatjoin %d %d", r.Left.Id, r.Right.Id)
   655  	case *HashJoin:
   656  		return fmt.Sprintf("hashjoin %d %d", r.Left.Id, r.Right.Id)
   657  	case *MergeJoin:
   658  		return fmt.Sprintf("mergejoin %d %d", r.Left.Id, r.Right.Id)
   659  	case *FullOuterJoin:
   660  		return fmt.Sprintf("fullouterjoin %d %d", r.Left.Id, r.Right.Id)
   661  	case *LateralJoin:
   662  		return fmt.Sprintf("lateraljoin %d %d", r.Left.Id, r.Right.Id)
   663  	case *TableScan:
   664  		return fmt.Sprintf("tablescan: %s", r.Name())
   665  	case *IndexScan:
   666  		if r.Alias != "" {
   667  			return fmt.Sprintf("indexscan: %s", r.Alias)
   668  		}
   669  		return fmt.Sprintf("indexscan: %s", r.Name())
   670  	case *Values:
   671  		return fmt.Sprintf("values: %s", r.Name())
   672  	case *TableAlias:
   673  		return fmt.Sprintf("tablealias: %s", r.Name())
   674  	case *RecursiveTable:
   675  		return fmt.Sprintf("recursivetable: %s", r.Name())
   676  	case *RecursiveCte:
   677  		return fmt.Sprintf("recursivecte: %s", r.Name())
   678  	case *SubqueryAlias:
   679  		return fmt.Sprintf("subqueryalias: %s", r.Name())
   680  	case *TableFunc:
   681  		return fmt.Sprintf("tablefunc: %s", r.Name())
   682  	case *JSONTable:
   683  		return fmt.Sprintf("jsontable: %s", r.Name())
   684  	case *EmptyTable:
   685  		return fmt.Sprintf("emptytable: %s", r.Name())
   686  	case *SetOp:
   687  		return fmt.Sprintf("setop: %s", r.Name())
   688  	case *Project:
   689  		return fmt.Sprintf("project: %d", r.Child.Id)
   690  	case *Distinct:
   691  		return fmt.Sprintf("distinct: %d", r.Child.Id)
   692  	case *Max1Row:
   693  		return fmt.Sprintf("max1row: %d", r.Child.Id)
   694  	case *Filter:
   695  		return fmt.Sprintf("filter: %d", r.Child.Id)
   696  	default:
   697  		panic(fmt.Sprintf("unknown RelExpr type: %T", r))
   698  	}
   699  }
   700  
   701  func buildRelExpr(b *ExecBuilder, r RelExpr, children ...sql.Node) (sql.Node, error) {
   702  	var result sql.Node
   703  	var err error
   704  
   705  	switch r := r.(type) {
   706  	case *CrossJoin:
   707  		result, err = b.buildCrossJoin(r, children...)
   708  	case *InnerJoin:
   709  		result, err = b.buildInnerJoin(r, children...)
   710  	case *LeftJoin:
   711  		result, err = b.buildLeftJoin(r, children...)
   712  	case *SemiJoin:
   713  		result, err = b.buildSemiJoin(r, children...)
   714  	case *AntiJoin:
   715  		result, err = b.buildAntiJoin(r, children...)
   716  	case *LookupJoin:
   717  		result, err = b.buildLookupJoin(r, children...)
   718  	case *RangeHeapJoin:
   719  		result, err = b.buildRangeHeapJoin(r, children...)
   720  	case *ConcatJoin:
   721  		result, err = b.buildConcatJoin(r, children...)
   722  	case *HashJoin:
   723  		result, err = b.buildHashJoin(r, children...)
   724  	case *MergeJoin:
   725  		result, err = b.buildMergeJoin(r, children...)
   726  	case *FullOuterJoin:
   727  		result, err = b.buildFullOuterJoin(r, children...)
   728  	case *LateralJoin:
   729  		result, err = b.buildLateralJoin(r, children...)
   730  	case *TableScan:
   731  		result, err = b.buildTableScan(r, children...)
   732  	case *IndexScan:
   733  		result, err = b.buildIndexScan(r, children...)
   734  	case *Values:
   735  		result, err = b.buildValues(r, children...)
   736  	case *TableAlias:
   737  		result, err = b.buildTableAlias(r, children...)
   738  	case *RecursiveTable:
   739  		result, err = b.buildRecursiveTable(r, children...)
   740  	case *RecursiveCte:
   741  		result, err = b.buildRecursiveCte(r, children...)
   742  	case *SubqueryAlias:
   743  		result, err = b.buildSubqueryAlias(r, children...)
   744  	case *TableFunc:
   745  		result, err = b.buildTableFunc(r, children...)
   746  	case *JSONTable:
   747  		result, err = b.buildJSONTable(r, children...)
   748  	case *EmptyTable:
   749  		result, err = b.buildEmptyTable(r, children...)
   750  	case *SetOp:
   751  		result, err = b.buildSetOp(r, children...)
   752  	case *Project:
   753  		result, err = b.buildProject(r, children...)
   754  	case *Max1Row:
   755  		result, err = b.buildMax1Row(r, children...)
   756  	case *Filter:
   757  		result, err = b.buildFilter(r, children...)
   758  	default:
   759  		panic(fmt.Sprintf("unknown RelExpr type: %T", r))
   760  	}
   761  
   762  	if err != nil {
   763  		return nil, err
   764  	}
   765  
   766  	if withDescribeStats, ok := result.(sql.WithDescribeStats); ok {
   767  		withDescribeStats.SetDescribeStats(*DescribeStats(r))
   768  	}
   769  	result, err = r.Group().finalize(result)
   770  	if err != nil {
   771  		return nil, err
   772  	}
   773  	return result, nil
   774  }