可以通过两种方式将数据加载到配置单元表中
*使用HDFS命令:
CREATE TABLE `test_sample`(
`test_map` map<string,string>
)
PARTITIONED BY (
`test_date ` string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
MAP KEYS TERMINATED BY '='
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
样品输入文件
hadoop fs -put input.txt HDFS_dest_Path
将文件上载到Hadoop fs之后,再将数据加载到表中:
load data inpath <location of the hadoop table> into table test_sample partition(test_date='2019-02-28');
如果文件系统中已经存在类似的数据,则可以通过配置单元查询将其插入表中。
INSERT INTO TABLE test_tab PARTITION(test_date= '2019-02-28')
select map from test_sample;
注意:由“=”约束终止的映射键对于测试选项卡表不一定是必需的。