Respect original column type when inserting#1174
Conversation
aeae9ac to
6c449bf
Compare
6c449bf to
c2a5313
Compare
c2a5313 to
5a4c812
Compare
presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/BaseJdbcClient.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
The JdbcPageSink is JDBC-specifc, and so JdbcOutputTableHandle is.
It's surprising at first that the argument isn't cast by the caller but it's being cast here.
I would consider something like this: pass JdbcOutputTableHandle (as it was).
Inside constructor, check:
if (!handle.getJdbcColumnTypes().isPresent()) {
... the old way
}
else {
.... the new way
}
(This would be further simplified if we combine WriteFunction and WriteNullFunction into a single interface, but let's not do this in this PR.)
5a4c812 to
52de269
Compare
|
Applied comments. Travis fails repeatedly due to out of memory error. |
In JDBC connectors, currently the insert target type for a column depends on the Presto type chosen to represent the column's values. This strategy doesn't support multiple original types mapped to the same Presto type -- a single `WriteMapping` imposes a target type which not necessarily fits them all, and so inserts may cause errors at finish time when trying to copy the temporary table into the target table (unless the target database is able to perform a coercion). This is fixed by making INSERT aware of the target column types i.e. by using the original column type in the temporary table and obtaining the write function from the `ColumnMapping`.
52de269 to
290b6c0
Compare
|
Merged, thanks! |
|
@findepi @kasiafi I was trying to understand the changes in this PR. Referring to this statement - |
In JDBC connectors, currently the insert target type for a column depends
on the Presto type chosen to represent the column's values.
This strategy doesn't support multiple original types mapped to the same
Presto type -- a single
WriteMappingimposes a target type which not necessarilyfits them all, and so inserts may cause errors at finish time when trying to copy
the temporary table into the target table (unless the target database is able
to perform a coercion).
This is fixed by making INSERT aware of the target column types i.e. by using
the original column type in the temporary table and obtaining the write function
from the
ColumnMapping.This will allow to support inserting Postgres array values when they are mapped to Presto JSON (issue #682 addressed by #1148)
Fixes #338