Search code examples
hadoophivesqoopclouderahortonworks-data-platform

Sqoop incremental import argument order?


I am trying to import an incremental load using sqoop from mysql. Below is the command I am running on unix console:

    sqoop job \
    --create sample_job --import -Dmapred.job.queue.name=realtime \
    --connect jdbc:mysql://hostname/db?zeroDateTimeBehavior=convertToNull \
    --driver com.mysql.jdbc.Driver \
    --table SAMPLE_TABLE -m 1 \
    --username tony \
    --password stark \
    --incremental lastmodified \
    --check-column ts \
    --last-value 2018-04-24 \
    --target-dir /some/tmp/location/ \
    --map-column-hive XYZ=tinyint \
    --null-string '\\N' \
    --null-non-string '\\N'

But, getting a typical argument error :

     /usr/hdp/2.6.4.0-91//sqoop/conf/sqoop-env.sh: line 21: HADOOP_CLASSPATH=${hcat -classpath}: bad substitution
     Warning: /usr/hdp/2.6.4.0-91/accumulo does not exist! Accumulo imports will fail.
     Please set $ACCUMULO_HOME to the root of your Accumulo installation.
     18/04/25 11:24:52 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.6.4.0-91
     18/04/25 11:24:52 ERROR tool.BaseSqoopTool: Error parsing arguments for job:

I found lot of resources available which show how to run imports with commands but most sources do not show the exact command lines and have improper arguments passed. I saw somewhere that the order of arguments matter , and so tried switching the order but didnt work. It is a simple issue so can someone tell me the proper syntax ?

Thanks in advance.


Solution

  • I think you have a problem with your syntax. https://sqoop.apache.org/docs/1.4.0-incubating/SqoopUserGuide.html#id1769640

    $ sqoop job --create myjob -- import --connect jdbc:mysql://example.com/db \
    --table mytable
    enter code here
    

    There a space between first parameter, replace your command with a space before import parameter.

    sqoop job \
    --create sample_job -- import -Dmapred.job.queue.name=realtime \
    --connect jdbc:mysql://hostname/db?zeroDateTimeBehavior=convertToNull \
    --driver com.mysql.jdbc.Driver \
    --table SAMPLE_TABLE -m 1 \
    --username tony \
    --password stark \
    --incremental lastmodified \
    --check-column ts \
    --last-value 2018-04-24 \
    --target-dir /some/tmp/location/ \
    --map-column-hive XYZ=tinyint \
    --null-string '\\N' \
    --null-non-string '\\N'