ClickHouse/ch-go

how to append data?

wangxuanyue opened this issue · 1 comments

auto infer

col := &proto.ColAuto{}
if err := col.Infer(proto.ColumnType("DateTime")); err != nil {
	fmt.Printf("Auto Infer Error: %s\n", err)
}

// how to append data to column???
col.append()???

I believe you have to know (or determine) the type of the column that's returned and make the appropriate type assertion:

inputCol := col.Data.(*proto.ColDateTime)
inputCol.Append(time.Now())

If you don't know in the type advance you could do this with a switch statement:

switch col.Data.(type) {
case *proto.ColDateTime:
col.Data.(*proto.ColDateTime).Append(time.Now()
}

Most "dynamic" solutions for creating input columns are going to involve either large switch statements or reflection, so there will always be some moderate performance it.