在配置单元中使用csv文件将数据插入表

sg3maiej  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(443)
  1. CREATE TABLE `rk_test22`(
  2. `index` int,
  3. `country` string,
  4. `description` string,
  5. `designation` string,
  6. `points` int,
  7. `price` int,
  8. `province` string,
  9. `region_1` string,
  10. `region_2` string,
  11. `taster_name` string,
  12. `taster_twitter_handle` string,
  13. `title` string,
  14. `variety` string,
  15. `winery` string)
  16. ROW FORMAT SERDE
  17. 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
  18. WITH SERDEPROPERTIES (
  19. 'input.regex'=',(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)')
  20. STORED AS INPUTFORMAT
  21. 'org.apache.hadoop.mapred.TextInputFormat'
  22. OUTPUTFORMAT
  23. 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
  24. LOCATION
  25. 'hdfs://namever/user/hive/warehouse/robert.db/rk_test22'
  26. TBLPROPERTIES (
  27. 'COLUMN_STATS_ACCURATE'='true',
  28. 'numFiles'='1',
  29. 'skip.header.line.count'='1',
  30. 'totalSize'='52796693',
  31. 'transient_lastDdlTime'='1516088117');

我使用上面的命令创建了配置单元表。现在我想使用loaddata命令将以下行(在csv文件中)加载到表中。LOADDATA命令显示status ok,但我看不到该表中的数据。

  1. 0,Italy,"Aromas include tropical fruit, broom, brimstone and dried herb. The palate isn't overly expressive, offering unripened apple, citrus and dried sage alongside brisk acidity.",Vulkà Bianco,87,,Sicily & Sardinia,Etna,,Kerin OKeefe,@kerinokeefe,Nicosia 2013 Vulkà Bianco (Etna),White Blend,Nicosia
oxalkeyp

oxalkeyp1#

如果您正在加载一行csv文件,则由于以下属性,将跳过该行: 'skip.header.line.count'='1' regex还应该为每列包含一个捕获组。就像这样的回答:https://stackoverflow.com/a/47944328/2700344
为什么在ddl表中提供这些设置:

  1. 'COLUMN_STATS_ACCURATE'='true'
  2. 'numFiles'='1',
  3. 'totalSize'='52796693',
  4. 'transient_lastDdlTime'='1516088117'

所有这些都应该在ddl和analyze之后自动设置。

相关问题