diff --git a/lib/column/bigint.go b/lib/column/bigint.go index e09c96ae1d..49e179cb67 100644 --- a/lib/column/bigint.go +++ b/lib/column/bigint.go @@ -90,7 +90,7 @@ func (col *BigInt) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: col.append(v[i]) default: nulls[i] = 1 diff --git a/lib/column/codegen/column.tpl b/lib/column/codegen/column.tpl index 2ae117db1c..fb76a8999b 100644 --- a/lib/column/codegen/column.tpl +++ b/lib/column/codegen/column.tpl @@ -309,7 +309,9 @@ func (col *{{ .ChType }}) Append(v any) (nulls []uint8,err error) { nulls = make([]uint8, len(v)) for i := range v { val := int8(0) - if *v[i] { + if v[i] == nil { + nulls[i] = 1 + } else if *v[i] { val = 1 } col.col.Append(val) @@ -432,4 +434,4 @@ func (col *{{ .ChType }}) Encode(buffer *proto.Buffer) { col.col.EncodeColumn(buffer) } -{{- end }} \ No newline at end of file +{{- end }} diff --git a/lib/column/column_gen.go b/lib/column/column_gen.go index 455be4c0e1..5bd1180a3b 100644 --- a/lib/column/column_gen.go +++ b/lib/column/column_gen.go @@ -656,7 +656,9 @@ func (col *Int8) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { val := int8(0) - if *v[i] { + if v[i] == nil { + nulls[i] = 1 + } else if *v[i] { val = 1 } col.col.Append(val) diff --git a/lib/column/datetime.go b/lib/column/datetime.go index d5dfffad22..3337430a77 100644 --- a/lib/column/datetime.go +++ b/lib/column/datetime.go @@ -121,7 +121,7 @@ func (col *DateTime) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: col.col.Append(time.Unix(*v[i], 0)) default: col.col.Append(time.Time{}) diff --git a/lib/column/datetime64.go b/lib/column/datetime64.go index f5a5a94877..bd683f855f 100644 --- a/lib/column/datetime64.go +++ b/lib/column/datetime64.go @@ -142,7 +142,7 @@ func (col *DateTime64) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: col.col.Append(time.UnixMilli(*v[i])) default: col.col.Append(time.UnixMilli(0)) diff --git a/lib/column/geo_multi_polygon.go b/lib/column/geo_multi_polygon.go index 2839a41c52..1263b897d8 100644 --- a/lib/column/geo_multi_polygon.go +++ b/lib/column/geo_multi_polygon.go @@ -86,9 +86,15 @@ func (col *MultiPolygon) Append(v any) (nulls []uint8, err error) { } return col.set.Append(values) case []*orb.MultiPolygon: + nulls = make([]uint8, len(v)) values := make([][]orb.Polygon, 0, len(v)) - for _, v := range v { - values = append(values, *v) + for i, v := range v { + if v == nil { + nulls[i] = 1 + values = append(values, orb.MultiPolygon{}) + } else { + values = append(values, *v) + } } return col.set.Append(values) default: diff --git a/lib/column/geo_point.go b/lib/column/geo_point.go index c93a715ace..4a4fe16bae 100644 --- a/lib/column/geo_point.go +++ b/lib/column/geo_point.go @@ -89,11 +89,16 @@ func (col *Point) Append(v any) (nulls []uint8, err error) { } case []*orb.Point: nulls = make([]uint8, len(v)) - for _, v := range v { - col.col.Append(proto.Point{ - X: v.Lon(), - Y: v.Lat(), - }) + for i, v := range v { + if v == nil { + nulls[i] = 1 + col.col.Append(proto.Point{}) + } else { + col.col.Append(proto.Point{ + X: v.Lon(), + Y: v.Lat(), + }) + } } default: if valuer, ok := v.(driver.Valuer); ok { diff --git a/lib/column/geo_polygon.go b/lib/column/geo_polygon.go index 542260815c..6e78b1a9d9 100644 --- a/lib/column/geo_polygon.go +++ b/lib/column/geo_polygon.go @@ -86,9 +86,15 @@ func (col *Polygon) Append(v any) (nulls []uint8, err error) { } return col.set.Append(values) case []*orb.Polygon: + nulls = make([]uint8, len(v)) values := make([][]orb.Ring, 0, len(v)) - for _, v := range v { - values = append(values, *v) + for i, v := range v { + if v == nil { + nulls[i] = 1 + values = append(values, orb.Polygon{}) + } else { + values = append(values, *v) + } } return col.set.Append(values) default: diff --git a/lib/column/geo_ring.go b/lib/column/geo_ring.go index 0f190a8e25..a64de47f73 100644 --- a/lib/column/geo_ring.go +++ b/lib/column/geo_ring.go @@ -86,9 +86,15 @@ func (col *Ring) Append(v any) (nulls []uint8, err error) { } return col.set.Append(values) case []*orb.Ring: + nulls = make([]uint8, len(v)) values := make([][]orb.Point, 0, len(v)) - for _, v := range v { - values = append(values, *v) + for i, v := range v { + if v == nil { + nulls[i] = 1 + values = append(values, orb.Ring{}) + } else { + values = append(values, *v) + } } return col.set.Append(values) default: diff --git a/lib/column/ipv4.go b/lib/column/ipv4.go index a15f6d3e92..3d4c252833 100644 --- a/lib/column/ipv4.go +++ b/lib/column/ipv4.go @@ -145,7 +145,7 @@ func (col *IPv4) Append(v any) (nulls []uint8, err error) { ips := make([]netip.Addr, len(v), len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: ip, err := strToIPV4(*v[i]) if err != nil { return nulls, err @@ -164,7 +164,7 @@ func (col *IPv4) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: col.col.Append(proto.ToIPv4(*v[i])) default: nulls[i] = 1 @@ -196,7 +196,7 @@ func (col *IPv4) Append(v any) (nulls []uint8, err error) { nulls = make([]uint8, len(v)) for i := range v { switch { - case v != nil: + case v[i] != nil: col.col.Append(proto.IPv4(*v[i])) default: nulls[i] = 1