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)
| 111 | // guidance pointing the user at -Merge combinators or finalizeAggregation(), |
| 112 | // since the driver cannot decode AggregateFunction intermediate state directly. |
| 113 | func 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 | |
| 123 | func 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") { |