Skip to content

Commit

Permalink
changefeedccl: Fix array encoding avro bug.
Browse files Browse the repository at this point in the history
Fix latent array avro encoding bug where previously allocated
memo array might contain 'nil' element, while the code assumed
that the element must always be a map.

Release note: none.
  • Loading branch information
Yevgeniy Miretskiy committed Sep 27, 2022
1 parent c55586b commit d7f53cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/ccl/changefeedccl/avro.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ func typeToAvroSchema(typ *types.T) (*avroSchemaField, error) {
},
func(d tree.Datum, memo interface{}) (interface{}, error) {
datumArr := d.(*tree.DArray)

var avroArr []interface{}
if memo != nil {
avroArr = memo.([]interface{})
Expand All @@ -616,14 +617,13 @@ func typeToAvroSchema(typ *types.T) (*avroSchemaField, error) {
} else {
avroArr = make([]interface{}, 0, datumArr.Len())
}

for i, elt := range datumArr.Array {
var encoded interface{}
if elt == tree.DNull {
encoded = nil
} else {
var encErr error
if i < len(avroArr) {
if i < len(avroArr) && avroArr[i] != nil {
encoded, encErr = itemSchema.encodeDatum(elt, avroArr[i].(map[string]interface{})[itemUnionKey])
} else {
encoded, encErr = itemSchema.encodeDatum(elt, nil)
Expand Down

0 comments on commit d7f53cf

Please sign in to comment.