sqoop在hdfs中导入的序列文件未在配置单元中读取

bqjvbblv  于 2021-06-03  发布在  Sqoop
关注(0)|答案(1)|浏览(437)

我使用--as sequencefile选项将一个表从mysql导入到hdfs中。然后我创建了一个hive表,其中包含storedassequencefile子句和location子句,它们指向sqoop导入的序列文件所在的hdfs位置。
sqoop导入命令:

sqoop import --connect jdbc:mysql://sandbox.hortonworks.com:3306/hirw --username root --password hadoop --table stocks -m 2 --as-sequencefile  --target-dir /user/root/output/hirw/sqoopimport/stocks_seq --delete-target-dir

配置单元表创建

CREATE TABLE stocks_sqoop_seq (id int, symbol string, name string, trade_date date, close_price float, volume int, update_time timestamp)  STORED AS SEQUENCEFILE LOCATION '/user/root/output/hirw/sqoopimport/stocks_seq';

当我现在尝试查询表时,它异常地失败了

Failed with exception java.io.IOException:java.lang.RuntimeException: java.io.IOException: WritableName can't load class: stocks

我错过什么了吗

pftdvrlh

pftdvrlh1#

您还必须声明输入和输出格式。创建如下表:

CREATE TABLE stocks_sqoop_seq (
  id int, symbol string, 
  name string, trade_date date, 
  close_price float, volume int, 
  update_time timestamp)  
STORED AS SEQUENCEFILE 
STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.SequenceFileInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat'
LOCATION '/user/root/output/hirw/sqoopimport/stocks_seq'\;

相关问题