Skip to content
This repository was archived by the owner on Dec 31, 2025. It is now read-only.

Commit df4e5b6

Browse files
committed
chore: make icepq_field_bound_values a faillible function (does not immediately break query but returns either result|error)
1 parent 504145e commit df4e5b6

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

cmd/clickhouse/function/field_bound_values/field_bound_values.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/ClickHouse/ch-go/proto"
1010
ice "github.com/agnosticeng/icepq/internal/iceberg"
11+
"github.com/samber/lo"
1112
"github.com/sourcegraph/conc/iter"
1213
"github.com/urfave/cli/v2"
1314
)
@@ -25,7 +26,7 @@ func Command() *cli.Command {
2526
buf proto.Buffer
2627
inputTableLocationCol = new(proto.ColStr)
2728
inputFieldNameCol = new(proto.ColStr)
28-
outputResultCol = new(proto.ColStr).Array()
29+
outputResultCol = new(proto.ColBytes)
2930

3031
input = proto.Results{
3132
{Name: "table_location", Data: inputTableLocationCol},
@@ -67,22 +68,30 @@ func Command() *cli.Command {
6768
)
6869

6970
if err != nil {
70-
return err
71+
outputResultCol.Append(lo.Must(json.Marshal(map[string]any{
72+
"error": err.Error(),
73+
})))
74+
continue
7175
}
7276

73-
res, err := iter.MapErr(values, func(item *ice.FieldBoundValuesItem) (string, error) {
77+
res, err := iter.MapErr(values, func(item *ice.FieldBoundValuesItem) (json.RawMessage, error) {
7478
js, err := json.Marshal(item)
7579
if err != nil {
76-
return "", err
80+
return nil, err
7781
}
78-
return string(js), nil
82+
return js, nil
7983
})
8084

8185
if err != nil {
82-
return err
86+
outputResultCol.Append(lo.Must(json.Marshal(map[string]any{
87+
"error": err.Error(),
88+
})))
89+
continue
8390
}
8491

85-
outputResultCol.Append(res)
92+
outputResultCol.Append(lo.Must(json.Marshal(map[string]any{
93+
"value": res,
94+
})))
8695
}
8796

8897
var outputblock = proto.Block{

config/icepq_field_bound_values_function.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<type>String</type>
1818
</argument>
1919

20-
<return_type>Array(JSON)</return_type>
20+
<return_type>JSON</return_type>
2121
</function>
2222
</functions>

0 commit comments

Comments
 (0)