appbaseio / appbaseio/abc

Error importing Postgres table with empty array column

Open
#189 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
471
Forks
47
PR merge metrics
No merged PRs in 30d

Description

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
```

Contributor guide

Open the contributing guide

Research direction

Start with casifyValue in private/adaptor/postgres/tailer.go at line 267, then follow its call from private/adaptor/postgres/reader.go at line 170. Reproduce the import using the shown PostgreSQL table containing both {foo,bar} and {}, and verify that the empty array imports without a panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.