如何将 Sqoop 导入命令与 --map-column-hive 一起使用? [英] How to use Sqoop import command with --map-column-hive?

查看:40
本文介绍了如何将 Sqoop 导入命令与 --map-column-hive 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Teradata 中的数据 Sqoop 到 hive.我想到了以下步骤:

I'm trying to Sqoop the data from Teradata to hive. I thought of following the below steps:

1) 创建一个 Hive 表,其中包含 Hue 中的所有必填字段.
2) 通过使用 Sqoop 导入命令和 --map-column-hive 属性将数据从 Teradata 加载到 hive.

1) Create a Hive table with all the required fields in Hue.
2) By using Sqoop import command along with --map-column-hive attribute to load the data from Teradata to hive .

如何从Sqoop导入命令中指向已经创建好的Hive表,让Sqooped的数据放到对应的Hive表中?

How to point to the already created Hive table from Sqoop import command, so that the Sqooped data should be placed in the corresponding Hive table?

推荐答案

您可以使用 shell 和 awk 从现有表中生成 map-column-hive 属性.它将以 COL1=TYPE,COL2=TYPE,...COLN=TYPE

You can generate map-column-hive attribute from existing table using shell and awk. it will be generated in the form COL1=TYPE,COL2=TYPE,...COLN=TYPE

#!/bin/bash

#Set table name here
TABLE_NAME=your_schema.your_table

#generate map from existing table
MAP_COLUMN_HIVE=$(hive -S -e "set hive.cli.print.header=false; describe ${TABLE_NAME};" | awk -F " " 'f&&!NF{exit}{f=1}f{printf c toupper($1) "=" toupper($2)}{c=","}')

#call sqoop with --map-column-hive parameter
#add other sqoop params
sqoop import [your sqoop params here] --map-column-hive "$MAP_COLUMN_HIVE" [more sqoop params]

这篇关于如何将 Sqoop 导入命令与 --map-column-hive 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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