DataStax Help Center

DSE Sqoop CQL import fails with "Didn't match any CQL columns for import against the SQL columns"

Summary

Attempt to import data to Cassandra fails with the exception Didn't match any CQL columns for import against the SQL columns.

Symptoms

The source SQL table USERS contains fields USERID, NAME, EMAIL, BIRTHDAY.

The CQL table is defined as:

CREATE TABLE users (
userid text PRIMARY KEY,
name text
)

With the following import command:

dse sqoop cql-import --connect <jdbc_string> --cassandra-keyspace sqoop_ks --cassandra-table users --cassandra-host localhost --table USERS --split-by USERID --cassandra-column-mapping userid:USERID,name:NAME

import fails with the following exception:

ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: Failed to read the table metadata 
at com.datastax.bdp.sqoop.SqoopUtil.setCqlImportOptions(SqoopUtil.java:222) 
at com.datastax.bdp.sqoop.CqlImportJob.configureOutputFormat(CqlImportJob.java:76) 
at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:232) 
at com.datastax.bdp.sqoop.SqlManagerAdapter.importQuery(SqlManagerAdapter.java:243) 
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:415) 
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:502) 
at org.apache.sqoop.Sqoop.run(Sqoop.java:145) 
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) 
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181) 
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220) 
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229) 
at org.apache.sqoop.Sqoop.main(Sqoop.java:238) 
at com.cloudera.sqoop.Sqoop.main(Sqoop.java:57) 
Caused by: java.io.IOException: Didn't match any CQL columns for import against the SQL columns 
at com.datastax.bdp.sqoop.SqoopUtil.setCqlImportOptions(SqoopUtil.java:203)

Cause

By default, Sqoop selects all the columns of a table for import as documented in the Sqoop User Guide. In the example above, the source SQL table USERS has 4 columns but the destination Cassandra table users only has 2.

Solution

Modify the Sqoop command to explicitly specify the columns to import with the --columns argument. For the example above, the resulting command should be:

dse sqoop cql-import --connect <jdbc_string> --cassandra-keyspace sqoop_ks --cassandra-table users --cassandra-host localhost --table USERS --split-by USERID --cassandra-column-mapping userid:USERID,name:NAME --columns USERID,NAME

With this update, the import should complete successfully.

See also

Apache doc - Sqoop User Guide

DataStax doc - Sqoop > Importing SQL to a CQL table or CFS

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk