zoukankan      html  css  js  c++  java
  • 3、hive操作

    进入hive

      beeline

      !connect jdbc:hive2://s101:10000/lx;auth=noSasl;

    建库并进入:

      create database umeng;

      use umeng;

    建立原始数据表并加载数据:

    use umeng;
    
    create external table if not exists raw_logs(servertimems float,
    servertimestr string,
    clientip string,
    clienttimems bigint,
    status int,
    json string)
    partitioned by(ym string,day string)
    row format delimited
    fields terminated by '#'
    lines terminated by '
    ';
    
    load data inpath '/user/centos/umeng/raw-logs/201810/29/2027' into table
    raw_logs partition(ym=201810,day=29);
    hive -f hive_create_table.sql

    创建日志子表

    -- 创建日志子表
    use umeng ;
    create table if not exists appstartuplogs (
      appchannel string ,
      appid string ,
      appplatform string ,
      appversion string ,
      brand string ,
      carrier string ,
      country string ,
    createdatms bigint ,
      deviceid string ,
      devicestyle string ,
      ipaddress string ,
      network string ,
      ostype string ,
      province string ,
      screensize string ,
      tenantid string)
    PARTITIONED BY (ym string, day string) 
    stored as parquet ;
    
    create table if not exists appeventlogs (
      appchannel string ,
      appid string ,
      appplatform string ,
      appversion string ,
      brand string ,
    createdatms bigint ,
      deviceid string ,
      devicestyle string ,
      eventdurationsecs string ,
      eventid string ,
      ostype string ,
      paramkeyvaluemap string ,
      tenantid string)
    PARTITIONED BY (ym string, day string) 
    stored as parquet ;
    
    create table if not exists apperrorlogs (
      appchannel string ,
      appid string ,
      appplatform string ,
      appversion string ,
      brand string ,
    createdatms bigint ,
      deviceid string ,
      devicestyle string ,
      errorbrief string ,
      errordetail string ,
      ostype string ,
      tenantid string)
    PARTITIONED BY (ym string, day string) 
    stored as parquet ;
    
    create table if not exists appusagelogs (
      appchannel string ,
      appid string ,
      appplatform string ,
      appversion string ,
      brand string ,
    createdatms bigint ,
      deviceid string ,
      devicestyle string ,
      ostype string ,
      singledownloadtraffic string ,
      singleuploadtraffic string ,
      singleusedurationsecs string ,
      tenantid string)
    PARTITIONED BY (ym string, day string) 
    stored as parquet ;
    
    create table if not exists apppagelogs (
      appchannel string ,
      appid string ,
      appplatform string ,
      appversion string ,
      brand string ,
    createdatms bigint ,
      deviceid string ,
      devicestyle string ,
      nextpage string ,
      ostype string ,
      pageid string ,
      pageviewcntinsession string ,
      staydurationsecs string ,
      tenantid string ,
      visitindex string)
    PARTITIONED BY (ym string, day string) 
    stored as parquet ;
    渐变 --> 突变
  • 相关阅读:
    SQL 语句优化中间表的使用优化
    SQL 语句优化OR 语句优化案例
    浅谈系统优化设计复杂运算放在逻辑层还是在数据库层?
    linux命令综合
    MySQL常用命令
    PHP知识点积累
    [Git] 生成token解决github remote: Support for password authentication was removed on August 13, 2021.
    [uniapp] GOFLY在线客服系统 uniapp增加播放背景音效或者按钮音效
    [Golang]gorm更新数据update 解决值为0时被忽略
    光阴真的是贱(似箭),一不小心就又过一年了
  • 原文地址:https://www.cnblogs.com/lybpy/p/9873885.html
Copyright © 2011-2022 走看看