Files
go/lib/column/simple_aggregate_function.go
zeekay 22b3f5ce2b hanzo-ds/go: branded datastore client, rebased on clickhouse-go v2.44.0
Feature-complete v2.44.0 (lib/churl, lib/col, BFloat16, QBit, scanTypeDuration,
Options.Logger *slog.Logger) — fixes the [email protected].0 downgrade RED caught.
Package datastore, module github.com/hanzo-ds/go, depends only on hanzo-ds/native.
Wire strings preserved VERBATIM (X-ClickHouse-* headers, sql.Register("clickhouse"),
clickhouse:// DSN, ClientName="clickhouse-go") — consistent with native.
2026-07-10 13:11:20 -07:00

86 lines
2.2 KiB
Go

package column
import (
"fmt"
"reflect"
"strings"
"github.com/hanzo-ds/native/proto"
)
type SimpleAggregateFunction struct {
base Interface
chType Type
name string
}
func (col *SimpleAggregateFunction) Reset() {
col.base.Reset()
}
func (col *SimpleAggregateFunction) Name() string {
return col.name
}
func (col *SimpleAggregateFunction) parse(t Type, sc *ServerContext) (_ Interface, err error) {
col.chType = t
base := strings.TrimSpace(strings.SplitN(t.params(), ",", 2)[1])
if col.base, err = Type(base).Column(col.name, sc); err == nil {
return col, nil
}
return nil, &UnsupportedColumnTypeError{
t: t,
}
}
func (col *SimpleAggregateFunction) Type() Type {
return col.chType
}
func (col *SimpleAggregateFunction) ScanType() reflect.Type {
return col.base.ScanType()
}
func (col *SimpleAggregateFunction) Rows() int {
return col.base.Rows()
}
func (col *SimpleAggregateFunction) Row(i int, ptr bool) any {
return col.base.Row(i, ptr)
}
func (col *SimpleAggregateFunction) ScanRow(dest any, rows int) error {
return col.base.ScanRow(dest, rows)
}
func (col *SimpleAggregateFunction) Append(v any) ([]uint8, error) {
return col.base.Append(v)
}
func (col *SimpleAggregateFunction) AppendRow(v any) error {
return col.base.AppendRow(v)
}
func (col *SimpleAggregateFunction) Decode(reader *proto.Reader, rows int) error {
return col.base.Decode(reader, rows)
}
func (col *SimpleAggregateFunction) Encode(buffer *proto.Buffer) {
col.base.Encode(buffer)
}
func (col *SimpleAggregateFunction) ReadStatePrefix(reader *proto.Reader) error {
if serialize, ok := col.base.(CustomSerialization); ok {
if err := serialize.ReadStatePrefix(reader); err != nil {
return fmt.Errorf("failed to read prefix for SimpleAggregateFunction base type %s: %w", col.base.Type(), err)
}
}
return nil
}
func (col *SimpleAggregateFunction) WriteStatePrefix(buffer *proto.Buffer) error {
if serialize, ok := col.base.(CustomSerialization); ok {
if err := serialize.WriteStatePrefix(buffer); err != nil {
return fmt.Errorf("failed to write prefix for SimpleAggregateFunction base type %s: %w", col.base.Type(), err)
}
}
return nil
}
var _ Interface = (*SimpleAggregateFunction)(nil)
var _ CustomSerialization = (*SimpleAggregateFunction)(nil)