栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Hive 实验

Hive 实验

// 创建数据库并导入数据

1. create database {database_name};

2. use {database_name};

3. create table docs(line string);

4. load data inpath '/training/{student_name}/inceptor_data/wordcount' into table docs;

//创建结果表

create table wc(word string, totalword int);

// wordcount统计

from (select explode(split(line, ' ')) as word from docs) w

insert into table wc

select word, count(1) as totalword

group by word

order by word;

// 查看分析结果

select * from wc;

// 创建外表

 create external table ext_table(rowkey string, num int, country int, rd string) row format delimited fields terminated by ',' location '/images/inceptor_data';

//创建ORC事务表

// 设置开启事务

1. set transaction.type=inceptor;

// 设置PLSQL编译器不检查语义

2. set plsql.compile.dml.check.semantic=false;

 create table atomicity_table(key int, value string) clustered by(key) into 8 buckets stored as orc tblproperties('transactional'='true');

// 创建单值分区表

CREATE TABLE user_acc_level (name STRING)

PARTITIonED BY (acc_level STRING)

//创建ORC分区分桶表

create table hq_ais_history_data_orc_bucket (

cbm string,

csx int,

cwjqd int,

dzdwzz int,

gjmc string,

hh string,

hs double,

hwlx int,

hx double,

hxzt int,

imobm string,

mbbh string,

mdd string,

txzt int,

xxlx int,

xxly int,

yjddsj string,

zdjss double,

zxl int,

lat double,

lon double,

mbsj int

)

partitioned by range (sj string) (

partition values less than ("2014-11-04 23:59:59"),

partition values less than ("2014-11-05 23:59:59"),

partition values less than ("2014-11-06 23:59:59"),

partition values less than ("2014-11-07 23:59:59"),

partition values less than ("2014-11-08 23:59:59"),

partition values less than ("2014-11-09 23:59:59"),

partition values less than ("2014-11-10 23:59:59"),

partition values less than ("2014-11-11 23:59:59"),

partition values less than ("2015-08-05 23:59:59")

)

clustered by (mbbh) into 23 buckets

stored as orc;

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/433981.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号