zoukankan      html  css  js  c++  java
  • Hive 多分隔符的使用 (转载)

    方法一)通过org.apache.hadoop.hive.contrib.serde2.RegexSerDe格式的serde。

    1) 建表语句

    #指定以^|~作为分隔符

    CREATE TABlE tableex3(id STRING, name STRING)

    ROW FORMAT SERDE'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'

    WITH SERDEPROPERTIES (

    "input.regex" = "^(.)^|~(.)$"

    )

    STORED AS TEXTFILE;

    2) 准备数据

    1^|~wee

    2^|~do

    we^|~xml

    %^|~we

    3) 转载数据

    load data local inpath '/var/lib/hadoop-hdfs/tee.txt'into table tableex3;

    4) 验证:

    select * from tableex3;

    +--------------+----------------+--+

    | tableex3.id | tableex3.name |

    +--------------+----------------+--+

    | 1 | wee |

    | 2 | do |

    | we | xml |

    | % | we |

    | NULL | NULL |

    +--------------+----------------+--+

    方法二)通过org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe格式的serde。

    #指定以^|~作为分隔符

    CREATE TABLE multi_delim (col1 STRING, col2 STRING,Col3STRING) ROW FORMAT SERDE'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe' WITH SERDEPROPERTIES("field.delim"="^|~");

    cat /var/lib/hadoop-hdfs/tee3.txt

    1^|~wee^|~hi

    2^|~do^|~where

    we^|~xml^|~rice

    %^|~we^|~^|

    load data local inpath '/var/lib/hadoop-hdfs/tee.txt'into table tableex3;

    select * from multi_delim;

    +-------------------+-------------------+-------------------+--+

    | multi_delim.col1 | multi_delim.col2 | multi_delim.col3 |

    +-------------------+-------------------+-------------------+--+

    | 1 | wee | hi |

    | 2 | do | where |

    | we | xml | rice |

    | % | we | ^| |

    | | NULL | NULL |

  • 相关阅读:
    js实现将字符串里包含手机号的中间四位替换为****
    草稿for套for
    js实现将时间戳转换成2017-05-06 09:03:02
    时间日期校验接口
    JS延迟导航nav
    nav导航
    鼠标滚动请求加载
    常用开源Jabber(XMPP) IM服务器介绍(转)
    01.base-v1.js
    Haproxy安装及配置(转)
  • 原文地址:https://www.cnblogs.com/ilvutm/p/7704330.html
Copyright © 2011-2022 走看看