Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Group By 索引号语句结果与MySQL中表现不一致 #17150

Closed
1 task done
WuMenglong opened this issue Jun 25, 2024 · 9 comments
Closed
1 task done

[Bug]: Group By 索引号语句结果与MySQL中表现不一致 #17150

WuMenglong opened this issue Jun 25, 2024 · 9 comments
Assignees
Labels
kind/bug Something isn't working kind/compatibility The compatibility with mysql 8.0 should be discussed further. phase/testing severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Milestone

Comments

@WuMenglong
Copy link

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

v1.1.3

Commit ID

14c4496

Other Environment Information

No response

Actual Behavior

问题描述:
使用 Tableau ODBC 方式连接 MatrixOne,在使用 Tableau 分析时,其生成的 SQL 执行出现多处如下报错:
5c4d60f0d257d6311cad4fe5ae280b9

根据提示,调整 sql_mode,关闭 ONLY_FULL_GROUP_BY 模式:

SET global sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_TRANS_TAB LES';

关闭 ONLY_FULL_GROUP_BY 后上述报错不再出现,但Group By 1的执行结果集与在 MySQL 下的不一致,且由于是 BI 中自动生成的语句,无法人为手动调整SQL为 GROUP BY YEAR(time_1):
MySQL:
image

MatrixOne:
image

Expected Behavior

No response

Steps to Reproduce

以下是不需要使用BI的复现操作:
-- 创建数据库

CREATE DATABASE stock_data;

-- 创建表
```sql
USE stock_data;
CREATE TABLE stockpriceus2_5min_copy1 (
    id INT AUTO_INCREMENT PRIMARY KEY,
    time_1 DATETIME,
    price DECIMAL(10, 2)
);

-- 插入示例数据

INSERT INTO stockpriceus2_5min_copy1 (time_1, price) VALUES 
('2023-06-25 14:00:00', 150.50),
('2023-06-25 14:05:00', 151.00),
('2022-06-25 14:10:00', 149.75),
('2021-06-25 14:15:00', 148.25),
('2020-06-25 14:20:00', 147.00);

-- 执行SQL

# 与MySQL结果一致的SQL
SELECT YEAR(`time_1`) AS yr_time_1_ok
FROM stockpriceus2_5min_copy1
GROUP BY YEAR(`time_1`);

# 与MySQL不一致SQL
SELECT YEAR(`time_1`) AS yr_time_1_ok
FROM stockpriceus2_5min_copy1
GROUP BY 1;


### Additional information

_No response_
@volgariver6
Copy link
Contributor

@daviszhen please help on it.

@dengn dengn added kind/compatibility The compatibility with mysql 8.0 should be discussed further. mysql-compability labels Jun 26, 2024
@dengn dengn added this to the 1.2.2 milestone Jun 26, 2024
@aronchanisme aronchanisme added severity/s0 Extreme impact: Cause the application to break down and seriously affect the use and removed needs-triage severity/s-1 labels Jun 26, 2024
@aronchanisme
Copy link
Contributor

  1. Business impact:
    Issue from community user, which has an impact on BI tool Tableau connecting to MO. Not a PRD case.

  2. Severity
    Downgrade from s-1 to s0 based on business impact

  3. Target version
    Probably can be fixed in v1.2.2 based on dev assessment and roadmap of v1.2.1

@aunjgr aunjgr assigned aunjgr and unassigned daviszhen Jun 26, 2024
@aunjgr
Copy link
Contributor

aunjgr commented Jul 3, 2024

on leave

@aunjgr
Copy link
Contributor

aunjgr commented Jul 9, 2024

main上已解决。1.2等pr合并

@aunjgr
Copy link
Contributor

aunjgr commented Jul 11, 2024

PR都合并了。

@aronchanisme
Copy link
Contributor

待验证

1 similar comment
@aronchanisme
Copy link
Contributor

待验证

@aronchanisme
Copy link
Contributor

Fixed. @WuMenglong Pls kindly take a look, thx.

Test result

  1. 1.2-dev(ebcfce8e5)
github@test0:/data/mo/1.2-dev/matrixone$ mo_ctl connect
2024-07-22 10:44:21.298 UTC+0800    [INFO]    Checking connectivity
2024-07-22 10:44:21.386 UTC+0800    [INFO]    Ok, connecting for user ... 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7004
Server version: 8.0.30-MatrixOne-v85 MatrixOne

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE stock_data;
Query OK, 1 row affected (0.04 sec)

mysql> 
mysql> -- 创建表
mysql> ```sql
    `> USE stock_data;
    `> CREATE TABLE stockpriceus2_5min_copy1 (
    `>     id INT AUTO_INCREMENT PRIMARY KEY,
    `>     time_1 DATETIME,
    `>     price DECIMAL(10, 2)
    `> );
    `> 
    `> ^C
mysql> USE stock_data;
Database changed
mysql> CREATE TABLE stockpriceus2_5min_copy1 (
    ->     id INT AUTO_INCREMENT PRIMARY KEY,
    ->     time_1 DATETIME,
    ->     price DECIMAL(10, 2)
    -> );
Query OK, 0 rows affected (0.04 sec)

mysql> INSERT INTO stockpriceus2_5min_copy1 (time_1, price) VALUES 
    -> ('2023-06-25 14:00:00', 150.50),
    -> ('2023-06-25 14:05:00', 151.00),
    -> ('2022-06-25 14:10:00', 149.75),
    -> ('2021-06-25 14:15:00', 148.25),
    -> ('2020-06-25 14:20:00', 147.00);
Query OK, 5 rows affected (0.01 sec)

mysql> select * from stockpriceus2_5min_copy1;
+------+---------------------+--------+
| id   | time_1              | price  |
+------+---------------------+--------+
|    1 | 2023-06-25 14:00:00 | 150.50 |
|    2 | 2023-06-25 14:05:00 | 151.00 |
|    3 | 2022-06-25 14:10:00 | 149.75 |
|    4 | 2021-06-25 14:15:00 | 148.25 |
|    5 | 2020-06-25 14:20:00 | 147.00 |
+------+---------------------+--------+
5 rows in set (0.00 sec)

mysql> SELECT YEAR(`time_1`) AS yr_time_1_ok
    -> FROM stockpriceus2_5min_copy1
    -> GROUP BY YEAR(`time_1`);
+--------------+
| yr_time_1_ok |
+--------------+
|         2023 |
|         2022 |
|         2021 |
|         2020 |
+--------------+
4 rows in set (0.00 sec)

mysql> SELECT YEAR(`time_1`) AS yr_time_1_ok
    -> FROM stockpriceus2_5min_copy1
    -> GROUP BY 1;
+--------------+
| yr_time_1_ok |
+--------------+
|         2023 |
|         2022 |
|         2021 |
|         2020 |
+--------------+
4 rows in set (0.00 sec)

mysql> select git_version();
+---------------+
| git_version() |
+---------------+
| ebcfce8e5     |
+---------------+
1 row in set (0.00 sec)

