New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java 8 Time Support for Postgres Arrays #1225
Comments
Mostly for read as I get an array due to an I worked around it for now with:
|
Also, I've been eyeing those PRs as I having to work around reading byte[][]. Same thing as above an array_agg on byte[] column. |
I've also encountered similar issue with
As you can see, it's not possible to retrieve the correct value from |
Thanks for this report. Anyone care to provide a PR ? |
@davecramer let's discuss API first. When reading one could use
When writing it should be easier. We can accept (multi-dim) arrays of |
@findepi |
@davecramer AFAIU, PostgreSQL Time zones are implicated only because JDBC wants you to use I've investigated this in Presto SQL (trinodb/trino#37 & related issues and PRs) and my opinion is that we we should use no time zone at all when handling cc @electrum |
@findepi you'd probably be surprised to know that timestamp with timezone doesn't store the timezone either then. |
In PostgreSQL -- yes, I know. Right, I missed the fact the issue is broader than just (Or course For (Let me explain my point of view. I am concerned mostly about losing information and not about convenience, because in Presto use-cases, not losing information is all we need. Even accessing String would be enough. Others, are probably more interested in getting java.time. classes because in application code there is usually more code that interacts with JDBC in some way.) |
Sadly the whole date/time/timestamp thing with java and JDBC is beyond repair. We have to chose to be opinionated here. At the moment I'm not sure of the "best" opinion. I'm going to confer with the npgsql guys to see what their driver does to get some level of consistency |
I think we could relatively easily allow consumer to override default array
type handling once the PR for reworking array decoding is merged.
…On Tue, Jul 30, 2019 at 9:16 AM Dave Cramer ***@***.***> wrote:
you'd probably be surprised to know that timestamp with timezone doesn't
store the timezone either then.
In PostgreSQL -- yes, I know.
Right, I missed the fact the issue is broader than just timestamp[].
I was not as much concerned about timestamptz[] being mapped to
java.sql.Timestamp[] because in timestamptz case all I need is point in
time. So this mapping at least does not lose information.
https://github.com/prestosql/presto/blob/c39358eee752eac13959fd05dc5427502cf03b33/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/PostgreSqlClient.java#L355-L357
(Or course java.time.Instant would be more appropriate)
For date[], mapping to java.sql.Date[] loses information in one edge case
only (DATE '2011-12-30' and Pacific/Apia zone). Of course, it's still
desirable to get the date[] data as java.time.LocalDate[].
Can you elaborate on why this one edge case fails
(Let me explain my point of view. I am concerned mostly about losing
information and not about convenience, because in Presto use-cases, not
losing information is all we need. Even accessing String would be enough.
Others, are probably more interested in getting java.time. classes because
in application code there is usually more code that interacts with JDBC in
some way.)
Sadly the whole date/time/timestamp thing with java and JDBC is beyond
repair. We have to chose to be opinionated here. At the moment I'm not sure
of the "best" opinion. I'm going to confer with the npgsql guys to see what
their driver does to get some level of consistency
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1225?email_source=notifications&email_token=AAW3U3LOBA5R5MSNNFFKJHDQCBEKHA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EDTYI#issuecomment-516438497>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAW3U3PVECBLJ6JNV2QTEP3QCBEKHANCNFSM4FG5ZJFA>
.
|
Brett,
What do we have to do to get that merged?
Dave Cramer
…On Tue, 30 Jul 2019 at 13:12, Brett Okken ***@***.***> wrote:
I think we could relatively easily allow consumer to override default array
type handling once the PR for reworking array decoding is merged.
On Tue, Jul 30, 2019 at 9:16 AM Dave Cramer ***@***.***>
wrote:
> you'd probably be surprised to know that timestamp with timezone doesn't
> store the timezone either then.
>
> In PostgreSQL -- yes, I know.
>
> Right, I missed the fact the issue is broader than just timestamp[].
> I was not as much concerned about timestamptz[] being mapped to
> java.sql.Timestamp[] because in timestamptz case all I need is point in
> time. So this mapping at least does not lose information.
>
https://github.com/prestosql/presto/blob/c39358eee752eac13959fd05dc5427502cf03b33/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/PostgreSqlClient.java#L355-L357
>
> (Or course java.time.Instant would be more appropriate)
>
> For date[], mapping to java.sql.Date[] loses information in one edge case
> only (DATE '2011-12-30' and Pacific/Apia zone). Of course, it's still
> desirable to get the date[] data as java.time.LocalDate[].
> Can you elaborate on why this one edge case fails
>
> (Let me explain my point of view. I am concerned mostly about losing
> information and not about convenience, because in Presto use-cases, not
> losing information is all we need. Even accessing String would be enough.
> Others, are probably more interested in getting java.time. classes
because
> in application code there is usually more code that interacts with JDBC
in
> some way.)
>
> Sadly the whole date/time/timestamp thing with java and JDBC is beyond
> repair. We have to chose to be opinionated here. At the moment I'm not
sure
> of the "best" opinion. I'm going to confer with the npgsql guys to see
what
> their driver does to get some level of consistency
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <
#1225?email_source=notifications&email_token=AAW3U3LOBA5R5MSNNFFKJHDQCBEKHA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EDTYI#issuecomment-516438497
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AAW3U3PVECBLJ6JNV2QTEP3QCBEKHANCNFSM4FG5ZJFA
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1225?email_source=notifications&email_token=AADDH5SDDDIUC5JASSIVGVDQCBY6DA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EVC5A#issuecomment-516510068>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADDH5XU7HNBJCIQKDCHXT3QCBY6DANCNFSM4FG5ZJFA>
.
|
You and Vladimir to review, approve and merge. 😀
On Wed, Jul 31, 2019 at 10:42 AM Dave Cramer <notifications@github.com>
wrote:
… Brett,
What do we have to do to get that merged?
Dave Cramer
On Tue, 30 Jul 2019 at 13:12, Brett Okken ***@***.***>
wrote:
> I think we could relatively easily allow consumer to override default
array
> type handling once the PR for reworking array decoding is merged.
>
> On Tue, Jul 30, 2019 at 9:16 AM Dave Cramer ***@***.***>
> wrote:
>
> > you'd probably be surprised to know that timestamp with timezone
doesn't
> > store the timezone either then.
> >
> > In PostgreSQL -- yes, I know.
> >
> > Right, I missed the fact the issue is broader than just timestamp[].
> > I was not as much concerned about timestamptz[] being mapped to
> > java.sql.Timestamp[] because in timestamptz case all I need is point in
> > time. So this mapping at least does not lose information.
> >
>
https://github.com/prestosql/presto/blob/c39358eee752eac13959fd05dc5427502cf03b33/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/PostgreSqlClient.java#L355-L357
> >
> > (Or course java.time.Instant would be more appropriate)
> >
> > For date[], mapping to java.sql.Date[] loses information in one edge
case
> > only (DATE '2011-12-30' and Pacific/Apia zone). Of course, it's still
> > desirable to get the date[] data as java.time.LocalDate[].
> > Can you elaborate on why this one edge case fails
> >
> > (Let me explain my point of view. I am concerned mostly about losing
> > information and not about convenience, because in Presto use-cases, not
> > losing information is all we need. Even accessing String would be
enough.
> > Others, are probably more interested in getting java.time. classes
> because
> > in application code there is usually more code that interacts with JDBC
> in
> > some way.)
> >
> > Sadly the whole date/time/timestamp thing with java and JDBC is beyond
> > repair. We have to chose to be opinionated here. At the moment I'm not
> sure
> > of the "best" opinion. I'm going to confer with the npgsql guys to see
> what
> > their driver does to get some level of consistency
> >
> > —
> > You are receiving this because you commented.
> > Reply to this email directly, view it on GitHub
> > <
>
#1225?email_source=notifications&email_token=AAW3U3LOBA5R5MSNNFFKJHDQCBEKHA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EDTYI#issuecomment-516438497
> >,
> > or mute the thread
> > <
>
https://github.com/notifications/unsubscribe-auth/AAW3U3PVECBLJ6JNV2QTEP3QCBEKHANCNFSM4FG5ZJFA
> >
> > .
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#1225?email_source=notifications&email_token=AADDH5SDDDIUC5JASSIVGVDQCBY6DA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3EVC5A#issuecomment-516510068
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AADDH5XU7HNBJCIQKDCHXT3QCBY6DANCNFSM4FG5ZJFA
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1225?email_source=notifications&email_token=AAW3U3MH5F6URWV554CLKGDQCGXGBA5CNFSM4FG5ZJFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3HVS2I#issuecomment-516905321>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAW3U3LKHGFXZJBG4DDUPEDQCGXGBANCNFSM4FG5ZJFA>
.
|
I've been looking around and it looks like Java 8 Time Support for Postgres Arrays is not yet implemented and there aren't any other issues so opening a new one.
At first glance it looks like the required change would be in
PgArray.buildArray(...)
as it currently defaults to marshalling DATE, TIME, and TIMESTAMP to java.sql.* classes.Looking at the existing methods called by
ResultSet.getObject(colName, Class<T>)
its straightforward to get the value. What's not clear to me is (1) whether the binary case that is handled getObject needs to be handled for arrays and (2) how to maintain backward compatibility. One way to possibly support in a backwards compatible is to implement the version of getArray that takes a map.For now, I'm manually doing the conversion as I'm on tight deadline and it's easy enough to do manual conversions.
The text was updated successfully, but these errors were encountered: