Skip to content

Commit 43514cd

Browse files
authored
Use decimals in TPC-H (#6311)
1 parent 0ff446d commit 43514cd

File tree

29 files changed

+187
-42
lines changed

29 files changed

+187
-42
lines changed

ydb/library/benchmarks/gen_queries/consts.yql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ $z1_2_35 = 1.2;
1313
$z0_05_35 = 0.05;
1414
$z0_9_35 = 0.9;
1515
$z1_1_35 = 1.1;
16+
$z0_5_35 = 0.5;
17+
$z100_35 = 100.;
18+
$z0_0001_35 = 0.0001;
19+
$z7_35 = 7.;
20+
21+
$z0_12 = 0.;
22+
$z1_12 = 1;
23+
$z0_0100001_12 = 0.0100001;
24+
$z0_07_12 = 0.07;
25+
$z0_2_12 = 0.2;
1626

1727
$round = ($x, $y) -> { return Math::Round($x, $y); };
1828
$upscale = ($x) -> { return $x; };

ydb/library/benchmarks/gen_queries/consts_decimal.yql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,16 @@ $z1_2_35 = cast("1.2" as decimal(35,2));
1313
$z0_05_35 = cast("0.05" as decimal(35,2));
1414
$z0_9_35 = cast("0.9" as decimal(35,2));
1515
$z1_1_35 = cast("1.1" as decimal(35,2));
16+
$z0_5_35 = cast("0.5" as decimal(35,2));
17+
$z100_35 = cast(100 as decimal(35,2));
18+
$z0_0001_35 = cast("0.0001" as decimal(35,2));
19+
$z7_35 = cast("7." as decimal(35,2));
20+
21+
$z0_12 = cast(0 as decimal(12,2));
22+
$z1_12 = cast(1 as decimal(12,2));
23+
$z0_0100001_12 = cast("0.0100001" as decimal(12,2));
24+
$z0_07_12 = cast("0.07" as decimal(12,2));
25+
$z0_2_12 = cast("0.2" as decimal(12,2));
26+
1627
$round = ($x,$y) -> {return $x;};
1728
$upscale = ($x) -> { return cast($x as decimal(35,9)); };

ydb/library/benchmarks/queries/tpch/yql/q1.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ select
99
l_linestatus,
1010
sum(l_quantity) as sum_qty,
1111
sum(l_extendedprice) as sum_base_price,
12-
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
13-
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
12+
sum(l_extendedprice * ($z1_12 - l_discount)) as sum_disc_price,
13+
sum(l_extendedprice * ($z1_12 - l_discount) * ($z1_12 + l_tax)) as sum_charge,
1414
avg(l_quantity) as avg_qty,
1515
avg(l_extendedprice) as avg_price,
1616
avg(l_discount) as avg_disc,

ydb/library/benchmarks/queries/tpch/yql/q10.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ on
6767
select
6868
c_custkey,
6969
c_name,
70-
sum(l_extendedprice * (1 - l_discount)) as revenue,
70+
sum(l_extendedprice * ($z1_12 - l_discount)) as revenue,
7171
c_acctbal,
7272
n_name,
7373
c_address,

ydb/library/benchmarks/queries/tpch/yql/q11.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ on
3232

3333
$threshold = (
3434
select
35-
sum(ps_supplycost * ps_availqty) * 0.0001000000 as threshold
35+
sum(ps_supplycost * ps_availqty) * $z0_0001_35 as threshold
3636
from
3737
$j2
3838
);

ydb/library/benchmarks/queries/tpch/yql/q14.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
$border = Date("1994-08-01");
88
select
9-
100.00 * sum(case
9+
$z100_35 * sum(case
1010
when p.p_type like 'PROMO%'
11-
then l.l_extendedprice * (1 - l.l_discount)
12-
else 0
13-
end) / sum(l.l_extendedprice * (1 - l.l_discount)) as promo_revenue
11+
then l.l_extendedprice * ($z1_12 - l.l_discount)
12+
else $z0_12
13+
end) / sum(l.l_extendedprice * ($z1_12 - l.l_discount)) as promo_revenue
1414
from
1515
{{lineitem}} as l
1616
join

ydb/library/benchmarks/queries/tpch/yql/q15.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $border = Date("1997-03-01");
88
$revenue0 = (
99
select
1010
l_suppkey as supplier_no,
11-
Math::Round(sum(l_extendedprice * (1 - l_discount)), -8) as total_revenue
11+
$round(sum(l_extendedprice * ($z1_12 - l_discount)), -8) as total_revenue
1212
from
1313
{{lineitem}}
1414
where

ydb/library/benchmarks/queries/tpch/yql/q17.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ where
1212

1313
$threshold = (
1414
select
15-
0.2 * avg(l_quantity) as threshold,
15+
$z0_2_12 * avg(l_quantity) as threshold,
1616
l.l_partkey as l_partkey
1717
from
1818
{{lineitem}} as l
@@ -33,7 +33,7 @@ on
3333
p.p_partkey = l.l_partkey;
3434

3535
select
36-
sum(l.l_extendedprice) / 7.0 as avg_yearly
36+
sum(l.l_extendedprice) / $z7_35 as avg_yearly
3737
from
3838
$l as l
3939
join

ydb/library/benchmarks/queries/tpch/yql/q19.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-- using 1680793381 as a seed to the RNG
66

77
select
8-
sum(l.l_extendedprice* (1 - l.l_discount)) as revenue
8+
sum(l.l_extendedprice* ($z1_12 - l.l_discount)) as revenue
99
from
1010
{{lineitem}} as l
1111
join

ydb/library/benchmarks/queries/tpch/yql/q20.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$border = Date("1993-01-01");
88
$threshold = (
99
select
10-
0.5 * sum(l_quantity) as threshold,
10+
$z0_5_35 * sum(l_quantity) as threshold,
1111
l_partkey as l_partkey,
1212
l_suppkey as l_suppkey
1313
from

0 commit comments

Comments
 (0)