随笔分类 - Hive
摘要:Hadoop集群安装参考: https://www.cnblogs.com/kopao/p/14312108.html Hive安装 一、从https://mirror.bit.edu.cn/apache/hive/下载hive,并上传到服务器上 我这里用的是 apache-hive-3.1.2-b
阅读全文
摘要:原始数据如下: 转换后效果: 实现方式: -- 原数据 SELECT '[{"slot_seq":"1","status":"0","battery_sn":"K212EV14C3"},{"slot_seq":"10","status":"0","battery_sn":"K482GE13RT"},
阅读全文
摘要:hive --hiveconf hive.root.logger=DEBUG,console
阅读全文
摘要:1)LAG与LEAD LAG(col,n,default) 用于统计窗口内往上第n行值 第一个参数为列名,第二个参数为往上第n行(可选,默认为1),第三个参数为默认值(当往上第n行为NULL时候,取默认值,如不指定,则为NULL) 例子:获取用户这次下单与下次下单的时间,统计时间差 select o
阅读全文
摘要:order by order by 会对数据进行全局排序,和oracle和mysql等数据库中的order by 效果一样,它只在一个reduce中进行所以数据量特别大的时候效率非常低。 而且当设置 :set hive.mapred.mode=strict的时候不指定limit,执行select会报
阅读全文
摘要:参考 https://blog.csdn.net/qq_34105362/article/details/80454697 hive提供了json的解析函数:get_json_object(string json_string, string path) 第一个参数填写json对象变量,第二个参数使
阅读全文
摘要:#!/bin/bash begin_date=$1 end_date=$2 target_table=bst_agg_car_driver_work_time_d v_dt_year=${begin_date:0:4} echo $v_dt_year,$begin_date,$end_date qu
阅读全文
摘要:UDTF(User-Defined Table-Generating Functions)一进多出,如lateral view explore() 实现方法: 1)继承org.apache.hadoop.hive.ql.udf.generic.GenericUDTF 2)重写initialize、p
阅读全文
摘要:查看使用方式: desc function str_to_map; str_to_map(字符串参数, 分隔符1, 分隔符2) 使用两个分隔符将文本拆分为键值对。 分隔符1将文本分成K-V对,分隔符2分割每个K-V对。对于分隔符1默认分隔符是 ',',对于分隔符2默认分隔符是 '=' 使用 说明:存
阅读全文
摘要:select tmp.*, case when pos = 0 and date_add(start_date, pos) < start_date then date_format(start_date, 'yyyy-MM-dd HH:mm:ss') else concat(date_format
阅读全文
摘要:1)设置hive显示表头和当前使用数据库 <property> <name>hive.cli.print.header</name> <value>true</value> <description>Whether to print the names of the columns in query
阅读全文
摘要:Hive的SQL可以通过用户定义的函数(UDF),用户定义的聚合(UDAF)和用户定义的表函数(UDTF)进行扩展。 当Hive提供的内置函数无法满足你的业务处理需要时,此时就可以考虑使用用户自定义函数(UDF)。 UDF、UDAF、UDTF的区别: UDF(User-Defined-Functio
阅读全文
摘要:转载 https://mp.weixin.qq.com/s?__biz=MzA3ODUxMzQxMA==&mid=2663993556&idx=1&sn=0e5291bd63426d747f32a7fd05128caa&scene=21#wechat_redirect Hive元数据库中一些重要的表
阅读全文
摘要:1)更改表名 alter table 原表名 rename to 心表名; 示例:alter table bst_agg_new_car_hailing_order_model_d rename to bst_agg_car_hailing_order_model_d; 2)更改location a
阅读全文
摘要:1)添加分区 alter table bst_bas_hailing_order add if not exists partition(dt_year='${v_dt_year}'); 2)删除分区 alter table bst_bas_hailing_order drop if exists
阅读全文
摘要:1)查看系统中有哪些数据库 show databases; 2)使用某个数据库 use database_name; 如 use dw_yq; 3)查看当前使用的数据库 select current_database(); 4) 创建数据库 create database dw_yq; -- 直接创
阅读全文