You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Andre Araujo <ar...@pythian.com> on 2013/12/19 07:17:38 UTC

Typecasting arrays

Hi, all,

Is there a way to typecast arrays in hive? What I want is that for a
specific select, where I specify and empty array as the value for one of
the columns, for Hive to treat the empty array as array<bigint>, instead of
the default, which is array<string>.

I searched the documentation but couldn't find any reference to casting
arrays. I also tried a few different combinations of the CAST function, but
neither worked for arrays.

Thanks,
Andre

-- 
André Araújo
The Pythian Group - Australia - www.pythian.com

Office (calls from within Australia): 1300 366 021 x1270
Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696   x1270
Mobile: +61 410 323 559
Fax: +61 2 9805 0544
IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk

“Success is not about standing at the top, it's the steps you leave behind.”
— Iker Pou (rock climber)

-- 


--




Re: Typecasting arrays

Posted by Nitin Pawar <ni...@gmail.com>.
I normally set default value to 0 if its empty


On Thu, Dec 19, 2013 at 12:04 PM, Andre Araujo <ar...@pythian.com> wrote:

> Thanks, Nitin.
>
> More specifically, what about empty arrays? How can I convince Hive that
> an empty array -- array() -- has a type of array<bigint>?
>
> Thanks again!
> Andre'
>
>
> On 19 December 2013 17:22, Nitin Pawar <ni...@gmail.com> wrote:
>
>> from what I know, There is no direct way to type cast array directly as
>> of now. If its added now then well and good
>>
>> I normally typecast individual element of the array and then join them
>> back (mostly via udf).
>>
>> I will see if I can find that code
>>
>>
>> On Thu, Dec 19, 2013 at 11:47 AM, Andre Araujo <ar...@pythian.com>wrote:
>>
>>> Hi, all,
>>>
>>> Is there a way to typecast arrays in hive? What I want is that for a
>>> specific select, where I specify and empty array as the value for one of
>>> the columns, for Hive to treat the empty array as array<bigint>, instead of
>>> the default, which is array<string>.
>>>
>>> I searched the documentation but couldn't find any reference to casting
>>> arrays. I also tried a few different combinations of the CAST function, but
>>> neither worked for arrays.
>>>
>>> Thanks,
>>> Andre
>>>
>>> --
>>> André Araújo
>>> The Pythian Group - Australia - www.pythian.com
>>>
>>> Office (calls from within Australia): 1300 366 021 x1270
>>> Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696
>>> x1270
>>> Mobile: +61 410 323 559
>>> Fax: +61 2 9805 0544
>>> IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk
>>>
>>> “Success is not about standing at the top, it's the steps you leave
>>> behind.” — Iker Pou (rock climber)
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Nitin Pawar
>>
>
>
>
> --
> André Araújo
> Database Administrator / SDM
>
> The Pythian Group - Australia - www.pythian.com
>
> Office (calls from within Australia): 1300 366 021 x1270
> Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696   x1270
> Mobile: +61 410 323 559
> Fax: +61 2 9805 0544
> IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk
>
> “Success is not about standing at the top, it's the steps you leave behind.”
> — Iker Pou (rock climber)
>
> --
>
>
>
>


-- 
Nitin Pawar

Re: Typecasting arrays

Posted by Andre Araujo <ar...@pythian.com>.
Thanks, Nitin.

More specifically, what about empty arrays? How can I convince Hive that an
empty array -- array() -- has a type of array<bigint>?

Thanks again!
Andre'


On 19 December 2013 17:22, Nitin Pawar <ni...@gmail.com> wrote:

> from what I know, There is no direct way to type cast array directly as of
> now. If its added now then well and good
>
> I normally typecast individual element of the array and then join them
> back (mostly via udf).
>
> I will see if I can find that code
>
>
> On Thu, Dec 19, 2013 at 11:47 AM, Andre Araujo <ar...@pythian.com> wrote:
>
>> Hi, all,
>>
>> Is there a way to typecast arrays in hive? What I want is that for a
>> specific select, where I specify and empty array as the value for one of
>> the columns, for Hive to treat the empty array as array<bigint>, instead of
>> the default, which is array<string>.
>>
>> I searched the documentation but couldn't find any reference to casting
>> arrays. I also tried a few different combinations of the CAST function, but
>> neither worked for arrays.
>>
>> Thanks,
>> Andre
>>
>> --
>> André Araújo
>> The Pythian Group - Australia - www.pythian.com
>>
>> Office (calls from within Australia): 1300 366 021 x1270
>> Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696
>> x1270
>> Mobile: +61 410 323 559
>> Fax: +61 2 9805 0544
>> IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk
>>
>> “Success is not about standing at the top, it's the steps you leave
>> behind.” — Iker Pou (rock climber)
>>
>> --
>>
>>
>>
>>
>
>
> --
> Nitin Pawar
>



-- 
André Araújo
Database Administrator / SDM
The Pythian Group - Australia - www.pythian.com

Office (calls from within Australia): 1300 366 021 x1270
Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696   x1270
Mobile: +61 410 323 559
Fax: +61 2 9805 0544
IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk

“Success is not about standing at the top, it's the steps you leave behind.”
— Iker Pou (rock climber)

-- 


--




Re: Typecasting arrays

Posted by Nitin Pawar <ni...@gmail.com>.
from what I know, There is no direct way to type cast array directly as of
now. If its added now then well and good

I normally typecast individual element of the array and then join them back
(mostly via udf).

I will see if I can find that code


On Thu, Dec 19, 2013 at 11:47 AM, Andre Araujo <ar...@pythian.com> wrote:

> Hi, all,
>
> Is there a way to typecast arrays in hive? What I want is that for a
> specific select, where I specify and empty array as the value for one of
> the columns, for Hive to treat the empty array as array<bigint>, instead of
> the default, which is array<string>.
>
> I searched the documentation but couldn't find any reference to casting
> arrays. I also tried a few different combinations of the CAST function, but
> neither worked for arrays.
>
> Thanks,
> Andre
>
> --
> André Araújo
> The Pythian Group - Australia - www.pythian.com
>
> Office (calls from within Australia): 1300 366 021 x1270
> Office (international): +61 2 8016 7000  x270 *OR* +1 613 565 8696   x1270
> Mobile: +61 410 323 559
> Fax: +61 2 9805 0544
> IM: pythianaraujo @ AIM/MSN/Y! or araujo@pythian.com @ GTalk
>
> “Success is not about standing at the top, it's the steps you leave behind.”
> — Iker Pou (rock climber)
>
> --
>
>
>
>


-- 
Nitin Pawar