func (b *SelectBuilder) Max(column string) *SelectBuilder {
	b.fn("max", column)
	return b
}
Max produces 'max(column)' aggregation function.
package qb
import (
	"bytes"
	"context"
	"fmt"
	"time"
	"github.com/scylladb/gocqlx/v2"
)
type Order bool
const (
	ASC Order = true
	DESC = false
)
func (o Order) String() string {
	if o {
		return "ASC"
	}
	return "DESC"
}
type SelectBuilder struct {
	table             string
	columns           columns
	distinct          columns
	using             using
	where             where
	groupBy           columns
	orderBy           columns
	limit             uint
	limitPerPartition uint
	allowFiltering    bool
	bypassCache       bool
	json              bool
}
func Select(table string) *SelectBuilder {
	return &SelectBuilder{
		table: table,
	}
}
func (b *SelectBuilder) ToCql() (stmt string, names []string) {
	cql := bytes.Buffer{}
	cql.WriteString("SELECT ")
	if b.json {
		cql.WriteString("JSON ")
	}
	switch {
	case len(b.distinct) > 0:
		cql.WriteString("DISTINCT ")
		b.distinct.writeCql(&cql)
	case len(b.groupBy) > 0:
		b.groupBy.writeCql(&cql)
		if len(b.columns) != 0 {
			cql.WriteByte(',')
			b.columns.writeCql(&cql)
		}
	case len(b.columns) == 0:
		cql.WriteByte('*')
	default:
		b.columns.writeCql(&cql)
	}
	cql.WriteString(" FROM ")
	cql.WriteString(b.table)
	cql.WriteByte(' ')
	names = append(names, b.using.writeCql(&cql)...)
	names = append(names, b.where.writeCql(&cql)...)
	if len(b.groupBy) > 0 {
		cql.WriteString("GROUP BY ")
		b.groupBy.writeCql(&cql)
		cql.WriteByte(' ')
	}
	if len(b.orderBy) > 0 {
		cql.WriteString("ORDER BY ")
		b.orderBy.writeCql(&cql)
		cql.WriteByte(' ')
	}
	if b.limit != 0 {
		cql.WriteString("LIMIT ")
		cql.WriteString(fmt.Sprint(b.limit))
		cql.WriteByte(' ')
	}
	if b.limitPerPartition != 0 {
		cql.WriteString("PER PARTITION LIMIT ")
		cql.WriteString(fmt.Sprint(b.limitPerPartition))
		cql.WriteByte(' ')
	}
	if b.allowFiltering {
		cql.WriteString("ALLOW FILTERING ")
	}
	if b.bypassCache {
		cql.WriteString("BYPASS CACHE ")
	}
	stmt = cql.String()
	return
}
func (b *SelectBuilder) Query(session gocqlx.Session) *gocqlx.Queryx {
	return session.Query(b.ToCql())
}
func (b *SelectBuilder) QueryContext(ctx context.Context, session gocqlx.Session) *gocqlx.Queryx {
	return b.Query(session).WithContext(ctx)
}
func (b *SelectBuilder) From(table string) *SelectBuilder {
	b.table = table
	return b
}
func (b *SelectBuilder) Json() *SelectBuilder {
	b.json = true
	return b
}
func (b *SelectBuilder) Columns(columns ...string) *SelectBuilder {
	if len(b.columns) == 0 {
		b.columns = columns
	} else {
		b.columns = append(b.columns, columns...)
	}
	return b
}
func As(column, name string) string {
	return column + " AS " + name
}
func (b *SelectBuilder) Distinct(columns ...string) *SelectBuilder {
	if len(b.where) == 0 {
		b.distinct = columns
	} else {
		b.distinct = append(b.distinct, columns...)
	}
	return b
}
func (b *SelectBuilder) Timeout(d time.Duration) *SelectBuilder {
	b.using.Timeout(d)
	return b
}
func (b *SelectBuilder) TimeoutNamed(name string) *SelectBuilder {
	b.using.TimeoutNamed(name)
	return b
}
func (b *SelectBuilder) Where(w ...Cmp) *SelectBuilder {
	if len(b.where) == 0 {
		b.where = w
	} else {
		b.where = append(b.where, w...)
	}
	return b
}
func (b *SelectBuilder) GroupBy(columns ...string) *SelectBuilder {
	if len(b.groupBy) == 0 {
		b.groupBy = columns
	} else {
		b.groupBy = append(b.groupBy, columns...)
	}
	return b
}
func (b *SelectBuilder) OrderBy(column string, o Order) *SelectBuilder {
	b.orderBy = append(b.orderBy, column+" "+o.String())
	return b
}
func (b *SelectBuilder) Limit(limit uint) *SelectBuilder {
	b.limit = limit
	return b
}
func (b *SelectBuilder) LimitPerPartition(limit uint) *SelectBuilder {
	b.limitPerPartition = limit
	return b
}
func (b *SelectBuilder) AllowFiltering() *SelectBuilder {
	b.allowFiltering = true
	return b
}
func (b *SelectBuilder) BypassCache() *SelectBuilder {
	b.bypassCache = true
	return b
}
func (b *SelectBuilder) Count(column string) *SelectBuilder {
	b.fn("count", column)
	return b
}
func (b *SelectBuilder) CountAll() *SelectBuilder {
	b.Count("*")
	return b
}
func (b *SelectBuilder) Min(column string) *SelectBuilder {
	b.fn("min", column)
	return b
}