Recently because of work requirements, schedule tasks required by hue, use sqoop import data. Import Script statement is as follows
sqoop import --connect jdbc:oracle:thin:@ip:port/db --username user --password pwd --query "select col1,col2 from db.table where \$CONDITIONS" --target-dir /user/kjxydata/src/LT_READER_${date_time} --delete-target-dir -m 1 --null-string '\\N' --null-non-string '\\N' --as-textfile --fields-terminated-by "\t" --hive-drop-import-delims
However, run-time error.
In writing sqoop import statement with hue, there are a few pit.
- 1, in the command window, do not add sqoop, beginning from import.
- 2, command window, use the query is problematic. For the sql query, because the hue calls oozie, oozie when parsing sql commands will be broken down into a number of parameters, rather than as an argument, it will not lead to parse command is run.
For the second question, the current tea to two solutions:
- 1, the direct use ssh to run the script in hue
- 2, an empty block command command, command parameters and enter the box
In order to maintain a consistent command all sqoop forms, individual second approach. Specific solutions Figure:
, Pay attention to the query in a written statement in arg.
Another point, note that select col1,col2 from db.table where \$CONDITIONS
, if used in sqoop need to add a query where $CONDITIONS
, if a script using the plus remember \
, but do not add the parameter window \
.
Details can also refer to this cloudera questions . After the contents of the xml relatively clear.