ITPub博客

首页 > IT职业 > IT职场 > hive:基础

hive:基础

IT职场 作者:qj_zhai 时间:2021-09-09 10:23:34 0 删除 编辑

插入

form student1
insert overwrite table copy_student3 select *
insert oberwrite table cpoy_student4 select *;

查看表结构

desc student1;

order by

使用 ORDER BY 查询的时候,为了优化查询的速度,使用 hive.mapred.mode 属性。
与数据库中 ORDER BY 的区别在于,在 hive.mapred.mode=strict 模式下必须指定limit ,否则执行会报错。

set hive.mapred.mode=strict;
select * from group_test order by uid limit 5;

Hive 创建索引

create index user_index on table user(id) as ‘org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler’ with deferred rebuild IN TABLE user_index_table;

使用 index_test 表,在属性 id 上创建一个索引 index1_index_test 。
create index index1_index_test on table index_test(id) as ‘org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler’ WITH DEFERERD REBUILD;

删除索引

drop index user_index on user;

查看索引

show index on user;

分区操作 创建分区

CREATE TABLE table_name(
…
)
PARTITION BY (dt STRING,country STRING);

自定义函数

create temporary function IFNullBol as ‘com.pingan.jrkj.datacenter.hive.udf.IFNullBol’;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4380/viewspace-2821445/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Golang goroutine
请登录后发表评论 登录
全部评论

注册时间:2019-08-12

  • 博文量
    76
  • 访问量
    658