Skip to content

[Bug]: q34: HAVING COUNT boundary mismatch (MO 519 vs MySQL 471) #24208

Closed

Description

@Ariznawlll

标题

q34: HAVING COUNT 边界判定不一致(MO 519 vs MySQL 471)

复现步骤

  1. SQL 文件: query_1g_mo/query34.sql。
  2. 执行(MO/MySQL)并保存结果:
mysql -h <MO_HOST> -P <MO_PORT> -u<MO_USER> -p<MO_PASS> tpcds -N -B < query_1g_mo/query34.sql > /tmp/query34.mo.result 2> /tmp/query34.mo.err
mysql -h <MYSQL_HOST> -P <MYSQL_PORT> -u<MYSQL_USER> -p<MYSQL_PASS> tpcds -N -B < query_1g_mo/query34.sql > /tmp/query34.mysql.result 2> /tmp/query34.mysql.err
wc -l /tmp/query34.mo.result /tmp/query34.mysql.result

复现 SQL

select c_last_name
       ,c_first_name
       ,c_salutation
       ,c_preferred_cust_flag
       ,ss_ticket_number
       ,cnt from
   (select ss_ticket_number
          ,ss_customer_sk
          ,count(*) cnt
    from store_sales,date_dim,store,household_demographics
    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
    and store_sales.ss_store_sk = store.s_store_sk
    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
    and (household_demographics.hd_buy_potential = '1001-5000' or
         household_demographics.hd_buy_potential = '0-500')
    and household_demographics.hd_vehicle_count > 0
    and (case when household_demographics.hd_vehicle_count > 0
        then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count
        else null
    end) > 1.2
    and date_dim.d_year in (2000,2000+1,2000+2)
    and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County',
                           'Williamson County','Williamson County','Williamson County','Williamson County')
    group by ss_ticket_number,ss_customer_sk) dn,customer
    where ss_customer_sk = c_customer_sk
      and cnt between 15 and 20
    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number;

期望结果

cnt between 15 and 20 的边界过滤应稳定一致。

实际结果

  • MO lines: 519
  • MySQL lines: 471
  • 示例: 同 key 下 cnt 存在 17 vs 16 差异。

影响评估

高影响。聚合边界错误会改变统计结论。

优先级

P1

验收标准

  1. 行数与参考实现一致。
  2. 抽样 ticket 的 cnt 值逐项一致。
  3. HAVING 边界值(15/20)覆盖回归用例。

Activity

  1. changed the title [-]q34: HAVING COUNT boundary mismatch (MO 519 vs MySQL 471)[/-] [+][Bug]: q34: HAVING COUNT boundary mismatch (MO 519 vs MySQL 471)[/+] on Apr 27, 2026
  2. added
    kind/bug
    on Apr 27, 2026
  3. added theissue type on Apr 27, 2026
  4. added this to the MO-202605 milestone on Apr 27, 2026
  5. self-assigned this
    on Apr 27, 2026
  6. matrix-meow commented on Apr 29, 2026

    @matrix-meow
    Contributor

    Hello @Ariznawlll. The bug issue in the BVT test code has not been removed,issues automatically open.

  7. gouhongshen commented on May 6, 2026

    @gouhongshen
    Contributor

    fixed

  8. Ariznawlll commented on May 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verification

    Tested on main branch, commit 8b18b39 (2026-05-14), TPC-DS 1G data on MO.

    q34 result: 471 rows (matches MySQL/PostgreSQL baseline). Previously returned 519 rows due to nullable group-key metadata being lost in AP MergeGroup path.

    Cannot reproduce. Fixed by #24223. Closing.

  9. Ariznawlll commented on May 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verification (updated)

    Tested on main branch, commit 8b18b39 (2026-05-14), TPC-DS 1G data.

    q34: 471 rows, exact match with MySQL baseline. Previously returned 519 rows. Fixed by #24223. ✅

  10. Ariznawlll commented on May 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verification (with result data)

    Tested on main branch, commit 8b18b39 (2026-05-14), TPC-DS 1G data.

    Result: 471 rows, exact match with MySQL baseline ✅

    First 5 rows:

    c_last_name  c_first_name  c_salutation  c_preferred_cust_flag  ss_ticket_number  cnt
                 (null)        (null)        Y                      53729             15
                 (null)        (null)        Y                      217817            16
                 (null)        (null)        N                      152278            15
                 (null)        (null)        N                      221914            15
    

    (471 rows total — full result matches MySQL golden line-by-line)

    Previously returned 519 rows due to nullable group-key metadata lost in AP MergeGroup path. Fixed by #24223. ✅

  11. Ariznawlll commented on May 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verification

    Tested on main branch, commit 8b18b39 (2026-05-14), TPC-DS 1G dataset.

    q34 result: 471 rows — matches MySQL/PostgreSQL baseline. Previously returned 519 rows due to nullable group-key metadata loss in AP MergeGroup.

    Cannot reproduce. Fixed by #24223. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions