-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
21 additions
and
68 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,16 +1,12 @@ | ||
{% macro fabric__get_limit_sql(sql, limit) %} | ||
|
||
{% if limit == -1 or limit is none %} | ||
with model_limit_subq as ( | ||
{{ sql }} | ||
) | ||
select * | ||
from model_limit_subq; | ||
{% else -%} | ||
with model_limit_subq as ( | ||
{{ sql }} | ||
) | ||
select top {{ limit }} * | ||
from model_limit_subq; | ||
{%- if limit == -1 or limit is none -%} | ||
{{ sql }} | ||
{#- Special processing if the last non-blank line starts with order by -#} | ||
{%- elif 'order by' in sql.strip().splitlines()[-1].strip().lower() -%} | ||
{{ sql }} | ||
offset 0 rows fetch first {{ limit }} rows only | ||
{%- else -%} | ||
{{ sql }} | ||
order by (select null) offset 0 rows fetch first {{ limit }} rows only | ||
{%- endif -%} | ||
{% endmacro %} |
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
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