1

I already have mySql database tables imported to hdfs using sqoop. The database gets updated daily. Now I tried importing data incrementally using sqoop as

sqoop import --connect jdbc:mysql://127.0.0.1/crawl_data_stats --username root --password password --table scraped_comments -m 1 --as-parquetfile --target-dir /databases/crawl_data_stats/scraped_comments --check-column timestamp --incremental lastmodified --last-value '2019-05-16 13:06:31' --driver com.mysql.jdbc.Driver

However the import fails with following output:

19/06/13 12:51:28 INFO manager.SqlManager: Using default fetchSize of 1000  
19/06/13 12:51:28 INFO tool.CodeGenTool: Beginning code generation  
19/06/13 12:51:28 INFO tool.CodeGenTool: Will generate java class as codegen_scraped_comments  
Thu Jun 13 12:51:28 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.  
19/06/13 12:51:29 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM scraped_comments AS t WHERE 1=0  
19/06/13 12:51:29 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM scraped_comments AS t WHERE 1=0  
19/06/13 12:51:29 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/local/hadoop  
Note: /tmp/sqoop-root/compile/8ccf132bb0ce002d14d2afeb75f85cf9/codegen_scraped_comments.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.  
19/06/13 12:51:31 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/8ccf132bb0ce002d14d2afeb75f85cf9/codegen_scraped_comments.jar  
19/06/13 12:51:32 ERROR tool.ImportTool: Import failed: --merge-key or --append is required when using --incremental lastmodified and the output directory exists.  
Nadeem Mehraj
  • 174
  • 1
  • 2
  • 15

1 Answers1

1

The error went away on adding merge-key option to sqoop import command

sqoop import --connect jdbc:mysql://127.0.0.1/crawl_data_stats --username root --password password --table scraped_metadata -m 1 --as-parquetfile --target-dir /databases/crawl_data_stats/scraped_metadata --check-column timestamp --incremental lastmodified --last-value '2019-05-16 13:06:31' --driver com.mysql.jdbc.Driver --merge-key id
Nadeem Mehraj
  • 174
  • 1
  • 2
  • 15