Hive

sqoop1再踩坑

给你一囗甜甜゛ 提交于 2021-01-22 12:26:41
一、什么是Sqoop Sqoop是一个在结构化数据和Hadoop之间进行批量数据迁移的工具,结构化数据可以是Mysql、Oracle等RDBMS。Sqoop底层用MapReduce程序实现抽取、转换、加载,MapReduce天生的特性保证了并行化和高容错率,而且相比Kettle等传统ETL工具,任务跑在Hadoop集群上,减少了ETL服务器资源的使用情况。在特定场景下,抽取过程会有很大的性能提升。 如果要用Sqoop,必须正确安装并配置Hadoop,因依赖于本地的hadoop环境启动MR程序;mysql、oracle等数据库的JDBC驱动也要放到Sqoop的lib目录下。本文针对的是Sqoop1,不涉及到Sqoop2,两者有大区别,感兴趣的读者可以看下官网说明。 二、import import是数据从RDBMS导入到Hadoop的工具 2.1、split Sqoop并行化是启多个map task实现的,-m(或--num-mappers)参数指定map task数,默认是四个。并行度不是设置的越大越好,map task的启动和销毁都会消耗资源,而且过多的数据库连接对数据库本身也会造成压力。在并行操作里,首先要解决输入数据是以什么方式负债均衡到多个map的,即怎么保证每个map处理的数据量大致相同且数据不重复。--split-by指定了split column,在执行并行操作时

Using like operator to check for pattern in hive

↘锁芯ラ 提交于 2021-01-22 10:15:06
问题 I need to retrieve the columns from a hive table that must begin with uppercase letter and end with digit. I used this query select * from tab1 where col1 like '[A-Z]%[0-9]'; But not able to retrieve the records ,getting only empty result. 回答1: rlike / regexp select * from tab1 where col1 rlike '^[A-Z].*[0-9]$'; 来源: https://stackoverflow.com/questions/42809183/using-like-operator-to-check-for-pattern-in-hive

Using like operator to check for pattern in hive

僤鯓⒐⒋嵵緔 提交于 2021-01-22 10:10:43
问题 I need to retrieve the columns from a hive table that must begin with uppercase letter and end with digit. I used this query select * from tab1 where col1 like '[A-Z]%[0-9]'; But not able to retrieve the records ,getting only empty result. 回答1: rlike / regexp select * from tab1 where col1 rlike '^[A-Z].*[0-9]$'; 来源: https://stackoverflow.com/questions/42809183/using-like-operator-to-check-for-pattern-in-hive

Using like operator to check for pattern in hive

隐身守侯 提交于 2021-01-22 10:07:13
问题 I need to retrieve the columns from a hive table that must begin with uppercase letter and end with digit. I used this query select * from tab1 where col1 like '[A-Z]%[0-9]'; But not able to retrieve the records ,getting only empty result. 回答1: rlike / regexp select * from tab1 where col1 rlike '^[A-Z].*[0-9]$'; 来源: https://stackoverflow.com/questions/42809183/using-like-operator-to-check-for-pattern-in-hive

Presto SQL - How can i get all possible combination of an array?

空扰寡人 提交于 2021-01-22 09:31:43
问题 I want all the possible combination of a number in a given set of array. I tried using some of the predefined functions of presto like array_agg(x) Input : [1,2,3,4] Output when n=2 : [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] when n=3 : [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] when n=4 : [[1,2,3,4]] or [1,2,3,4] 回答1: There is combinations(array(T), n) function and it does exactly what you want: select combinations(array[1,2,3,4],2); 来源: https://stackoverflow.com/questions/56540393/presto-sql-how-can-i

Presto SQL - How can i get all possible combination of an array?

↘锁芯ラ 提交于 2021-01-22 09:25:54
问题 I want all the possible combination of a number in a given set of array. I tried using some of the predefined functions of presto like array_agg(x) Input : [1,2,3,4] Output when n=2 : [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] when n=3 : [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] when n=4 : [[1,2,3,4]] or [1,2,3,4] 回答1: There is combinations(array(T), n) function and it does exactly what you want: select combinations(array[1,2,3,4],2); 来源: https://stackoverflow.com/questions/56540393/presto-sql-how-can-i

Presto SQL - How can i get all possible combination of an array?

℡╲_俬逩灬. 提交于 2021-01-22 09:25:47
问题 I want all the possible combination of a number in a given set of array. I tried using some of the predefined functions of presto like array_agg(x) Input : [1,2,3,4] Output when n=2 : [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] when n=3 : [[1,2,3],[1,2,4],[1,3,4],[2,3,4]] when n=4 : [[1,2,3,4]] or [1,2,3,4] 回答1: There is combinations(array(T), n) function and it does exactly what you want: select combinations(array[1,2,3,4],2); 来源: https://stackoverflow.com/questions/56540393/presto-sql-how-can-i

