You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by mahender bigdata <Ma...@outlook.com> on 2016/02/18 13:18:55 UTC

Stroing boolean value in Hive table

Hi,

How can we store Boolean value with 1 or 0 instead of storing true or 
false string. we can make use of CAST function to convert boolean into 1 
or 0. Is there any built-in setting in hive, which enable and store hive 
Boolean column values in 0 or 1 instead of true and false.




Re: Stroing boolean value in Hive table

Posted by mahender bigdata <Ma...@outlook.com>.
Hi Alan,

Thanks for answering. In HDi 3.1, boolean variables are stored as 0 or 1 
, but from HDI 3.3 , we see Boolean variables are stored as True or 
False in Hive External Table ( i.e Hive File data). Cast or Case will 
work definitely, I'm thinking of any hive setting available to store 1 
or 0 instead of True or False string.



On 2/18/2016 8:56 AM, Alan Gates wrote:
> How the data is stored is up to the storage format (text, rcfile, orc, etc.).  Do you mean in your text file you’d like booleans stored as 0 or 1?  You could use the case statement to convert them to integers like:
>
> select case _boolvar_ when true then 1 when false then 0 end from …
>
> Alan.
>
>> On Feb 18, 2016, at 04:18, mahender bigdata <Ma...@outlook.com> wrote:
>>
>> Hi,
>>
>> How can we store Boolean value with 1 or 0 instead of storing true or false string. we can make use of CAST function to convert boolean into 1 or 0. Is there any built-in setting in hive, which enable and store hive Boolean column values in 0 or 1 instead of true and false.
>>
>>
>>


Re: Stroing boolean value in Hive table

Posted by Alan Gates <al...@gmail.com>.
How the data is stored is up to the storage format (text, rcfile, orc, etc.).  Do you mean in your text file you’d like booleans stored as 0 or 1?  You could use the case statement to convert them to integers like:

select case _boolvar_ when true then 1 when false then 0 end from …

Alan.

> On Feb 18, 2016, at 04:18, mahender bigdata <Ma...@outlook.com> wrote:
> 
> Hi,
> 
> How can we store Boolean value with 1 or 0 instead of storing true or false string. we can make use of CAST function to convert boolean into 1 or 0. Is there any built-in setting in hive, which enable and store hive Boolean column values in 0 or 1 instead of true and false.
> 
> 
>