Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map columns with enum keys are unsupported. #1231

Closed
leklund opened this issue Mar 13, 2024 · 0 comments · Fixed by #1236
Closed

Map columns with enum keys are unsupported. #1231

leklund opened this issue Mar 13, 2024 · 0 comments · Fixed by #1236
Assignees
Labels

Comments

@leklund
Copy link
Contributor

leklund commented Mar 13, 2024

Map columns with enum keys are unsupported.

Queries that select map columns that use an enum key will fail and return an error:

Enum16('hello' = 1: invalid Enum

Steps to reproduce

  1. Create a table with some data
CREATE TABLE map_test
(
  `data` Map(Enum16('hello' = 1, 'world' = 2), UInt64),
)
ENGINE = TinyLog;
INSERT INTO map_test(data) VALUES (map(1, 42, 2, 123));
  1. Query:
sql := "SELECT data as Data FROM map_test"

var result []struct {
  Data map[string]uint64
}
if err := conn.Select(context.Background(), &result, sql); err != nil {
    fmt.Println(err)
}

fmt.Println(result)
  1. Error:
Enum16('hello' = 1: invalid Enum

Expected behaviour

[{map[hello:42 world:123]}]

Cause

map.go is always splitting the type into two substrings on the first comma: https://github.com/ClickHouse/clickhouse-go/blob/main/lib/column/map.go#L69

In my examples case this string for t.params(): Enum16('hello' = 1, 'world' = 2), UInt64 will split into:

[]string{
  "Enum16('hello' = 1",
  " 'world' = 2), UInt64"
}

Configuration

Environment

  • Client version: github.com/ClickHouse/clickhouse-go/v2 v2.20.0
  • Language version: go1.21.2
  • OS: Mac OS X darwin/arm64
  • Interface: ClickHouse API

ClickHouse server

  • ClickHouse Server version: 24.2.1.2248
  • ClickHouse Server non-default settings, if any: none
  • CREATE TABLE statements for tables involved: See above
  • Sample data for all these tables: See above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants