Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-24957

Wrong results when subquery has COALESCE in correlation predicate

    XMLWordPrintableJSON

Details

    Description

      Consider the following example:

      create table author (
          a_authorkey   int,
          a_name varchar(50));
      
      create table book (
          b_bookkey   int,
          b_title varchar(50),
          b_authorkey int);
      
      insert into author values (10, 'Victor Hugo');
      insert into author values (20, 'Alexandre Dumas');
      insert into author values (300, 'UNKNOWN');
      
      insert into book values (1, 'Les Miserables', 10);
      insert into book values (2, 'The Count of Monte Cristo', 20);
      insert into book values (3, 'Men Without Women', 30);
      insert into book values (4, 'Odyssey', null);
      
      select b.b_title
      from book b
      where exists
                (select a_authorkey
                 from author a
                 where coalesce(b.b_authorkey, 300) = a.a_authorkey);
      

      Expected results

      B_TITLE
      Les Miserables
      The Count of Monte Cristo
      Odyssey

      Actual results

      B_TITLE
      Les Miserables
      The Count of Monte Cristo

      Odyssey is missing from the result set and it shouldn't since with the application of COALESCE operator it should match with the UNKNOWN author.

      Attachments

        Issue Links

          Activity

            People

              zabetak Stamatis Zampetakis
              zabetak Stamatis Zampetakis
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m