
presto
鸭梨山大哎
life hard take it easy
展开
-
Presto数组函数
下标运算符:[]该[]运算符用于访问数组的元素,并从 1 开始索引:SELECT my_array[1] AS first_element连接运算符: ||该||运算符用于将数组与数组或相同类型的元素连接起来:SELECT ARRAY [1] || ARRAY [2]; -- [1, 2]SELECT ARRAY [1] || 2; -- [1, 2]SELECT 2 || ARRAY [1]; -- [2, 1]数组函数all_match( array(T) , function(T原创 2021-08-18 09:20:59 · 6868 阅读 · 0 评论 -
presto distinct用法
单列select distinct colA from a;多列-- 不支持select distinct colA,colB from a;-- 支持select distinct row(colA,colB) from a;所有列select distinct * from a;但是如果还需要聚合,presto 不支持以下写法select count(distinct *) from a;可以用如下写法代替select count(*) from (select d原创 2021-08-17 15:20:07 · 3109 阅读 · 0 评论 -
Presto 日期和时间函数
current_date -> date返回查询开始时的当前日期。current_time -> time with time zone返回查询开始时的当前时间。current_timestamp -> timestamp with time zone返回查询开始时的当前时间戳。current_timezone( ) → 变量字符#以 IANA 定义的格式(例如America/Los_Angeles)或与 UTC 的固定偏移量(例如+08:35)返回当前时区date( x原创 2021-08-07 10:19:38 · 3409 阅读 · 0 评论 -
Presto为什么快
架构Presto查询引擎是一个Master-Slave的架构,由一个Coordinator节点,一个Discovery Server节点,多个Worker节点组成,Discovery Server通常内嵌于Coordinator节点中。Coordinator负责解析SQL语句,生成执行计划,分发执行任务给Worker节点执行。Worker节点负责实际执行查询任务。Worker节点启动后向Discovery Server服务注册,Coordinator从Discovery Server获得可以正常工作的Wo原创 2021-01-26 19:33:41 · 1378 阅读 · 0 评论 -
presto array_join函数
用途就是把array中的每个元素用分隔符连接起来array_join(x, delimiter, null_replacement) → varcharConcatenates the elements of the given array using the delimiter and an optional string to replace nulls.案例如下regexp_extract_all提取字符串,返回值为array,之后用,把 array中的元素连接起来> select原创 2021-01-14 17:26:35 · 5626 阅读 · 0 评论 -
presto 正则提取函数
regexp_extract_all正则提取字段的buffer内容,返回类型为array.regexp_extract_all(string, pattern) -> array(varchar)测试> SELECT regexp_extract_all('1a 2b 14m', '\d+'); _col0------------ [1, 2, 14]还可以利用正则组> SELECT regexp_extract_all('1a 2b 14m', '(\d+)([原创 2021-01-14 17:05:34 · 5286 阅读 · 1 评论 -
deserializer does not exist: org.openx.data.jsonserde.JsonSerDe
presto建表报错deserializer does not exist: org.openx.data.jsonserde.JsonSerDe解决办法找到jar包放到hive-hadoop2目录下,重启presto即可json-serde-1.3.8-jar-with-dependencies/usr/lib/presto/plugin/hive-hadoop2/参考AWS Developer Forums: How to use JSON Serde with Presto? …原创 2021-01-14 15:33:11 · 904 阅读 · 0 评论 -
Airpal安装部署
安装依赖yum -y install gcc gcc++ npm参考airbnb/airpal: Web UI for PrestoDB.https://github.com/airbnb/airpal#airpalAirpal 部署-11805010-51CTO博客https://blog.51cto.com/11815010/2137005?source=dra原创 2021-01-07 10:16:57 · 267 阅读 · 0 评论 -
idea连接presto
前提:商业版idea,社区版不可以类型选择H2填写连接信息,网上下载一个presto的jdbc驱动,自定义添加,然后测试就可以了原创 2021-01-07 09:12:24 · 494 阅读 · 0 评论 -
presto查询报错
原因: hdfs挂了,所以无法访问文件夹,重启hdfs即可Query 20210106_130152_00033_nifmw failed: Failed to list directory: hdfs://xx:8020原创 2021-01-06 21:13:42 · 1438 阅读 · 0 评论 -
presto自定义UDF函数
以大小写转换为例写个插件public class PrestoUdfPlugin implements Plugin { @Override public Set<Class<?>> getFunctions() { return ImmutableSet.<Class<?>>builder() // 添加插件class .add(MyFunctions.cla原创 2021-01-06 20:06:32 · 2177 阅读 · 1 评论 -
presto字符串转日期
方法1date_parse(string, format) → timestampParses string into a timestamp using format.> select date_parse('2020-12-05','%Y-%m-%d'); _col0------------------------- 2020-12-05 00:00:00.000方法2:> select (cast ('2020-12-05' as date));原创 2021-01-06 18:48:00 · 8842 阅读 · 0 评论 -
presto求时间差
date_diff(unit, timestamp1, timestamp2) → bigintReturns timestamp2 - timestamp1 expressed in terms of unit.原创 2021-01-06 16:20:13 · 9756 阅读 · 0 评论 -
presto Slice入门
存储byte public void test1() { //分配空间,20个byte大小 Slice slice = Slices.allocate(20); //在index为0的地方存一个byte 100 slice.setByte(0, 100); //在index为1的地方存一个byte 2000 //注意 byte的范围是最小值为-128,最大值为127(含) slice.setBy原创 2021-01-06 10:06:04 · 855 阅读 · 0 评论 -
presto grouping操作
grouping operation返回一个转换为十进制的位,指示分组中存在哪些列。 它必须与GROUPING SETS,ROLLUP,CUBE或GROUP BY结合使用,并且其参数必须与相应的GROUPING SETS,ROLLUP,CUBE或GROUP BY子句中引用的列完全匹配。对于给定的分组,如果分组中包含相应的列,则将位设置为0,否则将其设置为1。 例如,考虑以下查询:SELECT origin_state, origin_zip, destination_state, sum(package原创 2021-01-04 21:21:09 · 2827 阅读 · 2 评论 -
presto cube等复杂聚合函数
Presto还使用GROUPING SETS,CUBE和ROLLUP语法支持复杂的聚合。 使用此语法,用户可以执行需要在单个查询中对多组列进行聚合的分析。 复杂的分组操作不支持对由输入列组成的表达式进行分组。 仅允许使用列名或常规名称。复杂的分组操作通常等效于简单GROUP BY表达式的UNION ALL,如以下示例所示。 但是,当聚合的数据源不确定时,此等效项将不适用。GROUPING SETS分组集允许用户指定多个列进行分组。 不属于分组列的给定子列表的列被设置为NULL。SELECT * FR原创 2021-01-04 20:38:07 · 2639 阅读 · 0 评论 -
presto安装及入门
相比SparkSQL而言,Presto在查询性能上是优于SparkSQL的,同时对数据源的支持也是比SparkSQL丰富的。当然除了这两款OLAP外,还有impala,clickhouse,hawq,greenplum 等其他OLAP引擎,这些引擎都有各自的优势和适用场景安装使用...原创 2021-01-04 10:33:33 · 515 阅读 · 0 评论 -
presto时间戳转字符串
from_unixtime返回值类型是一个timestampfrom_unixtime(unixtime) → timestampReturns the UNIX timestamp unixtime as a timestamp.from_unixtime(unixtime, string) → timestamp with time zoneReturns the UNIX timestamp unixtime as a timestamp with time zone using stri原创 2021-01-04 19:39:17 · 9383 阅读 · 1 评论 -
presto 时间函数
时间函数0、当前日期/当前时间presto:adm> select current_date,current_time,current_timestamp【=now()】 -> ; _col0 | _col1 | _col2------------+------------------+----------------------------- 2019-04-28 | 13:04:22.232 PRC | 201原创 2021-01-04 19:13:45 · 14185 阅读 · 0 评论