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

Cannot override column type to json #75

Open
anishjain94 opened this issue Jun 20, 2024 · 0 comments
Open

Cannot override column type to json #75

anishjain94 opened this issue Jun 20, 2024 · 0 comments

Comments

@anishjain94
Copy link

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?})
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

1 participant