Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

String interpolation in BQ JS UDF not supported in SQLX

I need to create some SQL statements at execution time, not compilation, and have therefore turned to a BQ UDF in JS.
It took me some time to figure that Dataform engine is confusing interpolation used within my UDF with "it's own".
For example,

create temp function test(x string)
returns string language js as r"return `seems ${x} to me`";
select test('ok')
is perfectly valid and works as-is in BQ SQL workplace but not in a dataform SQLX as its templating uses the same ES6 notation. One would get x not defined as not exported by any js module.

Instead of reverting to verbose string concatenations - even if my AI friend can help me-, any idea/trick to go around this, e.g. using a special notation ? If not, could be a feature request.

1 3 790
3 REPLIES 3