func (g *GroupConcat) IsNullable() bool {
	return false
}
IsNullable implements the Expression interface.
package aggregation
import (
	"fmt"
	"sort"
	"strings"
	"github.com/dolthub/vitess/go/vt/proto/query"
	"github.com/dolthub/go-mysql-server/sql"
	"github.com/dolthub/go-mysql-server/sql/expression"
)
type GroupConcat struct {
	distinct    string
	sf          sql.SortFields
	separator   string
	selectExprs []sql.Expression
	maxLen      int
	returnType  sql.Type
}
var _ sql.FunctionExpression = &GroupConcat{}
var _ sql.Aggregation = &GroupConcat{}
func NewEmptyGroupConcat() sql.Expression {
	return &GroupConcat{}
}
func NewGroupConcat(distinct string, orderBy sql.SortFields, separator string, selectExprs []sql.Expression, maxLen int) (*GroupConcat, error) {
	return &GroupConcat{distinct: distinct, sf: orderBy, separator: separator, selectExprs: selectExprs, maxLen: maxLen}, nil
}
func (g *GroupConcat) NewBuffer() (sql.AggregationBuffer, error) {
	var rows []sql.Row
	distinctSet := make(map[string]bool)
	return &groupConcatBuffer{g, rows, distinctSet}, nil
}
func (g *GroupConcat) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
	return nil, ErrEvalUnsupportedOnAggregation.New("GroupConcat")
}
func (g *GroupConcat) Resolved() bool {
	for _, se := range g.selectExprs {
		if !se.Resolved() {
			return false
		}
	}
	sfs := g.sf.ToExpressions()
	for _, sf := range sfs {
		if !sf.Resolved() {
			return false
		}
	}
	return true
}
func (g *GroupConcat) String() string {
	sb := strings.Builder{}
	sb.WriteString("group_concat(")
	if g.distinct != "" {
		sb.WriteString(fmt.Sprintf("distinct %s", g.distinct))
	}
	if g.selectExprs != nil {
		var exprs = make([]string, len(g.selectExprs))
		for i, expr := range g.selectExprs {
			exprs[i] = expr.String()
		}
		sb.WriteString(strings.Join(exprs, ", "))
	}
	if len(g.sf) > 0 {
		sb.WriteString(" order by ")
		for i, ob := range g.sf {
			if i > 0 {
				sb.WriteString(", ")
			}
			sb.WriteString(ob.String())
		}
	}
	if g.separator != "," {
		sb.WriteString(" separator ")
		sb.WriteString(fmt.Sprintf("'%s'", g.separator))
	}
	sb.WriteString(")")
	return sb.String()
}
func (g *GroupConcat) Type() sql.Type {
	if g.returnType == sql.Blob {
		if g.maxLen <= 512 {
			return sql.MustCreateString(query.Type_VARBINARY, 512, sql.Collation_binary)
		} else {
			return sql.Blob
		}
	} else {
		if g.maxLen <= 512 {
			return sql.MustCreateString(query.Type_VARCHAR, 512, sql.Collation_Default)
		} else {
			return sql.Text
		}
	}
}