forked from dbt-labs/dbt-bigquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create BQ version of string_literal with correct quoting (dbt-labs#1089)
* Create BQ version of string_literal with correct quoting * Fix macro for whitespace and add test. --------- Co-authored-by: dave-connors-3 <[email protected]> Co-authored-by: Mike Alfare <[email protected]> Co-authored-by: Mila Page <[email protected]> Co-authored-by: Mila Page <[email protected]>
- Loading branch information
1 parent
bd1eb66
commit 55689b9
Showing
3 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Fix dbt.string_literal for BQ when there are newlines | ||
time: 2024-02-05T10:29:54.145326+01:00 | ||
custom: | ||
Author: b-per | ||
Issue: "1088" |
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,3 @@ | ||
{%- macro bigquery__string_literal(value) -%} | ||
'''{{ value }}''' | ||
{%- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
from dbt.tests.util import run_dbt | ||
|
||
|
||
_MODEL_SQL = """ | ||
select {{ dbt.string_literal('my multiline | ||
string') }} as test | ||
""" | ||
|
||
|
||
class TestStringLiteralQuoting: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"my_model.sql": _MODEL_SQL} | ||
|
||
def test_string_literal_quoting(self, project): | ||
run_dbt() |