TobikoData / sqlmesh

Efficient data transformation and modeling framework that is backwards compatible with dbt.

Home Page:https://sqlmesh.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Backslahes in comments should be escaped

plaflamme opened this issue · comments

I had a model like this:

/* This is the comment with a \ in it */
MODEL(
  name foo.bar
);
SELECT * FROM baz

Results in the following error in BigQuery:

google.api_core.exceptions.BadRequest: 400 Syntax error: Illegal escape sequence: \  at [1:2231]; reason: invalidQuery, location: query, message: Syntax error: Illegal escape sequence: \  at [1:2231]

What happens if you add your own escape?

It works: it results in a \ in the BigQuery description of the table.

Though I think my point is that such a comment is perfectly fine in BigQuery. I believe that the reason it breaks is because the comment has to be transported through the API which requires escaping some characters.

For example, it's already escaping single quotes:

`my_column` STRING OPTIONS (description='The column\'s description')

So presumably, it should also be escaping backslashes...