You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Dangi, Shailesh " <sh...@citi.com.INVALID> on 2017/03/28 15:37:18 UTC

Reading the row key with HBase Client API

We have a use case  to read data from an existing Phoenix tables using HBase client APIs.

Following are part of the key in a Phx table where TXN_BOOK_DT is of type Date and rest VARCHAR.
ID
TXN_BOOK_DT
CR_DR_IND
PYMNT_STATUS_CD
TXN_REFR_NUM
PD_PCSOR_COD

When reading the result row key and assuming it is separated by a zero byte character ('\0'), I'm able to read all VARCHAR fields using Bytes.toString.  However, I'm getting garbled characters when doing the same operation on TXN_BOOK_DT.  Any idea?

Thanks,
Regards,


Re: Reading the row key with HBase Client API

Posted by Nick Dimiduk <nd...@gmail.com>.
Phoenix has it's own type encodings for each data type. For best
compatibility, I suggest you either use UNSIGNED_XXX [0], which are
guaranteed to serialize with Bytes.toBytes(), or to use the serialization
methods of PDataType types that ship in phoenix-core.

[0]: http://phoenix.apache.org/language/datatypes.html

On Tue, Mar 28, 2017 at 8:37 AM, Dangi, Shailesh <
shailesh.dangi@citi.com.invalid> wrote:

> We have a use case  to read data from an existing Phoenix tables using
> HBase client APIs.
>
> Following are part of the key in a Phx table where TXN_BOOK_DT is of type
> Date and rest VARCHAR.
> ID
> TXN_BOOK_DT
> CR_DR_IND
> PYMNT_STATUS_CD
> TXN_REFR_NUM
> PD_PCSOR_COD
>
> When reading the result row key and assuming it is separated by a zero
> byte character ('\0'), I'm able to read all VARCHAR fields using
> Bytes.toString.  However, I'm getting garbled characters when doing the
> same operation on TXN_BOOK_DT.  Any idea?
>
> Thanks,
> Regards,
>
>