Importing data with the Teradata Connector for Hadoop
You can use the Teradata Connector for Hadoop to import data from the Teradata database to Db2 Big SQL.
Before you begin
About this task
Procedure
Example
- Importing data with the Teradata Connector into a Hive table
- Create a new Hive table with sequence file format and import by using five map
tasks.
/usr/hdp/current/sqoop-client/bin/sqoop tdimport --connect jdbc:teradata://tdserver/database=GOSALES --username dbuser --password dbpw --as-sequencefile --hive-table country --map-column-hive "SALESCOUNTRYCODE=int, COUNTRY=string, ISOTHREELETTERCODE=string, ISOTWOLETTERCODE=string, ISOTHREEDIGITCODE=string, CURRENCYNAME=string, EUROINUSESINCE=string" --table COUNTRY --split-by SALESCOUNTRYCODE --num-mappers 5
- Importing data with the Teradata Connector in the Avro format
- To import data between a Teradata database and HDFS, you can specify the file format as Avro by
using the option --as-avrodatafile . When using the option
--as-avrodatafile, you must also specify the Avro schema Teradata property
tdch.output.hdfs.avro.schema.file. For
example:
/usr/hdp/current/sqoop-client/bin/sqoop tdimport -Dtdch.output.hdfs.avro.schema.file=/tmp/data/country.avsc --connect jdbc:teradata://tdserver/database=SALES --username tduser --password tdpw --as-avrodatafile --target-dir /tmp/data/country_avro --table COUNTRY --split-by SALESCOUNTRYCODE --num-mappers 1 - Create a new Hive table and import by using a local password file.
- The password file should contain only the
password.
$SQOOP_HOME/bin/sqoop tdimport --connect jdbc:teradata://tdserver/database=GOSALES --username dbuser --password-file file://home/user1/gosalesl.txt --hive-table country --map-column-hive "SALESCOUNTRYCODE=int, COUNTRY=string, ISOTHREELETTERCODE=string, ISOTWOLETTERCODE=string, ISOTHREEDIGITCODE=string, CURRENCYNAME=string, EUROINUSESINCE=string" --table COUNTRY --split-by SALESCOUNTRYCODE --num-mappers 1 - Create a new Hive table and import by using a password alias.
- The password alias should be created using the hadoop credential
command.
hadoop credential create testit -v somepw -provider jceks://file/tmp/alias.jceks$SQOOP_HOME/bin/sqoop tdimport -Dhadoop.security.credential.provider.path=jceks://file/tmp/alias.jceks --connect jdbc:teradata://tdserver/database=GOSALES --username dbuser --password-alias testit --hive-table country --map-column-hive "SALESCOUNTRYCODE=int, COUNTRY=string, ISOTHREELETTERCODE=string, ISOTWOLETTERCODE=string, ISOTHREEDIGITCODE=string, CURRENCYNAME=string, EUROINUSESINCE=string" --table COUNTRY --split-by SALESCOUNTRYCODE --num-mappers 1