Here is what hbase-shell returns for this field:
hbase(main):004:0> get 'urls', 'AZ.OC.ICR', {COLUMN => 'u'}
COLUMN
CELL
u:status timestamp=1411476725886,
value=\x00\x00\x00\xC8
The database is populated via Java/Clojure (using the
clojure-hbase-schemas) applications that use Bytes.toBytes(int) to convert
HTTP status into byte array. I also have no problem converting value back
via Bytes/toInt.
On Wed, Jul 22, 2015 at 7:00 PM, Ted Dunning <[email protected]> wrote:
> Yes. Just right on that.
>
> Regarding the integer conversion, can you saw what format your data is
> in? Is it exactly 4 bytes, big endian?
>
>
>
> On Wed, Jul 22, 2015 at 5:34 AM, Alex Ott <[email protected]> wrote:
> > Ok, answering my first question - I need to take the only the column name
> > into the backquotes, instead of taking the complete coordinates:
> >
> > 0: jdbc:drill:zk=local> select CONVERT_FROM(row_key, 'UTF8') as key,
> > CONVERT_FROM(urls.u.`raw-url`, 'UTF8') AS url FROM hbase.urls WHERE
> row_key
> > = 'AZ.OC.ICR';
> > +------------+-------------------+
> > | key | url |
> > +------------+-------------------+
> > | AZ.OC.ICR | http://RCI.CO.ZA |
> > +------------+-------------------+
> >
> >
> > On Wed, Jul 22, 2015 at 1:22 PM, Alex Ott <[email protected]> wrote:
> >
> >> Hello
> >>
> >> I'm starting to play with Apache Drill & try to use it with HBase.
> >>
> >> I have following questions:
> >> - I have HBase table, where some columns have minus sign ('-') in the
> >> name, like, 'raw-url', etc. How I can query this table & do conversion
> of
> >> the the corresponding columns? I tried to use single quotes around name,
> >> but in this case the name of column itself is returned:
> >>
> >> 0: jdbc:drill:zk=local> select CONVERT_FROM(row_key, 'UTF8') as key,
> >> CONVERT_FROM('urls.u.raw-url', 'UTF8') AS url FROM
> >> hbase.urls WHERE row_key = 'AZ.OC.ICR';
> >> +------------+-----------------+
> >> | key | url |
> >> +------------+-----------------+
> >> | AZ.OC.ICR | urls.u.raw-url |
> >> +------------+-----------------+
> >>
> >> Use of backquotes or double quotes leads to the error.
> >>
> >> - Another question is about data conversion - I have 'status' column
> that
> >> holds integer value (as binary), but when I'm trying to convert it from
> >> binary to INT, then I get value different from stored in the DB:
> >>
> >> For example, for this row I have status field equal to 200 (0xC8)
> >>
> >> hbase(main):004:0> get 'urls', 'AZ.OC.ICR', {COLUMN => 'u'}
> >> COLUMN
> >> CELL
> >>
> >> u:check-td timestamp=1422651539493,
> >> value=2015-01-30T07:53:17Z
> >> u:checked timestamp=1422651539493,
> >> value=\xFF
> >> u:imp-td timestamp=1414402209086,
> >> value=2014-09-11T06:51:41Z
> >> u:raw-url timestamp=1411476725886, value=
> >> http://RCI.CO.ZA
> >> u:status timestamp=1411476725886,
> >> value=\x00\x00\x00\xC8
> >> 5 row(s) in 0.0300 seconds
> >>
> >> But when I do query from Drill, I get some big negative number:
> >>
> >> 0: jdbc:drill:zk=local> select CONVERT_FROM(row_key, 'UTF8') as key,
> >> CONVERT_FROM(urls.u.status, 'INT') AS status FROM hbase.urls WHERE
> row_key
> >> = 'AZ.OC.ICR'
> >> . . . . . . . . . . . > ;
> >> +------------+-------------+
> >> | key | status |
> >> +------------+-------------+
> >> | AZ.OC.ICR | -939524096 |
> >> +------------+-------------+
> >>
> >> What is the correct way of converting binary data into corresponding
> >> representation?
> >>
> >> Thank you
> >>
> >> --
> >> With best wishes, Alex Ott
> >> http://alexott.net/
> >> Twitter: alexott_en (English), alexott (Russian)
> >> Skype: alex.ott
> >>
> >
> >
> >
> > --
> > With best wishes, Alex Ott
> > http://alexott.net/
> > Twitter: alexott_en (English), alexott (Russian)
> > Skype: alex.ott
>
--
With best wishes, Alex Ott
http://alexott.net/
Twitter: alexott_en (English), alexott (Russian)
Skype: alex.ott