Skip to content

Add tuple support#87

Merged
wlggraham merged 1 commit intomainfrom
ihladush/add_support_for_tuple
Feb 2, 2026
Merged

Add tuple support#87
wlggraham merged 1 commit intomainfrom
ihladush/add_support_for_tuple

Conversation

@hladush
Copy link
Contributor

@hladush hladush commented Feb 2, 2026

Clickhouse doesn't support Tuple or Array(Tuple...)) data types. It caused panic

reflect.Set: value of type []map[string]interface {} is not assignable to type []interface{}
The major reason for that was that handle array used var v []any as a result v couldn't be []map[string]interface {}. To fix that array right now expect any value because interface{} can be anything. It can be []map[string]interface {} and can be []string{} etc.
This PR fixes panic. General panic handler for all requests will be added in next PR.

Testing was done on local machine with multiple Clickhouse queries

Copilot AI review requested due to automatic review settings February 2, 2026 16:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds ClickHouse Tuple handling and adjusts Array scanning to avoid panics when scanning arrays whose concrete Go type is not []any (e.g., []map[string]any), resolving reflect.Set assignability errors.

Changes:

  • Add a Tuple type handler and recognize Tuple(...) in unwrapCHType.
  • Change Array scan targets/readers to use any instead of []any to accept concrete slice types returned by the driver.
  • Register the new Tuple handler in the ClickHouse type handler map.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +150 to +154
func handleTuple(nullable bool) (any, func() any) {
if nullable {
var p *any
return &p, func() any {
if p == nil || *p == nil {
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New code in handleTuple uses spaces for indentation and doesn’t match the rest of this Go file’s gofmt/tab formatting. Please run gofmt (or reformat this block) so indentation and brace alignment are consistent.

Copilot uses AI. Check for mistakes.
Comment on lines 165 to +176
func handleArray(nullable bool) (any, func() any) {
if nullable {
var p *[]any
return &p, func() any {
if p == nil {
return nil
}
return *p
}
}
var v []any
return &v, func() any { return v }
if nullable {
var p *any
return &p, func() any {
if p == nil || *p == nil {
return nil
}
return *p
}
}
var v any
return &v, func() any { return v }
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleTuple and handleArray now contain identical scan-target logic. Consider factoring this into a shared helper (e.g., reuse makeScanTargetany or introduce a dedicated handler for complex/unknown types) to avoid duplication and keep future fixes in one place.

Copilot uses AI. Check for mistakes.
Comment on lines +209 to +211
if strings.HasPrefix(s, "Tuple(") {
return "Tuple", nullable
}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added Tuple() branch uses space-indentation and is misaligned vs the surrounding gofmt style. Please gofmt/reformat this block for consistency.

Copilot uses AI. Check for mistakes.
@wlggraham wlggraham merged commit d236558 into main Feb 2, 2026
12 checks passed
@wlggraham wlggraham deleted the ihladush/add_support_for_tuple branch February 2, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants