How hive replaces in subquery with left semi join

Source: Internet
Author: User

Execute the following hive sql:

SELECT * from Trackinfo where ds= $date and session_id in (select session_id from Rcmd_track_path where ds= $date and Add_ca Rt_flag>0 and Product_id>0);</span>

The following error is indicated:

Failed:parseexception line 2:39 cannot recognize input near ' select ' session_id "from" in expression specification

Cause analysis & solutions are as follows:

Hive does not support the use of in subqueries, consider replacing in with the left semi join, overwriting the above hive SQL as follows:

SELECT * from Trackinfo T1 left semi joins Rcmd_track_path T2 on (t1.session_id=t2.session_id and T2.add_cart_flag>0 and T2.product_id>0 and t1.ds= $date and t2.ds= $date);

Left semi Join usage reference: Https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins

How hive replaces in subquery with left semi join

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.