drill-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aditya <adityakish...@gmail.com>
Subject Re: convert_from example
Date Mon, 24 Nov 2014 23:55:31 GMT
To expand on Steven's answer, you can use CAST() if the data is either
(1)stored as text or (2) in its native internal format but is differently
typed, for example (1)a double value 1234.56 is stored in a CSV file as
..., "1234.56", ...., or (2) a to use a Long value as TIMESTAMP.

OTOH, convert_from() helps you to interpret data encoded in some binary
format, i.e. a VARBINARY column which contains Integer as 4 bytes little
endian 32 encoding (1 = 01 00 00 00).

On Mon, Nov 24, 2014 at 3:24 PM, Steven Phillips <sphillips@maprtech.com>
wrote:

> It depends on how the value is encoded. Possible encodings include, e.g.
> little endian, big endian, and UTF8 string.
>
> select convert_from(row_key, 'INT'); // for little endian encoding
> select convert_from(row_key, 'INT_BE'); // for big endian encoding
> select cast(convert_from(row_key, 'UTF8') as int); // for utf8 string
> encoding
>
> On Mon, Nov 24, 2014 at 3:09 PM, carol Bourgade <cjbourgade@gmail.com>
> wrote:
>
> > can someone give an example using convert_from instead of cast in the
> > following query on an HBase table :
> >
> > select cast(row_key as int) as cust_id
> > from hbase.customers t ;
> >
>
>
>
> --
>  Steven Phillips
>  Software Engineer
>
>  mapr.com
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message