ClickHouse / ClickHouse/clickhouse-go
Array (Tuple) is parsed as Map Is this as expected?
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 680
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 14
Description
## Observed
1.create table sql:
CREATE DICTIONARY flow_tag.vtap_port_map
(
`vtap_id` UInt64,
`tap_port` UInt64,
`name` String,
`host_id` Int64,
`host_name` String,
`chost_id` Int64,
`chost_name` String,
`pod_node_id` Int64,
`pod_node_name` String,
`device_type` UInt64,
`device_id` UInt64,
`device_name` String,
`icon_id` Int64,
`team_id` UInt64
)
PRIMARY KEY vtap_id, tap_port
SOURCE(MYSQL(PORT 30130 USER 'root' PASSWORD '[HIDDEN]' REPLICA (HOST 'mysql' PRIORITY 1) DB deepflow TABLE ch_vtap_port UPDATE_FIELD 'updated_at' INVALIDATE_QUERY 'select max(updated_at) from ch_vtap_port'))
LIFETIME(MIN 30 MAX 60)
LAYOUT(COMPLEX_KEY_HASHED())
2. query sql: SELECT dictGetOrDefault('flow_tag.vtap_port_map', ('device_type','device_id','device_name','icon_id','host_id','host_name','chost_id','chost_name','pod_node_id','pod_node_name'),(toUInt64(agent_id),toUInt64(capture_nic)), (0,0,'',0,0,'',0,'',0,'')) AS `resource_from_vtap` FROM flow_metrics.`application_map.1m` LIMIT 2
3.clickhouse query result:
4. clickhouse-go query result:
## Expected behaviour
Consistent with the return from ClickHouse
## Code example
```go
package code
// your code snippet here
conn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{net.JoinHostPort(c.Host, strconv.Itoa(c.Port))},
Auth: clickhouse.Auth{
Database: "default",
Username: c.UserName,
Password: c.Password,
},
// Default MaxOpenConns = MaxIdleConns + 5
// Ref: https://clickhouse.com/docs/en/integrations/go/clickhouse-go/clickhouse-api#connection-settings
// In ClickHouse SDK, when returning a connection, if the current number of idle connections is equal to
// `MaxIdleConns`, the connection to be returned will be closed directly. Therefore, when `MaxOpenConns`
// is greater than `MaxIdleConns`, it is very easy for the connection to be actively closed, and it is
// easy to cause a lot of short connections during high-concurrency queries, so set the two to the same
// value here.
// Ref: https://github.com/ClickHouse/clickhouse-go/blob/main/clickhouse.go#L296
MaxOpenConns: config.Cfg.Clickhouse.MaxConnection,
MaxIdleConns: config.Cfg.Clickhouse.MaxConnection,
DialTimeout: time.Duration(config.Cfg.Clickhouse.Timeout) * time.Second,
})
```
## Error log
```log
```
## Details
### Environment
* [x] `clickhouse-go` version: v2.47.0
* [ ] Interface: ClickHouse API / `database/sql` compatible driver
* [x] Go version: 1.26.2
* [ ] Operating system:
* [x] ClickHouse version: v25.8.14
* [ ] Is it a ClickHouse Cloud?
* [ ] ClickHouse Server non-default settings, if any:
* [ ] `CREATE TABLE` statements for tables involved:
* [ ] Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary
Contributor guide
Research direction
Start by reproducing the reported SELECT dictGetOrDefault query with clickhouse-go v2.47.0 against ClickHouse v25.8.14, comparing the server result with the driver result. Trace how the returned Array/Tuple value is decoded and represented, then verify the result is consistent with ClickHouse's output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clickhouse, go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100