Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
None
-
None
-
None
Description
Our PDouble.getCodec().decodeDouble() and PFloat.getCodec().decodeFloat() methods are updating the byte array in-place when the data is DESC which is a big no-no as it essentially corrupts data. The end effect is that data which is attempted to be stored as DESC is stored ASC instead, with the data appearing as being corruprt. Not sure if this is always the case for ingest paths, but a common UPSERT VALUES is impacted:
0: jdbc:phoenix:localhost> create table dd (k double primary key desc);
No rows affected (1.356 seconds)
0: jdbc:phoenix:localhost> upsert into dd values (1.0);
1 row affected (0.054 seconds)
0: jdbc:phoenix:localhost> upsert into dd values (2.0);
1 row affected (0.005 seconds)
0: jdbc:phoenix:localhost> select * from dd;
+------------------------------------------+
| K |
+------------------------------------------+
| -1.0000000000000004 |
| -2.000000000000001 |
+------------------------------------------+
2 rows selected (0.038 seconds)
Not sure how to fix this in terms of data that has already been written. One potential solution is to switch the column to be ASC instead of DESC (since that's how it is actually stored):
put 'SYSTEM.CATALOG', "\x00\x00DD\x00K", '0:SORT_ORDER', "\x80\x00\x00\x00"
And now the data is interpreted correctly:
0: jdbc:phoenix:localhost> select * from dd; +------------------------------------------+ | K | +------------------------------------------+ | 1.0 | | 2.0 | +------------------------------------------+ 2 rows selected (6.157 seconds)