You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Tino Rusch <ti...@contiamo.com> on 2019/08/19 09:08:30 UTC

Unused ScanTypes in avatica-go driver

Hello,

I just want to ask if the ScanType in the avatica-go driver could be
removed. I don't find any references for it (its set, but never read) and
I'm facing errors when requesting columns with a non-trivial data type.

Unfortunately it even panics when it column metadata which doesn't contain
a well known type (INT, VARCHAR etc...)

In the [generic adapter](
https://github.com/apache/calcite-avatica-go/blob/master/generic/generic.go#L38)
is a method which prepares the ColumnMetaData for further use and also sets
up the ScanType values by switching over the reported data type for each
column. If there is any non-standard data type specified, the default case
is used, which results in a panic.

While investigating this I found out that the ScanType is never used in the
driver for actually scanning the data. I assume that this is some old code
which could be removed, but I'm not totally sure.

Could someone of you check if that whole ScanType logic can be removed? If
yes I'm more that happy to create a PR for this.

With kind regards,

Tino

Re: Unused ScanTypes in avatica-go driver

Posted by Francis Chuang <fr...@apache.org>.
Hi Tino,

The ScanType is used by ColumnTypeScanType [1] which is a new interface 
added in Go 1.8. The avatica-go implementation is here [2].

Therefore, we should not remove it as the database/sql can use this 
interface.

I believe you are hitting the panic here in the generic driver [3].

My suggestion would be to remove the panic, and return 
reflect.TypeOf(new(interface{})).Elem() for the default case, following 
the postgres driver's implementation [4].

Francis

[1] https://godoc.org/database/sql/driver#RowsColumnTypeScanType
[2] 
https://github.com/apache/calcite-avatica-go/blob/2e3a26ea672e2dbcb29cb50478a994e03bf737b1/rows_go18.go#L75
[3] 
https://github.com/apache/calcite-avatica-go/blob/2e3a26ea672e2dbcb29cb50478a994e03bf737b1/generic/generic.go#L91
[4] https://sourcegraph.com/github.com/lib/pq@90697d6/-/blob/rows.go#L41:43


On 19/08/2019 7:08 pm, Tino Rusch wrote:
> Hello,
> 
> I just want to ask if the ScanType in the avatica-go driver could be
> removed. I don't find any references for it (its set, but never read) and
> I'm facing errors when requesting columns with a non-trivial data type.
> 
> Unfortunately it even panics when it column metadata which doesn't contain
> a well known type (INT, VARCHAR etc...)
> 
> In the [generic adapter](
> https://github.com/apache/calcite-avatica-go/blob/master/generic/generic.go#L38)
> is a method which prepares the ColumnMetaData for further use and also sets
> up the ScanType values by switching over the reported data type for each
> column. If there is any non-standard data type specified, the default case
> is used, which results in a panic.
> 
> While investigating this I found out that the ScanType is never used in the
> driver for actually scanning the data. I assume that this is some old code
> which could be removed, but I'm not totally sure.
> 
> Could someone of you check if that whole ScanType logic can be removed? If
> yes I'm more that happy to create a PR for this.
> 
> With kind regards,
> 
> Tino
>