我需要您在Hive中的桌子的帮助。我的问题是我必须插入以下数据:
HD_4K;Number_Channel;ID_Channels;Type;Name_Channel;
4K; 45; "1;2;3;4;5;6" ; Series ; Channel 1;
HD; 24; "1;6"; Film; Channel 2;
我想用“;”分隔字段但是“ ID_CHANNELS”字段导致我遇到问题,因为您的信息还涉及“;”
任何人有解决此问题的想法吗?预先非常感谢:)
创建外部表通道(HD_4K字符串,Number_Channel整数,ID_Channels字符串,类型字符串,Name_Channel字符串)行格式由'\ u0059'终止的行由'\ n'终止的行存储为文本文件位置'/ database / channels /'TBLPROPERTIES(“ textfile.compress” =“ snappy”);
当前渠道表:(
HD_4K | NUMBER_CHANNEL | ID_CHANNELS | TYPE | NAME_CHANNELS
(String) (Int) (String) (String) (String)
4K 45 "1 2 3
HD 23 "1 6" Film
"" "" "" "" ""
梦幻频道表
HD_4K | NUMBER_CHANNEL | ID_CHANNELS | TYPE | NAME_CHANNELS
(String) (Int) (String) (String) (String)
4K 45 "1;2;3;4;5;6" Series Cook Channel
HD 23 "1;6" Film Channel 1
"" "" "" "" ""
您可以使用OpenCSVSerDe
CREATE EXTERNAL TABLE channels_csv(
HD_4K String,
Number_Channel Int,
ID_Channels String,
Type String,
Name_Channel String
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ";",
"quoteChar" = "\""
)
LOCATION '/path/to/file'
;
希望这会有所帮助