-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiline column descriptions result in unclosed string literals #421
Comments
Thanks for raising it! We will fix it in a patch in the next day or so. |
Sweet! Thanks, Benoit. |
Hey all, any update on this? Any ETA? |
Thanks for the follow-up. It slipped my mind. We have a fix in #422 but it wasn't merged yet as we had some comments about it. |
Hmmm, that's odd. I can't seem to be able to reproduce it... What do you get if you do a:
Does it fail as well? And are there some logs in BQ that you'd be able to share? |
It does fail:
|
Thanks. There is a problem with this macro then, because it works for me locally.
|
here's the full output of the three commands: $ dbt clean && dbt deps && dbt show --inline 'select {{ dbt_project_evaluator.wrap_string_with_quotes("ab\nc")}} '
20:49:07 Running with dbt=1.7.13
20:49:08 Checking /workspaces/inquirer-dbt/logs/*
20:49:08 Cleaned /workspaces/inquirer-dbt/logs/*
20:49:08 Checking /workspaces/inquirer-dbt/dbt_packages/*
20:49:08 Cleaned /workspaces/inquirer-dbt/dbt_packages/*
20:49:08 Checking /workspaces/inquirer-dbt/target-base/*
20:49:08 Cleaned /workspaces/inquirer-dbt/target-base/*
20:49:08 Checking /workspaces/inquirer-dbt/target/*
20:49:08 Cleaned /workspaces/inquirer-dbt/target/*
20:49:08 Finished cleaning all paths.
20:49:10 Running with dbt=1.7.13
20:49:11 Installing dbt-labs/dbt_utils
20:49:11 Installed from version 1.1.1
20:49:11 Up to date!
20:49:11 Installing calogica/dbt_expectations
20:49:11 Installed from version 0.10.3
20:49:11 Up to date!
20:49:11 Installing dbt-labs/codegen
20:49:11 Installed from version 0.12.1
20:49:11 Up to date!
20:49:11 Installing data-mie/dbt_profiler
20:49:11 Installed from version 0.8.1
20:49:11 Up to date!
20:49:11 Installing dbt-labs/dbt_project_evaluator
20:49:11 Installed from version 0.11.0
20:49:11 Up to date!
20:49:11 Installing brooklyn-data/dbt_artifacts
20:49:11 Installed from version 2.6.2
20:49:11 Up to date!
20:49:11 Installing elementary-data/elementary
20:49:12 Installed from version 0.14.1
20:49:12 Up to date!
20:49:12 Installing dbt-labs/audit_helper
20:49:12 Installed from version 0.11.0
20:49:12 Up to date!
20:49:12 Installing grafana/leaner_query
20:49:12 Installed from version 0.1.12
20:49:12 Up to date!
20:49:12 Installing Velir/ga4
20:49:12 Installed from version 6.0.1
20:49:12 Up to date!
20:49:12 Installing calogica/dbt_date
20:49:12 Installed from version 0.10.1
20:49:12 Up to date!
20:49:15 Running with dbt=1.7.13
20:49:16 Registered adapter: bigquery=1.7.7
20:49:16 Unable to do partial parsing because saved manifest not found. Starting full parse.
20:49:37 [WARNING]: Did not find matching node for patch with name 'dim_query_statement' in the 'models' section of file 'models/marts/bigquery_audit_log.yml'
20:49:37 [WARNING]: Did not find matching node for patch with name 'int_dbt_execution_info' in the 'models' section of file 'models/intermediate/int_bigquery_audit_log.yml'
20:49:37 [WARNING]: Did not find matching node for patch with name 'int_importance_calculation' in the 'models' section of file 'models/intermediate/int_bigquery_audit_log.yml'
20:49:38 [WARNING]: Test 'test.leaner_query.not_null_dim_query_statement_job_key.dde1be6c77' (models/marts/bigquery_audit_log.yml) depends on a node named 'dim_query_statement' in package '' which was not found
20:49:40 Found 478 models, 5 snapshots, 294 tests, 18 seeds, 179 sources, 1 exposure, 39 metrics, 1738 macros, 0 groups, 7 semantic models
20:49:40
20:49:40 Concurrency: 4 threads (target='dev')
20:49:40
20:49:41 BigQuery adapter: https://console.cloud.google.com/bigquery?project=inq-warehouse&j=bq:US:f0f374a1-2a89-4feb-983a-fbe9facb879a&page=queryresults
20:49:41 Encountered an error:
Runtime Error
Database Error in sql_operation inline_query (from remote system.sql)
Syntax error: Unclosed string literal at [8:5]
It is. Here's the full contents of the file {% macro wrap_string_with_quotes(str) %}
{% if str is none %}
{{ return('cast(NULL as ' ~ dbt.type_string() ~ ')') }}
{% else %}
{{ dbt.string_literal(str) }}
{% endif %}
{% endmacro %}
{#
To be removed when https://github.com/dbt-labs/dbt-bigquery/pull/1089 is merged
#}
{% macro bigquery__string_literal(value) -%}
'''{{ value }}'''
{%- endmacro %}
We did not. |
We will get to the bottom of it 😄 What I am thinking now then is that one of the other packages you have is definining
|
Ok, some progress here! Specifically, the change to the
I'm only seeing it defined in $ dbt clean && dbt deps && grep -iR "bigquery__string_literal" ./dbt_packages
16:41:25 Running with dbt=1.7.13
16:41:25 Checking /workspaces/inquirer-dbt/target/*
16:41:25 Cleaned /workspaces/inquirer-dbt/target/*
16:41:25 Checking /workspaces/inquirer-dbt/dbt_packages/*
16:41:26 Cleaned /workspaces/inquirer-dbt/dbt_packages/*
16:41:26 Checking /workspaces/inquirer-dbt/logs/*
16:41:26 Cleaned /workspaces/inquirer-dbt/logs/*
16:41:26 Checking /workspaces/inquirer-dbt/target-base/*
16:41:26 Cleaned /workspaces/inquirer-dbt/target-base/*
16:41:26 Finished cleaning all paths.
16:41:28 Running with dbt=1.7.13
16:41:29 Installing dbt-labs/dbt_utils
16:41:29 Installed from version 1.1.1
16:41:29 Up to date!
16:41:29 Installing calogica/dbt_expectations
16:41:29 Installed from version 0.10.3
16:41:29 Up to date!
16:41:29 Installing dbt-labs/codegen
16:41:29 Installed from version 0.12.1
16:41:29 Up to date!
16:41:29 Installing data-mie/dbt_profiler
16:41:29 Installed from version 0.8.1
16:41:29 Up to date!
16:41:29 Installing dbt-labs/dbt_project_evaluator
16:41:29 Installed from version 0.11.0
16:41:29 Up to date!
16:41:29 Installing brooklyn-data/dbt_artifacts
16:41:29 Installed from version 2.6.2
16:41:29 Up to date!
16:41:29 Installing elementary-data/elementary
16:41:29 Installed from version 0.14.1
16:41:29 Up to date!
16:41:29 Installing dbt-labs/audit_helper
16:41:29 Installed from version 0.11.0
16:41:29 Up to date!
16:41:29 Installing grafana/leaner_query
16:41:30 Installed from version 0.1.12
16:41:30 Up to date!
16:41:30 Installing Velir/ga4
16:41:30 Installed from version 6.0.1
16:41:30 Up to date!
16:41:30 Installing calogica/dbt_date
16:41:30 Installed from version 0.10.1
16:41:30 Up to date!
./dbt_packages/dbt_project_evaluator/macros/wrap_string_with_quotes.sql:{% macro bigquery__string_literal(value) -%}
After running "macro.dbt_project_evaluator.bigquery__string_literal": {
"name": "bigquery__string_literal",
"resource_type": "macro",
"package_name": "dbt_project_evaluator",
"path": "macros/wrap_string_with_quotes.sql",
"original_file_path": "macros/wrap_string_with_quotes.sql",
"unique_id": "macro.dbt_project_evaluator.bigquery__string_literal",
"macro_sql": "{% macro bigquery__string_literal(value) -%}\n '''{{ value }}'''\n{%- endmacro %}",
"depends_on": { "macros": [] },
"description": "",
"meta": {},
"docs": { "show": true, "node_color": null },
"patch_path": null,
"arguments": [],
"created_at": 1714495463.5902495,
"supported_languages": null
},
That resolved the issue! $ dbt clean && dbt deps && dbt show --inline 'select {{ dbt_project_evaluator.wrap_string_with_quotes("ab\nc")}} '
16:53:21 Running with dbt=1.7.13
16:53:21 Checking /workspaces/inquirer-dbt/target-base/*
16:53:21 Cleaned /workspaces/inquirer-dbt/target-base/*
16:53:21 Checking /workspaces/inquirer-dbt/target/*
16:53:21 Cleaned /workspaces/inquirer-dbt/target/*
16:53:21 Checking /workspaces/inquirer-dbt/dbt_packages/*
16:53:21 Cleaned /workspaces/inquirer-dbt/dbt_packages/*
16:53:21 Checking /workspaces/inquirer-dbt/logs/*
16:53:21 Cleaned /workspaces/inquirer-dbt/logs/*
16:53:21 Finished cleaning all paths.
16:53:24 Running with dbt=1.7.13
16:53:25 Installing dbt-labs/dbt_utils
16:53:25 Installed from version 1.1.1
16:53:25 Up to date!
16:53:25 Installing calogica/dbt_expectations
16:53:25 Installed from version 0.10.3
16:53:25 Up to date!
16:53:25 Installing dbt-labs/codegen
16:53:25 Installed from version 0.12.1
16:53:25 Up to date!
16:53:25 Installing data-mie/dbt_profiler
16:53:25 Installed from version 0.8.1
16:53:25 Up to date!
16:53:25 Installing dbt-labs/dbt_project_evaluator
16:53:25 Installed from version 0.11.0
16:53:25 Up to date!
16:53:25 Installing brooklyn-data/dbt_artifacts
16:53:25 Installed from version 2.6.2
16:53:25 Up to date!
16:53:25 Installing elementary-data/elementary
16:53:25 Installed from version 0.14.1
16:53:25 Up to date!
16:53:25 Installing dbt-labs/audit_helper
16:53:25 Installed from version 0.11.0
16:53:25 Up to date!
16:53:25 Installing grafana/leaner_query
16:53:25 Installed from version 0.1.12
16:53:25 Up to date!
16:53:25 Installing Velir/ga4
16:53:25 Installed from version 6.0.1
16:53:25 Up to date!
16:53:25 Installing calogica/dbt_date
16:53:26 Installed from version 0.10.1
16:53:26 Up to date!
16:53:28 Running with dbt=1.7.13
16:53:30 Registered adapter: bigquery=1.7.7
16:53:30 Unable to do partial parsing because saved manifest not found. Starting full parse.
16:53:50 [WARNING]: Did not find matching node for patch with name 'dim_query_statement' in the 'models' section of file 'models/marts/bigquery_audit_log.yml'
16:53:50 [WARNING]: Did not find matching node for patch with name 'int_dbt_execution_info' in the 'models' section of file 'models/intermediate/int_bigquery_audit_log.yml'
16:53:50 [WARNING]: Did not find matching node for patch with name 'int_importance_calculation' in the 'models' section of file 'models/intermediate/int_bigquery_audit_log.yml'
16:53:50 [WARNING]: Test 'test.leaner_query.not_null_dim_query_statement_job_key.dde1be6c77' (models/marts/bigquery_audit_log.yml) depends on a node named 'dim_query_statement' in package '' which was not found
16:53:52 Found 478 models, 5 snapshots, 294 tests, 18 seeds, 179 sources, 1 exposure, 39 metrics, 1738 macros, 0 groups, 7 semantic models
16:53:53
16:53:53 Concurrency: 4 threads (target='dev')
16:53:53
16:53:54 Previewing inline node:
| f0_ |
| ---- |
| ab
c |
|
I am still puzzled but will take the The |
Thanks for all the assistance, @b-per. FWIW, there's one additional instance of "macro.dbt.string_literal": {
"name": "string_literal",
"resource_type": "macro",
"package_name": "dbt",
"path": "macros/utils/literal.sql",
"original_file_path": "macros/utils/literal.sql",
"unique_id": "macro.dbt.string_literal",
"macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n",
"depends_on": {
"macros": ["macro.dbt_project_evaluator.bigquery__string_literal"]
},
"description": "",
"meta": {},
"docs": { "show": true, "node_color": null },
"patch_path": null,
"arguments": [],
"created_at": 1714496011.2609057,
"supported_languages": null
},
"macro.dbt_project_evaluator.bigquery__string_literal": {
"name": "bigquery__string_literal",
"resource_type": "macro",
"package_name": "dbt_project_evaluator",
"path": "macros/wrap_string_with_quotes.sql",
"original_file_path": "macros/wrap_string_with_quotes.sql",
"unique_id": "macro.dbt_project_evaluator.bigquery__string_literal",
"macro_sql": "{% macro bigquery__string_literal(value) -%}\n '''{{ value }}'''\n{%- endmacro %}",
"depends_on": { "macros": [] },
"description": "",
"meta": {},
"docs": { "show": true, "node_color": null },
"patch_path": null,
"arguments": [],
"created_at": 1714496013.0822887,
"supported_languages": null
}, |
Describe the bug
In BigQuery, the new
base_<node/source>_columns
models fail with a syntax error when a multiline column description is present.Steps to reproduce
Take a single line description, and convert to a multiline description using block notation.
Expected results
I expected dbt project evaluator to run without issue.
Actual results
Instead, the new
base_<node/source>_columns
models failed with "Unclosed string literal" syntax errors.Screenshots and log output
Inspecting the failed BigQuery job shows that it is interpreting the multiline string as unclosed individual strings.
System information
The contents of your
packages.yml
file:Which database are you using dbt with?
The output of
dbt --version
:I don't have ready access to the CLI at the moment, but these are the versions listed at the start of a Cloud IDE invocation.
dbt=1.6.9, dbt-bigquery=1.6.9
Additional context
I think I've traced the issue to the active line in the
wrap_string_with_quotes
macro.It seems like you all are trying to move away from the macro in #419, but I don't know whether
dbt.string_literal
has a triple-quoting option to support multiline BigQuery strings.Are you interested in contributing the fix?
Yes! I've played around in #420, and have confirmed that it resolves the issue in our own project.
The text was updated successfully, but these errors were encountered: