json函数 presto_Hive sql和Presto sql的一些对比
最近由于工作上和生活上的一些事儿好久没来博客园了,但是写博客的习惯还是得坚持,新的一年需要更加努力,困知勉行,终身学习,每天都保持空杯心态.废话不说,写一些最近使用到的Presto SQL和Hive SQL的体会和对比.
一.JSON处理对比
Hive
select get_json_object(json, '$.book');
Presto
select json_extract_scalar(json, '$.book');
注意这里Presto中json_extract_scalar返回值是一个string类型,其还有一个函数json_extract是直接返回一个json串,所以使用的时候你得自己知道取的到底是一个什么类型的值.
二.列转行对比
Hive
select student, score from tests lateral view explode(split(scores, ',')) t as score;
Presto
select student, score from tests cross json unnest(split(scores, ',') as t (score);
简单的讲就是将scores字段中以逗号隔开的分数列比如
80,90,99,80
这种单列的值转换成和student列一对多的行的值映射.
三.复杂Grouping对比
Hive
select origin_state, origin_zip, sum(package_weight) from shipping group by origin_state,origin_zip with rollup;
Presto
select origin_state, origin_zip, sum(package_weight) from shipping group by rollup (origin_state, origin_zip);
用过rollup的都知道,这是从右向左的递减的多级统计的聚合,等价于(如下为Presto写法)
select origin_state, origin_zip, sum(package_weight) from shipping group by grouping sets ((origin_state, origin_zip), (origin_state), ());
其他一些语法有细微的差别可以慢慢了解,当然Hive和Presto底层架构不一样导致Presto比Hive运算速度要快很多,再加上开源的Alluxio缓存更加如虎添翼了.
json函数 presto_Hive sql和Presto sql的一些对比相关推荐
- PostgreSQL 10.1 手册_部分 II. SQL 语言_第 9 章 函数和操作符_9.15. JSON 函数和操作符...
9.15. JSON 函数和操作符 表 9.43展示了可以用于两种 JSON 数据类型(见第 8.14 节)的操作符. 表 9.43. json和jsonb 操作符 操作符 右操作数类型 描述 例子 ...
- sql与nosql_SQL Server JSON函数:NoSQL与关系世界之间的桥梁
sql与nosql In this article, we will explain what JSON is, what are the SQL Server JSON functions intr ...
- 使用Presto SQL一些常见问题总结
查询速度慢, 如何优化? 解决方法1: 避免单节点处理 虽然Presto是分布式查询引擎, 但是一些操作是必须在单节点中处理的. 例如: count(distinct x) 考虑使用approx_di ...
- PRESTO SQL总结分享
1.常用SQL语法 1.1 字符substr(staff_leave_date,1,10) concat(string1, ..., stringN) → varchar--拼接多个字符串 lengt ...
- aws rds监控慢sql_使用AWS Lambda函数自动启动/停止AWS RDS SQL Server
aws rds监控慢sql This article gives you an overview of the AWS Lambda function to automatically start a ...
- 【翻译】Presto: SQL on Everything
文章目录 作者 公司 摘要 关键词 I. 引言 II. 用例 A. 交互式分析 B. 批处理 ETL C. A/B 测试 D. 开发者/广告主分析 III. 架构概览 IV. 系统设计 A. SQL ...
- Hive、Hadoop完全分布式安装,基本SQL,基本SQL,基本表结构,数据类型,函数,窗口函数,jion,查询和排序,beeline,文件格式及基本架构汇总
目录 Hive简介 一.概述 二.Hive和数据库的比较 三.特点 Hadoop完全分布式安装 一.配置 二.安装步骤 Hive安装 一.概述 二.安装步骤 其他 一.Hive运行日志 二.Hive的 ...
- sql自定义函数学习思路_学习SQL:用户定义的函数
sql自定义函数学习思路 You can create several user-defined objects in a database. One of these is definitely u ...
- sql etl_使用SQL TRY函数进行ETL优化
sql etl 介绍 (Introduction) An enterprise data warehouse ETL solution typically includes, amongst othe ...
最新文章
- HTTP协议基础解读
- [PHP]Maximum execution time of 30 seconds exceeded
- xcode7 没有Empty Application
- oracle expdp 39002,expdp 导入数据时ORA-39002、ORA-39070错误排查
- 洛谷P4555 [国家集训队]最长双回文串(manacher 线段树)
- 555定时器,你知道它的功能有多强大吗?
- python初学者编程指南_动态编程初学者指南
- Windows Azure 将正式更名为 Microsoft Azure
- hibernate中antlr对于hql生成抽象语法树源码解析
- STM32工作笔记0061---通用定时器基本原理
- Critical dependency: require function dependencies cannot be statically extracted
- C语言入门项目篇:贪吃蛇(完整代码+详细注释)
- 11个炫酷的Linux终端命令大全
- 智能android电视更换播放器,智能电视最强播放器—KODI常见使用技巧全方位解读...
- Organon将收购Forendo Pharma
- 你在日本经历过哪些事情的体验不如中国?
- 自兴人工智能——Python第三课(字符串和字典)
- 健康数据的获取 Iphone
- 运营推广一款新的app到底需要哪些完整步骤?
- u盘linux和win7双系统安装教程,双系统安装Win7系统U盘安装linux centos7,详细步骤...
热门文章
- 【转载】4412开发板、PC、ubuntu通过网线连接
- 浅谈数据库设计二三事
- NGUI_2.6.3_教程五(角色信息跟随)
- jsTree工作笔记001---jsTree的基本使用_js实现树形结构
- System学习笔记006---Windows退出telnet 命令的正确姿势
- Android异常总结---Test run failed:Unable to find instrumentation target package
- 清理日志文件尝试有效哦
- shell sed 替代1
- delphi的 PosEx 函数功能介绍
- mysql 为什么不能安装_下载的mysql怎么无法安装