Sqoop 将特定列从 hdfs 导出到 mysql 无法正常工作 [英] Sqoop Export specific columns from hdfs to mysql is not working properly

查看:31
本文介绍了Sqoop 将特定列从 hdfs 导出到 mysql 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 HDFS 文件包含 5 列.

My HDFS file contains 5 columns.

emp_no,birth_date,first_name,last_name,hire_date

我只想导出 3 列:

emp_no,first_name,last_name

我正在这样做

sqoop export
  --connect jdbc:mysql://mysql.example.com/sqoop
  --username sqoop
  --password sqoop
  --table employees
  --columns "emp_no,first_name,last_name"
  --export-dir /user/dataset/employees

但我在 MySQL 表中得到 emp_nobirth_datefirst_name.

But I am getting emp_no,birth_date and first_name in MySQL table.

我的表中有 3 列,但在 sqoop export

I am getting 3 columns in my table but one column I want to skip is not happening with --columns in sqoop export

推荐答案

我解决了我的问题.其实我误解了选项 --columns 用于导出.

I solved my problem. Actually I misunderstood option --columns for export.

使用 --columns 导出选项,我们可以选择列的子集或控制表列(或目标,例如 mysql 列)而不是 HDFS 列的顺序.

With --columns option for export, we can select subset of columns or control ordering of the table columns(or destination e.g mysql columns) not the HDFS columns.

此选项决定 HDFS 源列与目标表的 --columns 选项中提到的列的绑定.

This option decides binding of HDFS source columns with columns mentioned in --columns option of the destination table.

例如如果我在 sqoop 命令中提到 --columns "col2,col3,col1"其中 col1,col2,col3 是 mysql 表的列

e.g. if I mention --columns "col2,col3,col1" in sqoop command where col1,col2,col3 are mysql table's columns

然后它将 col2 与 HDFS 源的第一列绑定,col3 与 HDFS 源的第二列绑定,依此类推..

Then it will bind col2 with first column of the HDFS source and col3 with second column of the HDFS source and so on..

这篇关于Sqoop 将特定列从 hdfs 导出到 mysql 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