Skip to content

Commit

Permalink
[fix](MHY) add order by clause in sql (apache#176)
Browse files Browse the repository at this point in the history
# Checklist
run those case in master, some case all failed without order by

* 内部Jira:
* 修复PR:
  * master:
  * 1.2-lts:
  * 1.2-lts: 
* Doris-master:
  * [ ] 已修复
  * [ ] 未修复
  * [ ] 无问题
* Doris-1.2-lts:
  * [ ] 已修复
  * [ ] 未修复
  * [ ] 无问题
* Doris-1.1-lts:
  * [ ] 已修复
  * [ ] 未修复
  * [ ] 无问题

---------

Co-authored-by: yongkang.zhong <zhongykk@qq.com>
  • Loading branch information
zhangstar333 and zy-kkk authored Apr 25, 2023
1 parent 7eef5f5 commit 57f35bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions regression-test/data/usercases/MHY/sql/q07.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
decimal-原始未截断 7.100000000
decimal-原始未截断 8.123456000
decimal-截断保留3位小数 7.100000000
decimal-截断保留3位小数 8.122999999
decimal-截断保留3位小数 8.123000000
decimal-截断保留5位小数 7.100000000
decimal-截断保留5位小数 8.123450000
decimal-截断保留7位小数 7.100000000
Expand All @@ -20,12 +20,12 @@ double-截断保留7位小数 7.1
double-截断保留7位小数 8.1234559

-- !q07_3 --
原始数据-未做类型和精度转换 8.120000000 9.123456000
原始数据-未做类型和精度转换 8.450000000 9.654321000
decimal-round四舍五入保留两位小数 8.120000000 9.120000000
decimal-round四舍五入保留两位小数 8.450000000 9.650000000
decimal-扩大类型 8.120000000 9.123456000
decimal-扩大类型 8.450000000 9.654321000
decimal-round四舍五入保留两位小数 8.119999999 9.120000000
decimal-round四舍五入保留两位小数 8.449999999 9.650000000
原始数据-未做类型和精度转换 8.120000000 9.123456000
原始数据-未做类型和精度转换 8.450000000 9.654321000

-- !q07_4 --
56.325554000
Expand Down
20 changes: 10 additions & 10 deletions regression-test/suites/usercases/MHY/sql/q07.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
with vb1 as( select '7.1' as col
union all
select '8.123456' as col )
select 'decimal-原始未截断' as type,
cast(col as decimal(24,6)) col
select * from (select 'decimal-原始未截断' as type,
cast(col as decimal(25,6)) col
from vb1
union all
select 'decimal-截断保留3位小数' as type,
Expand All @@ -14,13 +14,13 @@ select 'decimal-截断保留5位小数' as type,
from vb1
union all
select 'decimal-截断保留7位小数' as type,
truncate (cast(col as decimal(24,6)),7) col
from vb1;
truncate (cast(col as decimal(25,6)),7) col
from vb1) t order by type, col;

with vb1 as( select '7.1' as col
union all
select '8.123456' as col )
select 'double-原始未截断' as type,
select * from (select 'double-原始未截断' as type,
cast(col as double) col
from vb1
union all
Expand All @@ -34,14 +34,14 @@ from vb1
union all -- ******结果不符合预期:8.1234559*****
select 'double-截断保留7位小数' as type,
truncate (cast(col as double),7) col
from vb1;
from vb1) as t order by type,col;

with vb1 as( select cast('8.12' as decimal(20, 2)) as decimal_20_2,
cast('9.123456' as decimal(20, 6)) as decimal_20_6
union all
select cast('8.45' as decimal(20, 2)) as decimal_20_2,
cast('9.654321' as decimal(20, 6)) as decimal_20_6 )
select '原始数据-未做类型和精度转换' as type ,
select * from (select '原始数据-未做类型和精度转换' as type ,
decimal_20_2 ,
decimal_20_6
from vb1
Expand All @@ -52,9 +52,9 @@ select 'decimal-扩大类型' as type ,
from vb1
union all
select 'decimal-round四舍五入保留两位小数' as type, -- *** 扩大精度后四舍五入结果错误8.12结果为8.119999999
round(cast(decimal_20_2 as decimal(24,6)),2) decimal_20_2 ,
round(cast(decimal_20_6 as decimal(24,6)),2) decimal_20_6
from vb1;
round(cast(decimal_20_2 as decimal(25,6)),2) decimal_20_2 ,
round(cast(decimal_20_6 as decimal(25,6)),2) decimal_20_6
from vb1) as t order by type,decimal_20_2, decimal_20_6;

with vb1 as(
select cast('8.12' as decimal(20, 2)) as decimal_20_2,cast('9.123456' as decimal(20, 6)) as decimal_20_6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ PARTITION p202311 VALUES [('2023-11-01'), ('2023-12-01')),
PARTITION p202312 VALUES [('2023-12-01'), ('2024-01-01')))
DISTRIBUTED BY HASH(`date`, `idea_id`, `place_type`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 2",
"replication_allocation" = "tag.location.default: 1",
"bloom_filter_columns" = "date, place_type, idea_id",
"in_memory" = "false",
"storage_format" = "V2",
Expand Down

0 comments on commit 57f35bd

Please sign in to comment.