sqoop:从mysql导入到hive时是否替换字符?

hsvhsicv  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(448)

当从mysql导入数据到hive时,我需要删除两个字符 +7 在电话号码里。以下请求返回sql错误。正确答案是什么 replace 我应该使用命令吗? sqoop import --connect jdbc:mysql://server/db --username x --password yyyy --query 'select name, last_name, email, second_name, Replace(personal_phone, '+7', ''), Replace(mobile, '+7', ''), Replace(phone, '+7', '') from user where $CONDITIONS' --target-dir /data/test -m 1 --null-string '\\N' --null-non-string '\\N' --hive-import --hive-table user_inf

jaxagkaj

jaxagkaj1#

这个对我有用: sqoop import --connect jdbc:mysql://server/db --username x --password yyyy --query "select name, last_name, email, second_name, Replace(phone, "+7", '') as phone, Replace(mobile, "+7", '') as mobile from test where \$CONDITIONS" --target-dir /data/test -m 1 --null-string '\\N' --null-non-string '\\N' --hive-import --hive-table info

vc9ivgsu

vc9ivgsu2#

这个 REPLACE 命令看起来正确。错误可能是因为引号,因为您在开头使用了单引号。我在sql查询中将它改为双引号。现在应该可以了: sqoop import --connect jdbc:mysql://server/db --username x --password yyyy --query "select name, last_name, email, second_name, Replace(personal_phone, '+7', ''), Replace(mobile, '+7', ''), Replace(phone, '+7', '') from user where $CONDITIONS" --target-dir /data/test -m 1 --null-string '\\N' --null-non-string '\\N' --hive-import --hive-table user_inf

相关问题