Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

boolean filed is not working in Hive

boolean filed is not working in Hive

New Contributor

Hello community,

I have a column in my hive table which datatype is boolean. when I tried to import data from csv , it stored as NULL.

this is my sample table :

CREATE tABLE if not exists Engineanalysis(

EngineModel String,

EnginePartNo String ,

Location String,

Position String,

InspectionReq boolean)

ROW FORMAT DELIMITED

FIELDS TERMINATED BY ','

LINES TERMINATED BY '\n';

My sample data :

AB01,AS01-IT01,AIRFRAME,,0

AB02,AS01-IT02,AIRFRAME,,1

AB03,AS01-IT03,AIRFRAME,,1

AB04,AS01-IT04,AIRFRAME,,1

AB05,AS01-IT05,HEAD,,1

AB06,AS01-IT06,HEAD,,0

AB07,AS01-IT07,HEAD,,0

AB08,AS01-IT08,HEAD,,0

AB09,AS01-IT09,NOSE,,1

AB10,AS01-IT10,NOSE,,0


Result :

AB01 AS01-IT01 AIRFRAME NULL

AB02 AS01-IT02 AIRFRAME NULL

AB03 AS01-IT03 AIRFRAME NULL

AB04 AS01-IT04 AIRFRAME NULL

AB05 AS01-IT05 HEAD NULL

AB06 AS01-IT06 HEAD NULL

AB07 AS01-IT07 HEAD NULL

AB08 AS01-IT08 HEAD NULL

AB09 AS01-IT09 NOSE NULL

AB10 AS01-IT10 NOSE NULL

when loading manually :

insert into Engineanalysis select 'AB11','AS01-IT11','AIRFRAME','',0;

Result:

AB11 AS01-IT11 AIRFRAME false


can someone explain why this dissimilarity?

1 REPLY 1

Re: boolean filed is not working in Hive

Super Mentor

@krishna raj

Have you tried setting this property to true?

"hive.lazysimple.extended_boolean_literal":

  • Default Value: false
  • Added in: Hive 0.14 with HIVE-3635

LazySimpleSerDe uses this property to determine if it treats 'T', 't', 'F', 'f', '1', and '0' as extended, legal boolean literals, in addition to 'TRUE' and 'FALSE'. The default is false, which means only 'TRUE' and 'FALSE' are treated as legal boolean literals.

See: https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties

.

Also please refer to the following link to know how to set "hive.lazysimple.extended_boolean_literal" to "true" while creating the Hive Tables. Like:

CREATE TABLE ........ [TBLPROPERTIES ("hive.lazysimple.extended_boolean_literal"="true")];

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL

.