[
https://issues.apache.org/jira/browse/PHOENIX-3470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Maksim Zhuk reopened PHOENIX-3470:
----------------------------------
There's no correlation, but there's a difference ... Hbase processes true as
*\xFF*, while Phoenix as *\x01*.
When Phoenix metadata is applied over the existing HBase table, queries like
*field=true* do not find valid results.
Steps to reproduce:
{noformat}
First, from hbase create test table and insert boolean data...
hbase> scan 'TestBoolean'
ROW COLUMN+CELL
1 column=cf:name, timestamp=1478780696313, value=negative
1 column=cf:value, timestamp=1478780696313, value=\x00
2 column=cf:name, timestamp=1478780471625, value=positive
2 column=cf:value, timestamp=1478780471625, value=\xFF
Then apply Phoenix metadata.
phx> create table "TestBoolean" (
pk UNSIGNED_LONG PRIMARY KEY,
"cf"."name" VARCHAR,
"cf"."value" BOOLEAN);
2 rows affected (6.312 seconds)
Verify results:
phx> select * from "TestBoolean";
+-------+------------+--------+
| PK | name | value |
+-------+------------+--------+
| null | negative | false |
| null | positive | true |
+-------+------------+--------+
2 rows selected (0.052 seconds)
phx> select * from "TestBoolean" where "value"=false;
+-------+-----------+--------+
| PK | name | value |
+-------+-----------+--------+
| null | negative | false |
+-------+-----------+--------+
1 row selected (0.061 seconds)
phx> select * from "TestBoolean" where "value"=true;
+-----+-------+--------+
| PK | name | value |
+-----+-------+--------+
+-----+-------+--------+
No rows selected (0.056 seconds)
{noformat}
> Boolean values discrepancy with HBase byte format
> -------------------------------------------------
>
> Key: PHOENIX-3470
> URL: https://issues.apache.org/jira/browse/PHOENIX-3470
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.8.0
> Reporter: Maksim Zhuk
> Fix For: verify
>
>
> There's an inconsstency between Phoenix and Hbase in handling boolean "true"
> in byte format.
> [Phoenix|https://phoenix.apache.org/language/datatypes.html#boolean_type] -
> "The binary representation is a single byte with 0 for false and 1 for true"
> [HBase|https://hbase.apache.org/apidocs/src-html/org/apache/hadoop/hbase/util/Bytes.html#line.739]
> - "True becomes -1 and false becomes 0"
> {code:title=org.apache.hadoop.hbase.util.Bytes|borderStyle=solid}
> /**
> * Convert a boolean to a byte array. True becomes -1
> * and false becomes 0.
> *
> * @param b value
> * @return <code>b</code> encoded in a byte array.
> */
> public static byte [] toBytes(final boolean b) {
> return new byte[] { b ? (byte) -1 : (byte) 0 };
> }
> {code}
> When Phoenix metadata is applied over the existing HBase table this causes
> issues for queries like "... WHERE FIELD=TRUE ..." not finding any results.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)