-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
tests/data/unit_tests/test_merger/test_maybe_stubbornly_merge.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
-- try to merge the first line of this segment with the previous segment | ||
count( | ||
* | ||
) | ||
over ( | ||
partition by | ||
foofoofoofoofoofoofoofoofoo | ||
order by | ||
foofoofoofoofoofoofoofoofoo asc | ||
rows between unbounded preceding and unbounded following | ||
), | ||
|
||
-- try to add this segment to the last line of the previous segment | ||
( | ||
foofoofoofoofoofoofoofoofoo | ||
+ barbarbarbarbarbarbarbarbar | ||
+ bazbazbazbazbazbazbazbazbaz | ||
) | ||
::decimal( | ||
18, | ||
2 | ||
), | ||
|
||
-- try to add just the first line of this segment to the last | ||
-- line of the previous segment | ||
sum( | ||
case | ||
when | ||
foo | ||
then | ||
foo + bar + baz | ||
when | ||
bar | ||
then | ||
bar + baz + qux | ||
when | ||
baz | ||
then | ||
something_else_long | ||
end | ||
) | ||
over ( | ||
partition by | ||
foofoofoofoofoofoofoofoofoo | ||
order by | ||
foofoofoofoofoofoofoofoofoo asc | ||
rows between unbounded preceding and unbounded following | ||
), | ||
|
||
-- give up and just return the original segments | ||
a_very_very_long_cte_name_that_is_just_under_eighty_eight_characters_in_length_xxxxxxx | ||
as ( | ||
select | ||
1 | ||
) | ||
)))))__SQLFMT_OUTPUT__((((( | ||
-- try to merge the first line of this segment with the previous segment | ||
count(*) over ( | ||
partition by | ||
foofoofoofoofoofoofoofoofoo | ||
order by | ||
foofoofoofoofoofoofoofoofoo asc | ||
rows between unbounded preceding and unbounded following | ||
), | ||
|
||
-- try to add this segment to the last line of the previous segment | ||
( | ||
foofoofoofoofoofoofoofoofoo | ||
+ barbarbarbarbarbarbarbarbar | ||
+ bazbazbazbazbazbazbazbazbaz | ||
)::decimal(18, 2), | ||
|
||
-- try to add just the first line of this segment to the last | ||
-- line of the previous segment | ||
sum( | ||
case | ||
when | ||
foo | ||
then | ||
foo + bar + baz | ||
when | ||
bar | ||
then | ||
bar + baz + qux | ||
when | ||
baz | ||
then | ||
something_else_long | ||
end | ||
) over ( | ||
partition by | ||
foofoofoofoofoofoofoofoofoo | ||
order by | ||
foofoofoofoofoofoofoofoofoo asc | ||
rows between unbounded preceding and unbounded following | ||
), | ||
|
||
-- give up and just return the original segments | ||
a_very_very_long_cte_name_that_is_just_under_eighty_eight_characters_in_length_xxxxxxx | ||
as ( | ||
select | ||
1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters