Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hive 当某些值包含“csv”时,发出将csv加载到配置单元表的命令&引用;_Hive_Hdfs - Fatal编程技术网

Hive 当某些值包含“csv”时,发出将csv加载到配置单元表的命令&引用;

Hive 当某些值包含“csv”时,发出将csv加载到配置单元表的命令&引用;,hive,hdfs,Hive,Hdfs,我正在尝试将csv加载到配置单元表中,加载成功后,由于某些列值中的“,”而无法正确加载该表。解决这个问题的最佳方法是什么 create table abc (col1 string, col2 int) row format delimited fields terminated by ',' tblproperties("skip.header.line.count"="1"); CSV示例:- col1 col2 abc,def 12 erfd 10 load

我正在尝试将csv加载到配置单元表中,加载成功后,由于某些列值中的“,”而无法正确加载该表。解决这个问题的最佳方法是什么

create table abc (col1 string, col2 int) row format delimited fields terminated by ',' tblproperties("skip.header.line.count"="1");
CSV示例:-

col1      col2
abc,def   12
erfd      10


 load data inpath 'path_to_csv' into table abc;

预期的输出是在配置单元中正确填充该表,就像在csv中一样。

使用以下SERDE:

  • 创建示例表

    create table test_hive1(name String, id int)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde';
    
  • 加载数据

    load data local inpath 'filepath' into table test_hive1;
    
  • 输出

    select * from test_hive1;
    name    id
    abc 22
    cdf, def    23
    dsa 34
    

  • 使用OpenCSV serde

    create table abc (col1 string, col2 int) row format
    SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES 
    ("escapeChar" = ",") ;
    
    使用命令将数据加载到表中

     load data local inpath 'path_to_csv' into table abc;
    

    预期产量是多少?