MCPcopy Create free account
hub / github.com/bytebase/bytebase / translateAggregateFunctionError

Function translateAggregateFunctionError

backend/plugin/db/clickhouse/query.go:113–121  ·  view source on GitHub ↗

translateAggregateFunctionError rewrites the clickhouse-go driver's opaque "unsupported column type \"AggregateFunction(...)\"" error into actionable guidance pointing the user at -Merge combinators or finalizeAggregation(), since the driver cannot decode AggregateFunction intermediate state directl

(err error)

Source from the content-addressed store, hash-verified

111// guidance pointing the user at -Merge combinators or finalizeAggregation(),
112// since the driver cannot decode AggregateFunction intermediate state directly.
113func translateAggregateFunctionError(err error) error {
114 if err == nil || !strings.Contains(err.Error(), aggregateFunctionErrMarker) {
115 return err
116 }
117 return errors.Wrap(err,
118 "this query selects an AggregateFunction column, which stores aggregator intermediate state and cannot be decoded directly. "+
119 "Wrap each AggregateFunction column with its -Merge combinator under GROUP BY (for example, maxMerge(col)), or with "+
120 "finalizeAggregation(col) for per-row finalization")
121}
122
123func makeValueByTypeName(typeName string, columnType *sql.ColumnType) any {
124 if strings.HasPrefix(typeName, "TUPLE") || strings.HasPrefix(typeName, "ARRAY") || strings.HasPrefix(typeName, "MAP") || strings.HasPrefix(typeName, "JSON") {

Callers 2

QueryConnMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by 1