goks
goks

Reputation: 1206

Sqoop export from hdfs to GreenPlum is not working

I am trying to export data from hdfs location to Greenplum user defined schema (not default schema).

Tried Sqoop Eval to check the connection.

sqoop eval --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sample_user --password xxxx --query "SELECT * FROM sample_db.sample_table LIMIT 3"

Result: working fine

Tried with --schema option

/usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert

Result:

Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:09:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:09:41 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Error parsing arguments for export:
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: sample_schema
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --export-dir=/sample/gp_export
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --input-fields-terminated-by
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: ,
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: --update-mode
18/06/25 11:09:41 ERROR tool.BaseSqoopTool: Unrecognized argument: allowinsert

Added extra '--' before '--schema' based on the sqoop documentation https://sqoop.apache.org/docs/1.4.3/SqoopUserGuide.html

 /usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb" --username sampleuser --password samplepassword --table sample_table -- --schema sample_schema --export-dir=/sample/gp_export --input-fields-terminated-by ',' --update-mode allowinsert

Result:

Warning: /usr/hdp/2.3.6.0-3796/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
18/06/25 11:06:26 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.6.0-3796
18/06/25 11:06:26 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
Export requires an --export-dir argument or --hcatalog-table argument.
Try --help for usage instructions.

Could someone guide me on this. Thanks

Upvotes: 1

Views: 869

Answers (2)

goks
goks

Reputation: 1206

Thanks to @cricket_007 for clarification.

--schema argument should be last in the sqoop command. So below code is working.

    /usr/bin/sqoop export --connect "jdbc:postgresql://sample.com:5432/sampledb"  \ 
--username sampleuser --password samplepassword  \ 
--export-dir=/sample/gp_export --input-fields-terminated-by ','  \ 
--table sample_table -- --schema sample_schema

But UPSERT operations not supported in postgresSql. There is an open Jira ticket here. https://issues.apache.org/jira/browse/SQOOP-1270

Upvotes: 1

roh
roh

Reputation: 1053

After the --export-dir you don't need the = check out the example below. Another suggestion is to use --verbose when you run into these kinds of issues.

sqoop export --libjars /path/some.jar \
--connect 'jdbc:sqlserver://IP:1433;database=db' \
--username someName -password somePassword -m 10 \
--verbose --mysql-delimiters \
--export-dir /HDFS/Path/someFile.csv \
--table "RDBMSTABLENAME"

Upvotes: 0

Related Questions