Some comparisons of Hive SQL and Presto sql

Source: Internet
Author: User

Recently because of work and life some things for a long time not to blog Park, but the habit of blogging is to insist, the new year needs more efforts, sleepy know Mian line, lifelong learning, every day to maintain empty cup mentality. Nonsense, write some of the most recently used Presto SQL and hive SQL experience and contrast.

One. JSON processing comparison
    • Hive

Select Get_json_object (JSON, ' $.book ');

    • Presto

Select Json_extract_scalar (JSON, ' $.book ');

Notice here that the Json_extract_scalar return value in Presto is a string type, and there is a function json_extract that returns a JSON string directly, so when you use it you have to know exactly what type of value to take.

Two. Column change comparison
    • 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);

In a nutshell, a comma-separated fractional column in the scores field, such as

80,90,99,80

This single-column value is converted to a value mapping with a one-to-many row for the student column.

Three. Complex grouping contrast
    • 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);

Used rollup know, this is a right-to-left descending multilevel statistic aggregation, equivalent to (as follows Presto notation)

Select Origin_state, Origin_zip, sum (package_weight) from shipping Group BY grouping sets ((Origin_state, Origin_zip), (or Igin_state), ());

Some of the other syntaxes have subtle differences that can be understood slowly, but the fact that hive is not the same as the Presto underlying architecture causes Presto to be much faster than hive operations, plus the open source Alluxio cache.

Some comparisons of Hive SQL and Presto sql

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.