Apache Pig doesn't respect ELSE statement when value is NULL -


when checking value in case statement in apache pig else routine ignored when 1 of values in condition null.

so in example below, when either or b null value a_equals_b null in output rather 0.

input = load '/data/input.csv' using pigstorage() (a:chararray, b:chararray); output = foreach input generate     case         when == b 1         else 0     end a_equalsb; 

it design? best work around these issues? add checks nulls separately, adds lot of bloat in script.

unfortunately, design, yes. in pig, every expression dealing null result in null, should check these values in code. there list of happens nulls in the official documentation.

arithmetic operators: if either subexpression null, resulting expression null.

  • , -, *, /
  • % modulo
  • ? : bincond
  • case : case

the best workaround said, checking nulls is null , is not null operators. generate messy lines of code when possibility of many null values exist unfortunately there no other solution @ moment.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -