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

panic: unsupported ClickHouse type="Map(String, String)" #51

Open
mdsohelmia opened this issue Nov 22, 2022 · 4 comments
Open

panic: unsupported ClickHouse type="Map(String, String)" #51

mdsohelmia opened this issue Nov 22, 2022 · 4 comments

Comments

@mdsohelmia
Copy link

My Model

type Video struct {
	ch.CHModel `ch:"partition:toYYYYMM(time)"`
	ID         uint64
	Title      string            `ch:""`
	Time       time.Time         `ch:",pk"`
	Meta       []uint64          `ch:"type:Array(UInt64)"`
	Chapter    map[string]string `ch:"type:Map(String,String)"`
}
	video := database.Video{
		ID:    1,
		Title: "Video 1",
		Time:  time.Now(),
		Meta:  []uint64{10, 10, 10, 10},
		Chapter: map[string]string{
			"hello1": "hello",
			"hello":  "hello",
			"title":  "title",
		},
	}
	db.NewInsert().Model(&video).Exec(ctx)

panic: unsupported ClickHouse type="Map(String, String)"

goroutine 1 [running]:
github.com/uptrace/go-clickhouse/ch/chschema.goType({0xc0000a4030, 0x13})
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/chschema/types.go:307 +0x6ce
github.com/uptrace/go-clickhouse/ch/chschema.NewColumnFromCHType({0xc0000a4030, 0x13}, 0xc00009a1e0?)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/chschema/column.go:54 +0x28
github.com/uptrace/go-clickhouse/ch/chschema.(*Block).Column(0xc00009c280, {0xc00009a1e0, 0x7}, {0xc0000a4030, 0x13})
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/chschema/block.go:46 +0xd4
github.com/uptrace/go-clickhouse/ch.(*DB).readBlock.func1()
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/proto.go:515 +0x16e
github.com/uptrace/go-clickhouse/ch/chproto.(*Reader).WithCompression(0xc00009c000, 0x1, 0x100e4a7?)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/chproto/reader.go:44 +0x53
github.com/uptrace/go-clickhouse/ch.(*DB).readBlock(0xc0002c8050, 0xc00009c000, 0xc00009c280, 0x1)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/proto.go:481 +0x8f
github.com/uptrace/go-clickhouse/ch.(*DB).readSampleBlock(0x13c3820?, 0xc00009c000)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/proto.go:382 +0x12c
github.com/uptrace/go-clickhouse/ch.(*DB)._insert.func1.2(0xc000094000?)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:405 +0x25
github.com/uptrace/go-clickhouse/ch/chpool.(*Conn).WithReader(0xc0000a0000, {0x131b410?, 0xc00001e0c0?}, 0x13b2c64?, 0xc00035fb50)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/chpool/conn.go:70 +0x67
github.com/uptrace/go-clickhouse/ch.(*DB)._insert.func1(0xc0000a0000)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:404 +0x12b
github.com/uptrace/go-clickhouse/ch.(*DB)._withConn(0xc0002c8050, {0x131b410?, 0xc00001e0c0}, 0xc00035fcf8)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:219 +0x1ec
github.com/uptrace/go-clickhouse/ch.(*DB).withConn(0xc0002c8050, {0x131b410?, 0xc00001e0c0?}, 0x12?)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:176 +0x28
github.com/uptrace/go-clickhouse/ch.(*DB)._insert(0xc0000922a0?, {0x131b410?, 0xc00001e0c0?}, {0x1000?, 0x1000?}, {0xc0000b5000?, 0x14?}, 0x1000?)
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:396 +0x8f
github.com/uptrace/go-clickhouse/ch.(*DB).insert(0xc0002c8050, {0x131b410, 0xc00001e0c0}, {0x131afa0, 0xc0000922a0}, {0xc0000b5000, 0x46}, {0xc000092090, 0x5, 0x6})
/Users/sohelmia/go/pkg/mod/github.com/uptrace/go-clickhouse@v0.2.9/ch/db.go:383 +0x145

@et
Copy link

et commented Feb 8, 2023

I'm having the same issue. This would be nice to add support as this is the datatype for storing attributes per the OTEL spec.

@vmihailenco
Copy link
Member

Map(String, String) is just syntactic sugar for creating 2 separate columns keys and values. Here is what we use at Uptrace instead.

@et
Copy link

et commented Feb 16, 2023

@vmihailenco - while it may be syntactic sugar, it is kind of nice to have it and ideally, it'd be nice to not change the schema.

How difficult would it be to add support to this library? That's my blocker for using this over the official Clickhouse client. I'd be happy to submit a PR for this if you can provide any pointers.

@vmihailenco
Copy link
Member

@et here you go - #57. The hard part is to figure out how to implement reading/writing map[string]string using ClickHouse native protocol (ReadFrom/WriteTo methods). Most likely https://github.com/ClickHouse/clickhouse-go already knows how to do that so you can also try to ask for help there.

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

No branches or pull requests

3 participants