hive
hive
小哇666
专注web/大数据
展开
-
hive语法树分析,判断 sql语句中有没有select *
【代码】hive语法树分析,判断 sql语句中有没有select *原创 2024-03-21 18:46:32 · 467 阅读 · 0 评论 -
java 通过 IMetaStoreClient 取 hive 元数据信息
【代码】java 通过 IMetaStoreClient 取 hive 元数据信息。原创 2024-03-20 22:45:13 · 276 阅读 · 0 评论 -
hive:union和union all的区别
1.Union 和Union All都是将两个表合并起来2.区别在于Union会去重,同时进行默认规则的排序Union All不去重,不进行排序原创 2020-12-02 19:10:44 · 1534 阅读 · 0 评论 -
cdh6.2平台,oozie执行hive脚本,报 java.lang.OutOfMemoryError: Java heap space 排错的过程
Ended Job = job_1606699847024_0002 with errorsError during job, obtaining debugging information...Examining task ID: task_1606699847024_0002_m_000008 (and more) from job job_1606699847024_0002Examining task ID: task_1606699847024_0002_r_000000 (and mor.原创 2020-11-30 14:58:20 · 338 阅读 · 0 评论 -
hive 中 函数 last_day的使用, 获取每个月最后一天
last_day获取每个月最后一天select last_day('2020-10-01')2020-10-31SELECT last_day('2003-03-15 01:22:33') 2003-03-31原创 2020-11-25 14:14:50 · 17449 阅读 · 1 评论 -
hive 日期转时间戳函数之unix_timestamp,时间戳转日期函数之from_unixtime
一. 日期>>>>时间戳默认返回的时间戳都是 10 位,如果是 13位,要特殊处理,看下面1.unix_timestamp() 获取当前时间戳例如:select unix_timestamp() --15658583892.unix_timestamp(string timestame) 输入的时间戳格式必须为'yyyy-MM-dd HH:mm:ss',如不符合则返回null例如:select unix_timestamp('2019-08-15 16...转载 2020-11-09 11:02:54 · 1836 阅读 · 0 评论 -
Hive内嵌函数大全:条件判断函数IF,COALESCE,CASE WHEN
1.Hive所有关于条件判断内嵌函数 Return Type Name(Signature) Description T if(boolean testCondition, T valueTrue, T valueFalseOrNull) Returns valueTrue when testCondition is true, returns valueFalseOrNull otherw转载 2020-10-25 15:47:29 · 1327 阅读 · 1 评论 -
Hive-load data加载数据到表中,insert overwrite导出数据到linux或hdfs中
hdfs常用命令,可查看博文hdfs常用命令//从本地加载数据到表,linux上的文件不会丢失,相当于是复制 ,这是 追加的模式load data local inpath '/data/log/1.txt' into table employee;//从本地加载数据到表,linux上的文件不会丢失,相当于是复制 ,overwrite 是 覆盖的模式load data local inpath '/data/log/2.txt' overwrite into table t1//从hdfs.原创 2020-10-24 21:23:56 · 883 阅读 · 0 评论 -
hive-分析函数 LAG、LEAD、FIRST_VALUE和LAST_VALUE OVER(PARTITION BY order by) 的使用
OVER(PARTITION BY order by)函数的其它用法,可查看博文https://blog.csdn.net/qq_41712271/article/details/109224538创建表和数据cookie1,2015-04-10 10:00:02,url2cookie1,2015-04-10 10:00:00,url1cookie1,2015-04-10 10:03:04,1url3cookie1,2015-04-10 10:50:05,url6cookie1,2015-0.转载 2020-10-22 18:20:47 · 3260 阅读 · 0 评论 -
hive-OVER(PARTITION BY order by)函数 的使用
准备测试数据dss,1,95fda,1,80ffd,1,95cfe,2,74gds,2,923dd,3,78adf,3,45asdf,3,55ddd,3,99gf,3,99use test;create external table T2_TEMP(name string, class string, sroce int) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n转载 2020-10-22 16:32:52 · 5120 阅读 · 0 评论 -
hive-字符串查找函数 instr和locate
找不到都是返回0字符串查找函数: instr语法: instr(string str, string substr)返回值: int说明:返回字符串 substr 在 str 中首次出现的位置举例:hive> select instr('abcdf','df') from test;OK4字符串查找函数:locate语法: locate(string substr, string str[, int pos])返回值: int说明:返回字符串 substr 在 str 中.原创 2020-10-22 14:50:03 · 17325 阅读 · 1 评论 -
HIVE-row_number() OVER(PARTITION BY)函数-先分组,取每个分组的前几个
select row_number() over (partition by month order by ref_host_cnts desc)partition:按照month分成区块order by :排序是在partition分成的区块中分别进行。row_number():对各个分区分别添加编号,类似于rownum的递增序列准备表和测试数据create external table product_1(day_id string, mac_id int, mac_colo原创 2020-10-22 14:31:37 · 2889 阅读 · 0 评论 -
HIVE-执行命令的几种方式 和 hive -e 和hive -f的使用
第一种,在bash中直接通过hive -e命令,并用 > 输出流把执行结果输出到制定文件hive -e "select * from test.hour_rate2 where year='2019'" > /tmp/output_1.txt第二种,在bash中直接通过hive -f命令,执行文件中一条或者多条sql语句。并用 > 输出流把执行结果输出到制定文件hive -f /tmp/exer.sql > /tmp/output_3.txtexer.sql 文原创 2020-10-22 11:32:34 · 12388 阅读 · 1 评论 -
hive中round、floor、ceil区别及用法
浮点数四舍五入:select round(1.4) : 1.0select round(1.5) : 2.0浮点数取两位小数:select round(1.23454,2) : 1.23select round(1.04234,2) : 1.04select round(1.04534,2) : 1.05小数点位数是负数,比如-2,那么小数点前2位为0,且进行四舍五入计算。select round(1213232,-2) : 1213200select round(12转载 2020-10-20 18:53:41 · 1190 阅读 · 0 评论 -
Hive,mysql 差集运算 left outer join
差集定义:一般地,设A,B是两个集合,由所有属于A且不属于B的元素组成的集合,叫做集合A减集合B(或集合A与集合B之差)。 类似地,对于集合A,B,我们把集合{x/x∈A,且x¢B}叫做A与B的差集,记作A-B记作A-B(或A\B); 即A-B={x|x∈A,且x ¢B}(或A\B={x|x∈A,且x ¢B} B-A={x/x∈B且x¢A} 叫做B与A的差集。比如说有这么两个表: hive...转载 2020-10-20 18:33:25 · 580 阅读 · 0 评论 -
hive日期函数-原生函数 from_unixtime,unix_timestamp,to_date,current_date,datediff,date_add,date_sub,add_mont
1.from_unixtime将UNIX时间戳转日期函数:from_unixtime 语法:from_unixtime(bigint unixtime[, stringformat])返回值: string说明: 转化UNIX时间戳(从1970-01-0100:00:00 UTC到指定时间的秒数)到当前时区的时间格式举例: select from_unixtime(1323308943);+----------------------+--+| _c0 ...转载 2020-10-20 10:39:30 · 2364 阅读 · 0 评论 -
Ambari平台安装Hive,并配置Hive的元数据存储在mysql
由于Ambari不允许将hive元数据安装在 master主机,所以这里将mysql装在 slave1节点上1.创建 Hive 所需的 MySQL 资源在 MySQL 里单独为 Hive 创建hive用户,密码 hive%123,和数据库以便于管理:在 slave1 上,进入 MySQL 的命令行 mysql -uroot -p然后执行如下命令:set global validate_password_policy=0;set global validate_password_mixed_ca原创 2020-09-22 21:14:00 · 986 阅读 · 0 评论 -
Hive和Hbase整合使用,注意事项,细节等,没有讲整合的环境搭建
配置 hive 与 hbase 整合的目的是利用 HQL 语法实现对 hbase 数据库的增删改查操作,基本原理就是利用两者本身对外的API接口互相进行通信,两者通信主要是依靠hive_hbase-handler.jar工具类。但请注意:使用Hive操作HBase中的表,只是提供了便捷性,前面章节已经介绍,hiveQL引擎使用的是MapReduce,对于性能上,表现比较糟糕,在实际应用过程中可针对不同的场景酌情使用。至于整合的环境的搭建,请小伙伴自行baidu,不好意思比如hbase中的如下表,结构如下原创 2020-09-14 15:41:38 · 306 阅读 · 0 评论 -
Impala或hive与HBase整合
Impala与HBase整合impala可以通过Hive外部表的方式和Hbase进行整合-步骤一:创建HBASE表,添加数据create 'test_info','info';put 'test_info','1','info:name','similarFish';put 'test_info','2','info:name','fish';-步骤二:创建hive表create external table test_info(key string,name string)原创 2020-09-02 17:30:23 · 405 阅读 · 0 评论 -
Hive动态分区&Partition中使用函数
步骤1: 建立好分区表步骤2:设置分区参数set hive.exec.dynamic.partition=true;(可通过这个语句查看:set hive.exec.dynamic.partition;) set hive.exec.dynamic.partition.mode=nonstrict; SET hive.exec.max.dynamic.partitions=100000;(如果自动分区数大于这个参数,将会报错)SET hive.exec.max.dynamic.partiti.原创 2020-07-25 19:58:27 · 2400 阅读 · 0 评论 -
hive 常用函数大全
文章目录1关系运算 1.11、等值比较: = 1.22、不等值比较: 1.33、小于比较: < 1.44、小于等于比较: <= 1.55、大于比较: > 1.66、大于等于比较: >= 1.77、空值判断: IS NULL 1.88、非空判断: IS NOT NULL 1.99、LIKE比较: LIKE 1.1...转载 2019-11-28 23:31:30 · 202 阅读 · 0 评论 -
hive 启动方式
1 直接运行hive2 beeline方式启动hive --service hiveserver2beeline -u jdbc:hive2://127.0.0.1:100003 通过spark启动,前提需要配置好和hive集成进入spark安装的bin目录,运行 spark-sql...原创 2019-11-29 09:31:01 · 132 阅读 · 0 评论 -
springboot集成 hive
1 添加依赖 <!-- https://mvnrepository.com/artifact/com.google.guava/guava --> <dependency> <groupId>org.apache.avro</groupId> <artifactId>a...原创 2019-09-26 15:44:35 · 3102 阅读 · 0 评论 -
hive 操作复杂结构数据 array,map,struct,json
use test03;//array类型create table person(name string,work_locations array<string>)ROW FORMAT DELIMITEDFIELDS TERMINATED BY '\t'COLLECTION ITEMS TERMINATED BY ',';//导入数据LOAD DATA LOCAL ...原创 2019-11-28 23:15:03 · 1772 阅读 · 0 评论 -
hive 分桶表
use test03;// 桶表 辅助表create table b_tb1(id bigint,name string,love array<string>)row format delimited fields terminated by '\t';//导入数据load data local inpath '/data/log/tong.txt' into ta...原创 2019-11-28 23:13:43 · 79 阅读 · 0 评论 -
hive 动态分区表
use test03;drop table d_fz//设置为非严格模式set hive.exec.dynamic.partition.mode=nonstrict;//启动动态分区set hive.exec.dynamic.partition=true;//建立一个辅助表存储数据(和动态分区表列相同)create table d_fz(id bigint,name stri...原创 2019-11-28 23:13:02 · 529 阅读 · 0 评论 -
hive 静态分区表
use test03drop table my_partitioner1drop table my_partitioner3//一级分区的静态分区表create table my_partitioner1(id bigint,name string,time date,love string)partitioned by(sex string)row format deli...原创 2019-11-28 23:12:05 · 248 阅读 · 0 评论 -
hive 建库建表字段操作基础
//建库create database if NOT EXISTS test03//建库,并指定位置create database if NOT EXISTS test04 location '/apps/hive/warehouse/cheshi_4'//查询所有的数据库show databases//使用库use test03//展示所有表show tables...原创 2019-11-28 23:05:17 · 839 阅读 · 0 评论