zoukankan      html  css  js  c++  java
  • hdfs文件导入hive(ods层),格式为ORC

    方式一:

    1、创建库表

    -- 创建库表
    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode=nonstrict;
    drop table if exists ods_log;
    CREATE EXTERNAL TABLE ods_log (`line` string)
    PARTITIONED BY (`dt` string) -- 按照时间创建分区
    STORED AS -- 指定存储方式
      textfile
    LOCATION '/warehouse/mall/ods/ods_log'  -- 指定数据在hdfs上的存储位置
    ;

    2、加载数据

    --加载数据
    load data  inpath '/flume/data/mall/log/topic_log/2021-04-06' overwrite into table ods_log partition(dt='2021-04-06');

    3、修改表存储格式

    --将表存储格式修改为orc
    ALTER TABLE ods_log SET FILEFORMAT ORC;

    4、查看表存储结构变化

    show create table ods_log;

     方式二:

    1、创建临时表并加载数据

    --创建临时表
    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode=nonstrict;
    drop table if exists ods_log_tmp;
    CREATE EXTERNAL TABLE ods_log_tmp (`line` string)
    PARTITIONED BY (`dt` string) -- 按照时间创建分区
    STORED AS -- 指定存储方式
      textfile
    LOCATION '/warehouse/mall/ods/ods_log_tmp';
    
    load data  inpath '/flume/data/mall/log/topic_log/2021-04-06' overwrite into table ods_log_tmp partition(dt='2021-04-06');

    2、创建ods库表

    -- 创建库表
    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode=nonstrict;
    drop table if exists ods_log;
    CREATE EXTERNAL TABLE ods_log (`line` string)
    PARTITIONED BY (`dt` string) -- 按照时间创建分区
    STORED AS -- 指定存储方式
      orc
    LOCATION '/warehouse/mall/ods/ods_log'  -- 指定数据在hdfs上的存储位置
    ;

    3、将数据导入orc格式表中

    -- 加载日志数据  --- 默认压缩格式为snappy
    insert overwrite  table  ods_log partition (dt='2021-04-06') select  line from ods_log_tmp;
  • 相关阅读:
    String.prototype.getParm
    IOS—通过ChildViewController实现view的切换
    objective-c IBOutletCollection介绍
    iOS方法类:CGAffineTransform的使用大概
    cocoaPods下载使用记录
    objective-c 中的关联介绍
    操作系统--文件管理
    操作系统--设备管理
    操作系统--存储管理的任务
    操作系统--并发进程死锁
  • 原文地址:https://www.cnblogs.com/ywjfx/p/14621658.html
Copyright © 2011-2022 走看看