zoukankan      html  css  js  c++  java
  • hive表中字段显示为NULL时,HDFS文件中存储为N

    hive数据落地到hdfs,null会默认用'N'存储

    解决方式1:利用命令(这个我没起效果)

    alter table adl_cici_test_fdt set serdeproperties('serialization.null.format' = '');

     解决方式2;建表时直接指定(两种方式)

    a、用语句
    ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe’
    with serdeproperties('serialization.null.format' = '')
    实现,注意两者必须一起使用,如
    CREATETABLE hive_tb (idint,name STRING)
    PARTITIONED BY (`day` string,`type` tinyint COMMENT'0 as bid, 1 as win, 2 as ck',`hour` tinyint)
    ROW FORMAT SERDE ‘org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe’
    WITH SERDEPROPERTIES (‘field.delim’='/t’,‘escape.delim’='//’,serialization.null.format'='' )
    STORED AS TEXTFILE;
    b、或者通过ROW FORMAT DELIMITED NULL DEFINED AS ''
    CREATETABLE hive_tb (idint,name STRING)
    PARTITIONED BY (`day` string,`type` tinyint COMMENT'0 as bid, 1 as win, 2 as ck',`hour` tinyint)
    ROW FORMAT DELIMITED
    NULL DEFINED AS ''
    STORED AS TEXTFILE;
    如:
    create table vip_info( id string, mobile string)row format delimited fields terminated by ' ' NULL DEFINED AS '' stored as textfile;

    解决方式3

    insert overwrite directory 'hive_test/vip'
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
    WITH SERDEPROPERTIES (
    'field.delim'='	',
    'serialization.format'= '',
    'serialization.null.format'=''  
    ) STORED AS TEXTFILE
    select * from user;
  • 相关阅读:
    WCF bindings comparison z
    DevExpress打印功能 z
    使用Topshelf 5步创建Windows 服务 z
    Log4net中的RollingFileAppender z
    Log4Net在Windows服务中不能记录日志 z
    dev 注册方法 z
    async callback z
    多窗体之间方法调用 z
    [JS6] 通过用户事件事件执行脚本
    [JS5] 利用onload执行脚本
  • 原文地址:https://www.cnblogs.com/xiaoliu66007/p/9447542.html
Copyright © 2011-2022 走看看