Given the following config:
config {
type: 'table',
assertions: {
rowConditions: [
`validCheck`,
`
invalidCheck
`,
]
}
}
Dataform compiles assertions into:
SELECT
'validCheck' AS failing_row_condition,
*
FROM `project.dataset.test`
WHERE NOT (validCheck)
UNION ALL
SELECT
'
invalidCheck
' AS failing_row_condition,
*
FROM `project.dataset.test`
WHERE NOT (
invalidCheck
)
The generated SQL is invalid because BigQuery single-quoted string literals cannot span multiple lines. As a result, any multiline rowConditions entry causes a syntax error during execution.
While this is a somewhat synthetic example, more complex expressions can be easier to read and maintain when formatted across multiple lines.
As a workaround, I currently normalize whitespace before passing the condition:
config {
type: 'table',
assertions: {
rowConditions: [
`validCheck`,
`
invalidCheck
`.replace(/\s+/g, " "),
]
}
}
Possible solutions:
- Generate triple-quoted string literals
SELECT
'''
invalidCheck
''' AS failing_row_condition
- Escape or normalize newlines before embedding
SELECT
'\n invalidCheck\n ' AS failing_row_condition
Given the following config:
Dataform compiles assertions into:
The generated SQL is invalid because BigQuery single-quoted string literals cannot span multiple lines. As a result, any multiline rowConditions entry causes a syntax error during execution.
While this is a somewhat synthetic example, more complex expressions can be easier to read and maintain when formatted across multiple lines.
As a workaround, I currently normalize whitespace before passing the condition:
Possible solutions: