Error : java.lang.RuntimeException: Can’t parse input data: ‘NULL’

When we execute a sqoop export action via oozie  (moving data from hdfs to mysql ) using the tag <command>, we may come across the error java.lang.RuntimeException: Can’t parse input data: ‘NULL’.  This sqoop export  command, which was executed successfully though terminal, may raise this issue, when it is combined with oozie.

The fix for the above issue is to remove all the single/double quotes from the command.                                              eg : Instead of –input-null-string ‘NULL’, we need to use –input-null-string NULL                                                  

A working command is added below :                                                

<command>export –connect jdbc:mysql://localhost/demo –username root –password mysql123 –table calc_match_out –input-null-string NULL –input-null-non-string NULL -m 1 –input-fields-terminated-by ; –input-lines-terminated-by \n –export-dir /user/ambari-qa/output/output-calc/part-r-00000</command>

The reason why this fix is working can be interpreted from the following excerpts taken from the blog

Sqoop command:
The Sqoop command can be specified either using the command element or multiple arg elements.
– When using the command element, Oozie will split the command on every space into multiple arguments.- When using the arg elements, Oozie will pass each argument value as an argument to Sqoop.  The arg variant should be used when there are spaces within a single argument.  – All the above elements can be parameterized (templatized) using EL expressions.

Also I think the following apache documentation on sqoop is of high relevance for beginners in sqoop domain :

Sqoop features

 The sqoop action runs a Sqoop job synchronously.- The information to be included in the oozie sqoop action  are the job-tracker, the name-node and Sqoop command or arg elements as well as configuration.- A prepare node can be included to do any prep work including hdfs actions.  This will be executed prior to execution of the sqoop job.- Sqoop configuration can be specified with a file, using the job-xml element, and inline, using the configuration elements.- Oozie EL expressions can be used in the inline configuration. Property values specified in the configuration element override values specified in the job-xml file.
Note that Hadoop mapred.job.tracker and properties must not be present in the inline configuration. As with Hadoop map-reduce jobs, it is possible to add files and archives in order to make them available to the Sqoop job. 

Undefined vs Null vs NaN – Javascript

If you have tried to develop atleast one application in javascript,  you might have come across these kind of things.  (probability is 1..though my knowledge in probability is really pathetic). I still remember the confusion I had regarding these three terms, when I stepped in to the world of javascript.  The following are my assumptions about  the perplexing trios in javascipt — undefined, null, and NaN.

undefined  :  Th-is can act as both a type and a value. A variable that has been declared and has not been assigned  with a value is undefined always.

For example –

var tmp;    //  just declared, not assigned with a value

console.log(tmp) ;    ———————-> undefined

console.log( typeof tmp );———————-> “undefined”

From this it is clear that value of tmp is undefined. and its type also is undefined. but this is an undefined enclosed by quotes.

Null    : is a  primitive value in javascript  whose type is Object.

var a=null;

console.log(a);  —————————-> null

console.log( typeof  a );  ———————-> Object

Still there will be some confusion for some of you. I had undergone this phase. So I would like to summarize it as follows.

Undefined  comes into play  when javascript does not know much about that variable. ie Its type is not known. It has never been referenced before.  javascript is not  even sure about its existance. On the other hand null comes into the scenario when a variable is known to exist(type is known). But its value is not known.

NaN (Not a Number)

It is the value returned as a result when an invalid arithmetic operation is performed. Its type is Number. It is value.

For example :

var  tmp = 10 / ten                    // invalid arithmetic operation

console.log(tmp)   —————————>  NaN

Now we need to understand another important concept about NaN ………………….

                                  Two NaNs are not at all equal in normal comparisons!!!!!!!

This would be clear from the following example.

var  tmp2 = 10 / ten                    // invalid arithmetic operation

console.log(tmp2)   —————————>  NaN

if (tmp == tmp2)   ——————————–> false

Normally what we are expecting for above operation , is a true value. But Its result is false. But What if we need to compare two NaN values? For that purpose we need to make of the built in method isNaN() . It returns a true value when a NaN value is fed as an input.

For example, in the previous cases we have seen

isNaN(tmp)  ——————————> true

isNaN(tmp2) ——————————-> true

For comparing these two NaNs

if ( isNaN(tmp) && isNaN(tmp2) )   ——————————> true

Now we can compare two NaN values successfully.