[
https://issues.apache.org/jira/browse/PHOENIX-2946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15456958#comment-15456958
]
James Taylor edited comment on PHOENIX-2946 at 9/1/16 11:49 PM:
----------------------------------------------------------------
[~kliew] - dates, times, and timestamps may use their byte[] representation
directly for comparison. Looks like this wasn't the case. Take a look at this
patch. It'd be useful too to have test that compared a DATE against a TIMESTAMP
where the difference was only the nanos part. The only way to input a nanos is
as a bind parameter through stmt.setTimestamp(xxx, ts), after using the
setNanos() call on the timestamp. You'd also want to test comparison of an
UNSIGNED_TIMESTAMP with a DATE, as that's where that ugly condition I added in
PDataType.compareTo comes into play. Though PTimestamp has a codec, it
shouldn't be used in this case for the reason indicated by the comment. Might
be better to remove the codec as it's deceiving - it only takes into account
the first 8 bytes - but that leads to a number of test failures so this is
easier/safer.
Do you want to take a crack and adding a test like that to the ones you've
already added?
was (Author: jamestaylor):
[~kliew] - dates, times, and timestamps may use their byte[] representation
directly for comparison. Looks like this wasn't the case. Take a look at this
patch. It'd be useful too to have test that compared a DATE against a TIMESTAMP
where the difference was only the nanos part. The only way to input a nanos is
as a bind parameter through stmt.setTimestamp(xxx, ts), after using the
setNanos() call on the timestamp.
Do you want to take a crack and adding a test like that to the ones you've
already added?
> Projected comparison between date and timestamp columns always returns true
> ---------------------------------------------------------------------------
>
> Key: PHOENIX-2946
> URL: https://issues.apache.org/jira/browse/PHOENIX-2946
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.6.0, 4.8.0
> Reporter: Kevin Liew
> Assignee: Kevin Liew
> Priority: Minor
> Labels: comparison, date, timestamp
> Fix For: 4.9.0, 4.8.1
>
> Attachments: PHOENIX-2946_v2.patch
>
>
> {code}
> 0: jdbc:phoenix:thin:url=http://localhost:876> create table test (dateCol
> DATE primary key, timestampCol TIMESTAMP);
> No rows affected (2.559 seconds)
> 0: jdbc:phoenix:thin:url=http://localhost:876> upsert into test values
> (TO_DATE('1990-01-01'), NOW());
> 1 row affected (0.255 seconds)
> 0: jdbc:phoenix:thin:url=http://localhost:876> select dateCol = timestampCol
> from test;
> +------------------------------------------+
> | DATECOL = TIMESTAMPCOL |
> +------------------------------------------+
> | true |
> +------------------------------------------+
> 1 row selected (0.019 seconds)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)