func (ieb *IfElseBlock) WithChildren(children ...sql.Node) (sql.Node, error) {
	if len(children) < 2 {
		return nil, fmt.Errorf("%T: invalid children number, got %d, expected at least 2", ieb, len(children))
	}
	ifConditionals := make([]*IfConditional, len(children)-1)
	for i, child := range children[:len(children)-1] {
		ifConditional, ok := child.(*IfConditional)
		if !ok {
			return nil, fmt.Errorf("%T: expected if conditional child but got %T", ieb, child)
		}
		ifConditionals[i] = ifConditional
	}
	return NewIfElse(ifConditionals, children[len(children)-1]), nil
}
WithChildren implements the sql.Node interface.
package plan
import (
	"fmt"
	"github.com/dolthub/go-mysql-server/sql"
)
type IfConditional struct {
	Condition sql.Expression
	Body      sql.Node
}
var _ sql.Node = (*IfConditional)(nil)
var _ sql.DebugStringer = (*IfConditional)(nil)
var _ sql.Expressioner = (*IfConditional)(nil)
func NewIfConditional(condition sql.Expression, body sql.Node) *IfConditional {
	return &IfConditional{
		Condition: condition,
		Body:      body,
	}
}
func (ic *IfConditional) Resolved() bool {
	return ic.Condition.Resolved() && ic.Body.Resolved()
}
func (ic *IfConditional) String() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode(fmt.Sprintf("IF(%s)", ic.Condition.String()))
	_ = p.WriteChildren(ic.Body.String())
	return p.String()
}
func (ic *IfConditional) DebugString() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode(fmt.Sprintf("IF(%s)", sql.DebugString(ic.Condition)))
	_ = p.WriteChildren(sql.DebugString(ic.Body))
	return p.String()
}
func (ic *IfConditional) Schema() sql.Schema {
	return ic.Body.Schema()
}
func (ic *IfConditional) Children() []sql.Node {
	return []sql.Node{ic.Body}
}
func (ic *IfConditional) WithChildren(children ...sql.Node) (sql.Node, error) {
	if len(children) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(ic, len(children), 1)
	}
	nic := *ic
	nic.Body = children[0]
	return &nic, nil
}
func (ic *IfConditional) Expressions() []sql.Expression {
	return []sql.Expression{ic.Condition}
}
func (ic *IfConditional) WithExpressions(exprs ...sql.Expression) (sql.Node, error) {
	if len(exprs) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(ic, len(exprs), 1)
	}
	nic := *ic
	nic.Condition = exprs[0]
	return &nic, nil
}
func (ic *IfConditional) RowIter(ctx *sql.Context, row sql.Row) (sql.RowIter, error) {
	return ic.Body.RowIter(ctx, row)
}
type IfElseBlock struct {
	IfConditionals []*IfConditional
	Else           sql.Node
}
var _ sql.Node = (*IfElseBlock)(nil)
var _ sql.DebugStringer = (*IfElseBlock)(nil)
func NewIfElse(ifConditionals []*IfConditional, elseStatement sql.Node) *IfElseBlock {
	return &IfElseBlock{
		IfConditionals: ifConditionals,
		Else:           elseStatement,
	}
}
func (ieb *IfElseBlock) Resolved() bool {
	for _, s := range ieb.IfConditionals {
		if !s.Resolved() {
			return false
		}
	}
	return ieb.Else.Resolved()
}
func (ieb *IfElseBlock) String() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode("IF BLOCK")
	var children []string
	for _, s := range ieb.IfConditionals {
		children = append(children, s.String())
	}
	_ = p.WriteChildren(children...)
	ep := sql.NewTreePrinter()
	_ = ep.WriteNode("ELSE")
	_ = ep.WriteChildren(ieb.Else.String())
	_ = p.WriteChildren(ep.String())
	return p.String()
}
func (ieb *IfElseBlock) DebugString() string {
	p := sql.NewTreePrinter()
	_ = p.WriteNode("IF BLOCK")
	var children []string
	for _, s := range ieb.IfConditionals {
		children = append(children, sql.DebugString(s))
	}
	_ = p.WriteChildren(children...)
	ep := sql.NewTreePrinter()
	_ = ep.WriteNode("ELSE")
	_ = ep.WriteChildren(sql.DebugString(ieb.Else))
	_ = p.WriteChildren(ep.String())
	return p.String()
}
func (ieb *IfElseBlock) Schema() sql.Schema {
	return nil
}
func (ieb *IfElseBlock) Children() []sql.Node {
	statements := make([]sql.Node, len(ieb.IfConditionals)+1)
	for i, ifConditional := range ieb.IfConditionals {
		statements[i] = ifConditional
	}
	statements[len(ieb.IfConditionals)] = ieb.Else
	return statements
}