在Hive和Impala中使用不同的分隔符创建表

在Hive和Impala中的表格方面,我需要您的帮助。我的问题是我必须   插入以下数据:

   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
  ""              ""                ""         ""           ""
fgvlty 回答:在Hive和Impala中使用不同的分隔符创建表

您可以使用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' 
;

希望这会有所帮助

本文链接:https://www.f2er.com/3164888.html

大家都在问