mysql> system mo_ctl get_cid
2024-07-22 10:45:13.079 UTC+0800    [INFO]    Try get mo commit id
commit ebcfce8e541ecd1dfb05411553b5e6b15da09741
Author: LiuBo <[email protected]>
Date:   Fri Jul 19 22:04:24 2024 +0800

    [enhancement] stats: add metrics for stats trigger updating (#17618)
    
    add metrics for stats trigger updating
    
    Approved by: @XuPeng-SH, @zhangxu19830126, @sukki37
2024-07-22 10:45:13.134 UTC+0800    [INFO]    Get commit id succeeded
mysql> system mo_ctl get_branch
2024-07-22 10:45:15.092 UTC+0800    [INFO]    Try get mo branch
2024-07-22 10:45:15.144 UTC+0800    [INFO]    Get branch succeeded, current branch: 1.2-dev
mysql> exit
Bye
2024-07-22 10:45:18.354 UTC+0800    [INFO]    Connect succeeded and finished. Bye
  1. main(0cc26c508)
github@test0:/data/mo/1.2-dev/matrixone$ mo_ctl connect
2024-07-22 10:47:04.439 UTC+0800    [INFO]    Checking connectivity
2024-07-22 10:47:04.513 UTC+0800    [INFO]    Ok, connecting for user ... 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2704
Server version: 8.0.30-MatrixOne-v026508 MatrixOne

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select git_version();
+---------------+
| git_version() |
+---------------+
| 0cc26c508     |
+---------------+
1 row in set (0.00 sec)

mysql> system mo_ctl get_cid
2024-07-22 10:47:16.499 UTC+0800    [INFO]    Try get mo commit id
commit 0cc26c5089c918c6feb3a0548f06f19c82e0a766
Author: nitao <[email protected]>
Date:   Mon Jul 22 01:01:55 2024 +0800

    Refactor prepare to reuse Compile part 2 (#17625)
    
    fix a bug that cause tpch hang when refactoring prepare statement
    
    Approved by: @ouyuanning
2024-07-22 10:47:16.550 UTC+0800    [INFO]    Get commit id succeeded
mysql> system mo_ctl get_branch
2024-07-22 10:47:18.418 UTC+0800    [INFO]    Try get mo branch
2024-07-22 10:47:18.474 UTC+0800    [INFO]    Get branch succeeded, current branch: main
mysql> CREATE DATABASE stock_data;
Query OK, 1 row affected (0.05 sec)

mysql> USE stock_data;
Database changed
mysql> CREATE TABLE stockpriceus2_5min_copy1 (
    ->     id INT AUTO_INCREMENT PRIMARY KEY,
    ->     time_1 DATETIME,
    ->     price DECIMAL(10, 2)
    -> );
Query OK, 0 rows affected (0.04 sec)

mysql> INSERT INTO stockpriceus2_5min_copy1 (time_1, price) VALUES 
    -> ('2023-06-25 14:00:00', 150.50),
    -> ('2023-06-25 14:05:00', 151.00),
    -> ('2022-06-25 14:10:00', 149.75),
    -> ('2021-06-25 14:15:00', 148.25),
    -> ('2020-06-25 14:20:00', 147.00);
Query OK, 5 rows affected (0.02 sec)

mysql> select * from stockpriceus2_5min_copy1;
+------+---------------------+--------+
| id   | time_1              | price  |
+------+---------------------+--------+
|    1 | 2023-06-25 14:00:00 | 150.50 |
|    2 | 2023-06-25 14:05:00 | 151.00 |
|    3 | 2022-06-25 14:10:00 | 149.75 |
|    4 | 2021-06-25 14:15:00 | 148.25 |
|    5 | 2020-06-25 14:20:00 | 147.00 |
+------+---------------------+--------+
5 rows in set (0.00 sec)

mysql> SELECT YEAR(`time_1`) AS yr_time_1_ok
    -> FROM stockpriceus2_5min_copy1
    -> GROUP BY YEAR(`time_1`);
+--------------+
| yr_time_1_ok |
+--------------+
|         2023 |
|         2022 |
|         2021 |
|         2020 |
+--------------+
4 rows in set (0.00 sec)

mysql> SELECT YEAR(`time_1`) AS yr_time_1_ok
    -> FROM stockpriceus2_5min_copy1
    -> GROUP BY 1;
+--------------+
| yr_time_1_ok |
+--------------+
|         2023 |
|         2022 |
|         2021 |
|         2020 |
+--------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
2024-07-22 10:47:48.675 UTC+0800    [INFO]    Connect succeeded and finished. Bye

@heni02
Copy link
Contributor

heni02 commented Aug 27, 2024

@Ariznawlll 添加到bvtcase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working kind/compatibility The compatibility with mysql 8.0 should be discussed further. phase/testing severity/s0 Extreme impact: Cause the application to break down and seriously affect the use
Projects
None yet
Development

No branches or pull requests

9 participants