func (m *maxBuffer) Update(ctx *sql.Context, row sql.Row) error {
	v, err := m.expr.Eval(ctx, row)
	if err != nil {
		return err
	}
	if reflect.TypeOf(v) == nil {
		return nil
	}
	if m.val == nil {
		m.val = v
		return nil
	}
	cmp, err := m.expr.Type().Compare(v, m.val)
	if err != nil {
		return err
	}
	if cmp == 1 {
		m.val = v
	}
	return nil
}
Update implements the AggregationBuffer interface.
package aggregation
import (
	"fmt"
	"reflect"
	"github.com/dolthub/go-mysql-server/sql"
	"github.com/dolthub/go-mysql-server/sql/expression"
)
type Max struct {
	expression.UnaryExpression
}
var _ sql.FunctionExpression = (*Max)(nil)
var _ sql.Aggregation = (*Max)(nil)
func NewMax(e sql.Expression) *Max {
	return &Max{expression.UnaryExpression{Child: e}}
}
func (m *Max) FunctionName() string {
	return "max"
}
func (m *Max) Type() sql.Type {
	return m.Child.Type()
}
func (m *Max) String() string {
	return fmt.Sprintf("MAX(%s)", m.Child)
}
func (m *Max) DebugString() string {
	return fmt.Sprintf("MAX(%s)", sql.DebugString(m.Child))
}
func (m *Max) IsNullable() bool {
	return false
}
func (m *Max) WithChildren(children ...sql.Expression) (sql.Expression, error) {
	if len(children) != 1 {
		return nil, sql.ErrInvalidChildrenNumber.New(m, len(children), 1)
	}
	return NewMax(children[0]), nil
}
func (m *Max) NewBuffer() (sql.AggregationBuffer, error) {
	bufferChild, err := expression.Clone(m.UnaryExpression.Child)
	if err != nil {
		return nil, err
	}
	return &maxBuffer{nil, bufferChild}, nil
}
func (m *Max) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
	return nil, ErrEvalUnsupportedOnAggregation.New("Max")
}
type maxBuffer struct {
	val  interface{}
	expr sql.Expression
}