Skip to content

Commit

Permalink
Remove extra CASTs (TPC-H YQL) (ydb-platform#4288)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hor911 authored May 7, 2024
1 parent 4782712 commit b139f2a
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion ydb/library/benchmarks/queries/tpch/ydb/q1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ select
from
`{path}lineitem`
where
CAST(l_shipdate AS Timestamp) <= (CAST('1998-12-01' AS Date) - Interval("P100D"))
l_shipdate <= CAST('1998-12-01' AS Date) - Interval("P100D")
group by
l_returnflag,
l_linestatus
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ join
on
c.c_custkey = o.o_custkey
where
cast(o.o_orderdate as timestamp) >= $border and
cast(o.o_orderdate as timestamp) < ($border + Interval("P90D"))
o.o_orderdate >= $border
and o.o_orderdate < ($border + Interval("P90D"))
);
$join2 = (
select
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q12.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ where
(l_shipmode = 'MAIL' or l_shipmode = 'TRUCK')
and l_commitdate < l_receiptdate
and l_shipdate < l_commitdate
and cast(l_receiptdate as timestamp) >= $border
and cast(l_receiptdate as timestamp) < ($border + Interval("P365D"))
and l_receiptdate >= $border
and l_receiptdate < ($border + Interval("P365D"))
group by
l_shipmode
order by
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q14.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ join
on
l.l_partkey = p.p_partkey
where
cast(l.l_shipdate as timestamp) >= $border
and cast(l.l_shipdate as timestamp) < ($border + Interval("P31D"));
l.l_shipdate >= $border
and l.l_shipdate < ($border + Interval("P31D"));
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q15.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $revenue0 = (
from
`{path}lineitem`
where
cast(l_shipdate as timestamp) >= $border
and cast(l_shipdate as timestamp) < ($border + Interval("P92D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P92D"))
group by
l_suppkey
);
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q20.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ select
from
`{path}lineitem`
where
cast(l_shipdate as timestamp) >= $border
and cast(l_shipdate as timestamp) < ($border + Interval("P365D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P365D"))
group by
l_partkey, l_suppkey
);
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ left semi join
on
c.c_custkey = o.o_custkey
where
CAST(o_orderdate AS Timestamp) < Date('1995-03-08')
o_orderdate < Date('1995-03-08')
);

$join2 = (
Expand All @@ -40,7 +40,7 @@ join
on
l.l_orderkey = o.o_orderkey
where
CAST(l_shipdate AS Timestamp) > Date('1995-03-08')
l_shipdate > Date('1995-03-08')
);

select
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ select
from
`{path}orders`
where
CAST(o_orderdate AS Timestamp) >= $border
and CAST(o_orderdate AS Timestamp) < DateTime::MakeDate(DateTime::ShiftMonths($border, 3))
o_orderdate >= $border
and o_orderdate < DateTime::MakeDate(DateTime::ShiftMonths($border, 3))
);

$l = (
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ join
on
c.c_custkey = o.o_custkey
where
CAST(o.o_orderdate AS Timestamp) >= $border
and CAST(o.o_orderdate AS Timestamp) < ($border + Interval("P365D"))
o.o_orderdate >= $border
and o.o_orderdate < ($border + Interval("P365D"))
);

