zoukankan      html  css  js  c++  java
  • hive分区操作

    hive分区操作

    20191017


    • (1)hive建表时创建分区
    create table  `mytable`(
      `column1` string, 
      `column2` string)
    partitioned by ( `mydate` string, `mytype` int)
    row format delimited fields terminated by ',';
    

    • (2)hiveselect--加载数据时动态创建分区
    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode=nonstrict;
    
    use mydatabase;
    
    insert overwrite table mytable partition(
    mydate,mytype)
    select xxx, xxx, xxx as mydate, xxx as mytype from othertable;
    

    动静混合加载

    set hive.exec.dynamic.partition=true;
    set hive.exec.dynamic.partition.mode=nonstrict;
    
    use mydatabase;
    
    insert overwrite table mytable partition(
    mydate='2019-01-01',mytype)
    select xxx, xxx, col3 as mydate, xxx as mytype from othertable where col3 = '2019-01-01';
    

    • (3)hive文件加载数据时创建分区
    load data local inpath '/path/file' overwrite into table mytable 
    partition (mydate='2018-01-01',mytype=40);
    

    • (4)hive只添加分区,不载入数据
    alter table mytable add [IF NOT EXISTS] partition (mydate='2018-01-01', mytype=40);
    

    • (5)hive 删除已有分区

    mytable表有两个分区字段mydate string,mytype int

    alter table mytable drop [IF EXISTS] partition (mydate='2018-01-01', mytype=40);
    

    参考

    参考1
    参考2

  • 相关阅读:
    django 母版与继承
    django 模板系统
    及时从数据库中取得数据填放进Form表单的多选框中
    django 自带的验证功能
    django Form表单
    AJAX 操作
    django 中间件
    JVM-crash查看hs_err_pid.log日志
    java-log4j日志打印
    tomcat 闪退问题排查
  • 原文地址:https://www.cnblogs.com/damahuhu/p/11694690.html
Copyright © 2011-2022 走看看