hive和presto
1.本质区别
Hive是把一个查询转化成多个MapReduce任务,然后一个接一个执行。执行的中间结果通过对磁盘的读写来同步。然而,Presto没有使用MapReduce,它是通过一个定制的查询和执行引擎来完成的。它的所有的查询处理是在内存中,这也是它的性能很高的一个主要原因。
2.执行速度presto由于是基于内存的,而hive是在磁盘上读写的,因此presto比hive快很多,但是由于是基于内存的当多张大表关联操作时易引起内存溢出错误
3.处理json类型的数据presto处理如下:
select json_extract_scalar(xx[‘custom’],’$.position’) from table
hive处理如下:
select get_json_object(xx[‘custom’],’$.position’)
from table
(此外Presto还有一个函数json_extract是直接返回一个json串,根据需要自己需要选择函数)
4.列转行
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)