Skip to content

Commit 903a0d1

Browse files
committed
ignore materialized and alias cols
during instantiation of the batch insert we construct all the columns, there is no need to do it for materialized and alias columns as they are non insertable
1 parent 720f9cb commit 903a0d1

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

conn_http_batch.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import (
2121
"context"
2222
"errors"
2323
"fmt"
24-
"github.com/ClickHouse/clickhouse-go/v2/lib/column"
25-
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
26-
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
2724
"io"
2825
"io/ioutil"
2926
"regexp"
3027
"strings"
28+
29+
"github.com/ClickHouse/clickhouse-go/v2/lib/column"
30+
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
31+
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
3132
)
3233

3334
// \x60 represents a backtick
@@ -63,14 +64,19 @@ func (h *httpConnect) prepareBatch(ctx context.Context, query string, opts drive
6364
var colNames []string
6465
for r.Next() {
6566
var (
66-
colName string
67-
colType string
68-
ignore string
67+
colName string
68+
colType string
69+
default_type string
70+
ignore string
6971
)
7072

71-
if err = r.Scan(&colName, &colType, &ignore, &ignore, &ignore, &ignore, &ignore); err != nil {
73+
if err = r.Scan(&colName, &colType, &default_type, &ignore, &ignore, &ignore, &ignore); err != nil {
7274
return nil, err
7375
}
76+
// // these column types cannot be specified in INSERT queries
77+
// if default_type == "MATERIALIZED" || default_type == "ALIAS" {
78+
// continue
79+
// }
7480
colNames = append(colNames, colName)
7581
columns[colName] = colType
7682
}

0 commit comments

Comments
 (0)