hive窗口函数/分析函数详细剖析

此生再无相见时 提交于 2021-01-21 23:41:16
hive窗口函数/分析函数 在sql中有一类函数叫做聚合函数,例如sum()、avg()、max()等等,这类函数可以将多行数据按照规则聚集为一行,一般来讲聚集后的行数是要少于聚集前的行数的。但是有时我们想要既显示聚集前的数据,又要显示聚集后的数据,这时我们便引入了窗口函数。窗口函数又叫OLAP函数/分析函数,窗口函数兼具分组和排序功能。 窗口函数最重要的关键字是 partition by 和 order by。 具体语法如下: over (partition by xxx order by xxx) sum,avg,min,max 函数 准备数据 1 建表语句: 2 create table bigdata_t1( 3 cookieid string , 4 createtime string , --day 5 pv int 6 ) row format delimited 7 fields terminated by ',' ; 8 9 加载数据: 10 load data local inpath '/root/hivedata/bigdata_t1.dat' into table bigdata_t1; 11 12 cookie1,2018-04-10,1 13 cookie1,2018-04-11,5 14 cookie1,2018-04-12,7 15 cookie1

数禾云上数据湖最佳实践

吃可爱长大的小学妹 提交于 2021-01-21 16:43:59
目录 1. 数禾科技 2. 云上自建CDH 3. 云上混合架构 4. 阿里云第一代数据湖 4.1. 什么是数据湖 4.2. 阿里云数据湖设计 4.2.1. 阿里云数据湖整体架构 4.2.2. 统一存储和元数据管理 4.2.3. 多EMR多OSS桶设计 4.2.4. 分布式调度系统设计 4.2.5. 用户权限系统设计 4.2.6. EMR弹性伸缩设计 4.2.7. 负载均衡管理 4.2.8. OSS桶生命周期管理 4.2.9. 日志管理 4.2.10. 终端权限管理 4.2.11. 组件UI管理 4.2.12. 监控告警管理 4.2.13. 即席查询设计 4.2.14. 集群安全组设计 4.2.15. 数据脱敏设计 4.2.16. YARN队列设计 4.3. 数据湖EMR治理 4.3.1. 调整EMR预伸缩时间 4.3.2. 更改EMR弹性伸缩策略 4.3.3. 优化EMR云盘空间 4.3.4. EMR机器组的选择 4.3.5. EMR成本控制 4.3.6. 购买RI预留抵扣券 4.3.7. 弹性保障 4.4. 数据湖OSS治理 4.4.1. 数仓ODS多版本桶治理 4.4.2. 数仓日志桶治理 4.4.3. 数仓桶和集市桶治理 4.4.4. 监控桶内对象 5. 阿里云第二代数据湖 5.1. 阿里云数据湖构建 5.2. 阿里云数据湖解决方案 1.数禾科技 数禾科技成立于2015年8月

阿里云 EMR Delta Lake 在流利说数据接入中的架构和实践

风格不统一 提交于 2021-01-21 12:45:23
简介: 为了消灭数据孤岛,企业往往会把各个组织的数据都接入到数据湖以提供统一的查询或分析。本文将介绍流利说当前数据接入的整个过程,期间遇到的挑战,以及delta在数据接入中产生的价值。 背景 流利说目前的离线计算任务中,大部分数据源都是来自于业务 DB,业务DB数据接入的准确性、稳定性和及时性,决定着下游整个离线计算 pipeline 的准确性和及时性。同时,我们还有部分业务需求,需要对 DB 中的数据和 hive 中的数据做近实时的联合查询。 在引入阿里云 EMR Delta Lake 之前,我们通过封装 DataX 来完成业务 DB 数据的接入,采用 Master-Slave 架构,Master 维护着每日要执行的 DataX 任务的元数据信息,Worker 节点通过不断的以抢占的方式获取状态为 init 和 restryable 的 DataX 任务来执行,直到当天的所有的 DataX 任务全都执行完毕为止。 架构图大致如下: Worker 处理的过程如下: 对于近实时需求,我们是直接开一个从库,配置 presto connector 去连接从库,来实现业务 BD 中的数据和 hive 中的数据做近实时的联合查询需求。 这种架构方案的优点是简单,易于实现。但是随着数据量也来越多,缺点也就逐渐暴露出来了: 性能瓶颈: 随着业务的增长,这种通过 SELECT