abc icon indicating copy to clipboard operation
abc copied to clipboard

Error importing Postgres table with empty array column

Open lbolla opened this issue 3 years ago • 0 comments

I am hitting the below error when trying to import data from a Postgres table, with a column of type "array" and empty value.

E.g. consider a PG table like this:

postgres@[local]/postgres
15:16:56 =# \d lbolla
              Table "public.lbolla"
 Column |  Type  | Collation | Nullable | Default
--------+--------+-----------+----------+---------
 data   | text[] |           |          |

with this values:

postgres@[local]/postgres
15:16:57 =# select * from lbolla;
   data
-----------
 {foo,bar}
 {}
(2 rows)

I now try to import it:

abc import --src_type=postgres --src_uri="postgresql://postgres@localhost/postgres" --src_filter="lbolla" "http://localhost:9200/abc_test"

panic: runtime error: index out of range

goroutine 67 [running]:
github.com/appbaseio/abc/private/adaptor/postgres.casifyValue(0xc00047a5a2, 0x2, 0xc00047a4e0, 0x6, 0xc00047a5a2, 0x2)
        /go/src/github.com/appbaseio/abc/private/adaptor/postgres/tailer.go:267 +0xdef
github.com/appbaseio/abc/private/adaptor/postgres.(*Reader).iterateTable.func1(0xc00046e480, 0xc00046e420, 0xc000131220, 0x8, 0xc000116180, 0xc0000a8b40)
        /go/src/github.com/appbaseio/abc/private/adaptor/postgres/reader.go:170 +0xced
created by github.com/appbaseio/abc/private/adaptor/postgres.(*Reader).iterateTable
        /go/src/github.com/appbaseio/abc/private/adaptor/postgres/reader.go:104 +0x91

The error is caused by the row with empty ('{}') value.

I am using:

abc versionVersion:    1.0.0-beta.1
Variant:    !oss
Go version: go1.12.5
OS:         linux
Arch:       amd64

lbolla avatar Sep 09 '20 13:09 lbolla