【问题标题】:How to import parquet data from S3 into HDFS using Sqoop?如何使用 Sqoop 将 Parquet 数据从 S3 导入 HDFS?
【发布时间】:2021-11-05 12:22:12
【问题描述】:
我正在尝试将数据导入 RDS 中的表。数据采用 parquet 文件格式,存在于 s3 中。
我想过使用Sqoop将s3中的数据导入HDFS,然后使用Sqoop将其导出到RDS表中。我能够找到将数据从 HDFS 导出到 RDS 的命令。但我找不到从 S3 导入镶木地板数据的方法。在这种情况下,您能否帮助了解如何构造sqoop import 命令。
【问题讨论】:
标签:
hadoop
amazon-s3
hdfs
parquet
sqoop
【解决方案2】:
对我来说似乎最简单和最好的方法如下:
- 在 Hive 中创建 Parquet 表并使用来自 S3 的 Parquet 数据加载它
create external table if not exists parquet_table(<column name> <column's datatype>) stored as parquet;
LOAD DATA INPATH 's3a://<bucket_name>/<parquet_file>' INTO table parquet_table
- 在 Hive 中创建一个 CSV 表并使用 Parquet 表中的数据加载它
create external table if not exists csv_table(<column name> <column's datatype>)
row format delimited fields terminated by ','
stored as textfile
location 'hdfs:///user/hive/warehouse/csvdata'
- 现在我们在 Hive 中有一个 CSV/Textfile 表,Sqoop 可以轻松地将表从 HDFS 导出到 MySQL 表 RDS。
export --table <mysql_table_name> --export-dir hdfs:///user/hive/warehouse/csvdata --connect jdbc:mysql://<host>:3306/<db_name> --username <username> --password-file hdfs:///user/test/mysql.password --batch -m 1 --input-null-string "\\N" --input-null-non-string "\\N" --columns <column names to be exported, without whitespace in between the column names>