Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-4505

Regression: DISTINCT with sub query gets wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • 5.5.2
    • 5.5.2
    • ExeMgr
    • None
    • 2021-1, 2021-2

    Description

      See regression/mysql/queries/working_tpch1_compareLogOnly/view/mts_view.sql:

      CREATE TABLE t1 (lid int, name char(10)) engine=columnstore;
      INSERT INTO t1 (lid, name) VALUES (1, 'YES'), (2, 'NO');
       
      CREATE TABLE t2 (  id int, gid int, lid int, dt date) engine=columnstore;
      INSERT INTO t2 (id, gid, lid, dt) VALUES
       (1, 1, 1, '2007-01-01'),(2, 1, 2, '2007-01-02'),
       (3, 2, 2, '2007-02-01'),(4, 2, 1, '2007-02-02');
       
      SELECT DISTINCT t2.gid,(SELECT t1.name FROM t1, t2 WHERE t1.lid  = t2.lid AND t2.gid = t1.lid and t1.lid =1 ) as clid FROM t2 order by 1,2;
      

      +------+------+
      | gid  | clid |
      +------+------+
      |    1 | YES  |
      |    2 | YES  |
      +------+------+
      

      However, if you strip off the order by, you get

      SELECT DISTINCT t2.gid,(SELECT t1.name FROM t1, t2 WHERE t1.lid  = t2.lid AND t2.gid = t1.lid and t1.lid =1 ) as clid FROM t2;
      

      +------+------+
      | gid  | clid |
      +------+------+
      |    1 | YES  |
      |    1 | YES  |
      |    2 | YES  |
      |    2 | YES  |
      +------+------+
      

      There should only be two rows returned

      Attachments

        Issue Links

          Activity

            People

              dleeyh Daniel Lee (Inactive)
              David.Hall David Hall (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.