$j5 = (
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/ydb/q6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ select
from
`{path}lineitem`
where
CAST(l_shipdate AS Timestamp) >= $border
and cast(l_shipdate as Timestamp) < ($border + Interval("P365D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P365D"))
and l_discount between 0.07 - 0.01 and 0.07 + 0.01
and l_quantity < 25;
2 changes: 1 addition & 1 deletion ydb/library/benchmarks/queries/tpch/ydb/q8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ join
`{path}orders` as o
on
o.o_orderkey = j.l_orderkey
where cast(cast(o_orderdate as Timestamp) as Date) between Date('1995-01-01') and Date('1996-12-31')
where o_orderdate between Date('1995-01-01') and Date('1996-12-31')
);
$join5 = (
select
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/benchmarks/queries/tpch/yql/q1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ select
from
{{lineitem}}
where
CAST(l_shipdate AS Timestamp) <= (CAST('1998-12-01' AS Date) - Interval("P100D"))
l_shipdate <= CAST('1998-12-01' AS Date) - Interval("P100D")
group by
l_returnflag,
l_linestatus
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ join
on
c.c_custkey = o.o_custkey
where
cast(o.o_orderdate as timestamp) >= $border and
cast(o.o_orderdate as timestamp) < ($border + Interval("P90D"))
o.o_orderdate >= $border
and o.o_orderdate < ($border + Interval("P90D"))
);
$join2 = (
select
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q12.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ where
(l_shipmode = 'MAIL' or l_shipmode = 'TRUCK')
and l_commitdate < l_receiptdate
and l_shipdate < l_commitdate
and cast(l_receiptdate as timestamp) >= $border
and cast(l_receiptdate as timestamp) < ($border + Interval("P365D"))
and l_receiptdate >= $border
and l_receiptdate < ($border + Interval("P365D"))
group by
l_shipmode
order by
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q14.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ join
on
l.l_partkey = p.p_partkey
where
cast(l.l_shipdate as timestamp) >= $border
and cast(l.l_shipdate as timestamp) < ($border + Interval("P31D"));
l.l_shipdate >= $border
and l.l_shipdate < ($border + Interval("P31D"));
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q15.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ $revenue0 = (
from
{{lineitem}}
where
cast(l_shipdate as timestamp) >= $border
and cast(l_shipdate as timestamp) < ($border + Interval("P92D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P92D"))
group by
l_suppkey
);
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q20.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ select
from
{{lineitem}}
where
cast(l_shipdate as timestamp) >= $border
and cast(l_shipdate as timestamp) < ($border + Interval("P365D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P365D"))
group by
l_partkey, l_suppkey
);
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ left semi join
on
c.c_custkey = o.o_custkey
where
CAST(o_orderdate AS Timestamp) < Date('1995-03-08')
o_orderdate < Date('1995-03-08')
);

$join2 = (
Expand All @@ -42,7 +42,7 @@ join
on
l.l_orderkey = o.o_orderkey
where
CAST(l_shipdate AS Timestamp) > Date('1995-03-08')
l_shipdate > Date('1995-03-08')
);

select
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ select
from
{{orders}}
where
CAST(o_orderdate AS Timestamp) >= $border
and CAST(o_orderdate AS Timestamp) < DateTime::MakeDate(DateTime::ShiftMonths($border, 3))
o_orderdate >= $border
and o_orderdate < DateTime::MakeDate(DateTime::ShiftMonths($border, 3))
);

$l = (
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ join
on
c.c_custkey = o.o_custkey
where
CAST(o.o_orderdate AS Timestamp) >= $border
and CAST(o.o_orderdate AS Timestamp) < ($border + Interval("P365D"))
o.o_orderdate >= $border
and o.o_orderdate < ($border + Interval("P365D"))
);

$j5 = (
Expand Down
4 changes: 2 additions & 2 deletions ydb/library/benchmarks/queries/tpch/yql/q6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ select
from
{{lineitem}}
where
CAST(l_shipdate AS Timestamp) >= $border
and cast(l_shipdate as Timestamp) < ($border + Interval("P365D"))
l_shipdate >= $border
and l_shipdate < ($border + Interval("P365D"))
and l_discount between 0.07 - 0.0100001 and 0.07 + 0.0100001
and l_quantity < 25;
2 changes: 1 addition & 1 deletion ydb/library/benchmarks/queries/tpch/yql/q8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ join
{{orders}} as o
on
o.o_orderkey = j.l_orderkey
where cast(cast(o_orderdate as Timestamp) as Date) between Date('1995-01-01') and Date('1996-12-31')
where o_orderdate between Date('1995-01-01') and Date('1996-12-31')
);
$join5 = (
select
Expand Down

0 comments on commit b139f2a

Please sign in to comment.