You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the correct way to decode a column whose ClickHouse type is Array(Tuple(String, String)) and map it to a Go [][]string?
For example, given the following SQL query:
SELECT [('one', 'two'), ('three', 'four')] AS arr;
...how do I replace the TODO comment with something that will map each tuple to a [][]string?
funcarrayOfTuples() {
ctx:=context.Background()
c, err:=ch.Dial(ctx, ch.Options{Address: "localhost:9000"})
iferr!=nil {
panic(err)
}
arr:=new(proto.ColArr[proto.ColTuple])
iferr:=c.Do(ctx, ch.Query{
Body: "SELECT [('one', 'two'), ('three', 'four')] AS arr",
Result: proto.Results{
{Name: "arr", Data: arr},
},
OnResult: func(ctx context.Context, b proto.Block) error {
// TODO: Decode b and map its values to `[][]string`returnnil
},
}); err!=nil {
panic(err)
}
}
The difficulty is in figuring out how to allocate a proto.ColumnOf[proto.ColTuple], where ColTuple is of type tuple(string, string), and how to properly decode a block into it.
We got the same ask at #227 ch-go doesn't provide an interface to interact with Array( Tuple() ). Tuple is implemented a bit differently compared to other column types.
When supported, interacting with the result would look like this:
What is the correct way to decode a column whose ClickHouse type is
Array(Tuple(String, String))
and map it to a Go[][]string
?For example, given the following SQL query:
...how do I replace the TODO comment with something that will map each tuple to a
[][]string
?The difficulty is in figuring out how to allocate a
proto.ColumnOf[proto.ColTuple]
, whereColTuple
is of typetuple(string, string)
, and how to properly decode a block into it.The equivalent clickhouse-go code works smoothly:
The text was updated successfully, but these errors were encountered: