如何在--map-column-hive中使用Sqoop导入命令? [英] How to use Sqoop import command with --map-column-hive?

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

问题描述

我试图将Teradata的数据平铺到配置单元中。我想按照下面的步骤:
$ b $ 1)创建Hue中所有必填字段的Hive表格。
2)通过使用Sqoop导入命令以及 - map-column-hive 属性以将Teradata中的数据加载到配置单元。



从Sqoop导入命令指向已经创建的Hive表,以便Sqooped数据应该放置在相应的Hive表中? 解决方案

p>您可以使用shell和awk从现有表中生成 map-column-hive 属性。它将以 COL1 = TYPE,COL2 = TYPE,... COLN = TYPE $ b <$ p $的形式生成在这里设置表名
TABLE_NAME = your_schema.your_table

#从现有表格生成地图 b



MAP_COLUMN_HIVE = $(hive -S -eset hive.cli.print.header = false; describe $ {TABLE_NAME};| awk -F'f&&!NF {exit} {f = 1} f {printf c toupper($ 1)=toupper($ 2)} {c =,}')

#使用--map-column-hive参数调用sqoop参数
#add other sqoop params
sqoop import [您的sqoop参数在这里] --map-column-hive$ MAP_COLUMN_HIVE[more sqoop params]


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

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 .

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?

解决方案

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]

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

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