go-clickhouse
go-clickhouse copied to clipboard
Cannot override column type to json
Hi I am trying to override a column type to json. I am not able to do that. Can you help me with it.
As per this documentation clickhouse still supports JSON
.
https://clickhouse.com/docs/en/integrations/go#json
Here are my models.
type LogKarzaApiClickhouse struct {
ch.CHModel `ch:"table:log_karza_apis"`
RequestId string `ch:"request_id"`
Path string `ch:"path"`
Request []byte `ch:"request"`
Response []byte `ch:"response"`
ResponseRaw string `ch:"response_raw"`
Method common.HttpMethodsEnum `ch:"method"`
StatusCode int `ch:"status_code"`
RequestHeaders *common.CustomHeader `ch:"type:JSON,request_headers"`
ResponseHeaders *common.CustomHeader `ch:"type:JSON,response_headers"`
ResponseTime time.Duration `ch:"response_time"`
Error *string `ch:"error"`
}
Function
func TestCreateTable(t *testing.T) {
fmt.Println("cache")
ctx := context.Background()
environment.InitializeEnvs(environment.VARIANT_LOAN)
logger.InitializeLogger()
uptrace.InitializeClickHouse()
res, err := uptrace.Clickhousedb.NewCreateTable().Model((*LogKarzaApiClickhouse)(nil)).Exec(ctx)
util.AssertError(err, util.BLOCKED, http.StatusBadGateway, "error")
util.PrintJson(res)
}
error logs
panic: unsupported ClickHouse column: [recovered]
panic: unsupported ClickHouse column:
goroutine 6 [running]:
testing.tRunner.func1.2({0x103c30c80, 0x14000721cf0})
/opt/homebrew/Cellar/go/1.22.4/libexec/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
/opt/homebrew/Cellar/go/1.22.4/libexec/src/testing/testing.go:1634 +0x33c
panic({0x103c30c80?, 0x14000721cf0?})
/opt/homebrew/Cellar/go/1.22.4/libexec/src/runtime/panic.go:770 +0x124
github.com/uptrace/go-clickhouse/ch/chschema.ColumnFactory({0x0, 0x0}, {0x103d925c8, 0x103c787a0})
/Users/anishjain/go/pkg/mod/github.com/uptrace/[email protected]/ch/chschema/types.go:243 +0x1150
github.com/uptrace/go-clickhouse/ch/chschema.ColumnFactory({0x103be6378, 0x4}, {0x103d925c8, 0x103c55320})
/Users/anishjain/go/pkg/mod/github.com/uptrace/[email protected]/ch/chschema/types.go:229 +0x1044
github.com/uptrace/go-clickhouse/ch/chschema.(*Table).addFields(0x1400042c9a0, {0x103d925c8, 0x103d46380}, {0x0, 0x0, 0x0?})