Sqoop import is picking all the records instead of limit specified in --query

24 views Asked by At

I'm trying to do a sqoop import from postgres table to hdfs, I'm able to import data but the sqoop SQL manager is picking all records from the table even though I specified a limit at --query.

sqoop import --connect jdbc:postgres://serverdetails:port/database
--username abc -P
--table tablename --query "SELECT col1, col2 FROM tablename order by col2 desc limit 1" --as-textfile
--target-dir /path/in/hdfs
--fields-terminated-by ','
--lines-terminated-by '\n'
--num-mappers 1
--libjars /path/libjars/.jar
--header
--direct

From the above query I'm getting all the columns (assume 5) and all the records from psql table, but I want only 2 column with 1 records and also I'm not getting header along the data from table.

I explored in sqoop user guide(v1.4.6) but not able to find exact query..can someone suggest where I missed..

0

There are 0 answers