Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-8513

Right Hash Join with empty Left table ruturns 0 result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.22.0
    • None
    • None

    Description

      Drill returns no results on the right Hash Join if the probe(left) table is empty.

      The simplest way to reproduce the issue:

      1.To force Drill not to use merge join and use the hash join operator instead:

      alter session set planner.enable_mergejoin = false;
      alter session set planner.enable_nestedloopjoin= false; 

      2. Disable join order optimization to prevent Drill from flipping join tables:

      alter session set planner.enable_join_optimization = false;  

      3. Execute a query with empty left table outcome:

      SELECT *
      FROM 
          (SELECT * FROM (VALUES (1, 'Max', 28), 
                                 (2, 'Jane', 32),
                                 (3, 'Saymon', 29)
                         ) AS users(id, name, age)
          WHERE false
          ) AS users
      RIGHT JOIN 
          (VALUES (1, 'Engineer'), 
                  (2, 'Doctor'), 
                  (3, 'Teacher')
          ) AS job(id, title)
      ON users.id = job.id 

      Expected result is:

      id name age id0 title
      null null null 1 Engineer
      null null null 2 Doctor
      null null null 3 Teacher

      But we get 0 rows.

      Attachments

        Issue Links

          Activity

            People

              rymarm Maksym Rymar
              rymarm Maksym Rymar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: