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;
  • 相关阅读:
    最不要勉强的,是感情.
    Nginx+phpfastcgi下flush 一下子全部输出问题
    php excel 读取日期问题
    JavaScript年月日和时间戳互转
    mysql 查找除id外其他重复的字段数据
    Thinkphp 下 MySQL group by 接count 获得条数方法
    MySQL性能管理及架构设计 --- 理论篇
    MySQL 导入.sql文件
    Apache ab 压力并发测试工具
    工作生活随笔
  • 原文地址:https://www.cnblogs.com/ywjfx/p/14621658.html
Copyright © 2011-2022 走看看