Skip to content

Nested comments can transpile to invalid sql #5132

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

Open
patricksurry opened this issue May 28, 2025 · 1 comment
Open

Nested comments can transpile to invalid sql #5132

patricksurry opened this issue May 28, 2025 · 1 comment

Comments

@patricksurry
Copy link

I'm using python3 -m sqlglot --read bigquery --write bigquery - < foo.sql.

I've run into this issue a few times via sqlmesh format ... after commenting out a line using -- which contained a trailing comment (typically previously formatted by sqlmesh).

bigquery SQL doesn't seem to allow nested /* */ pairs so flags the second */ in the output as invalid.

Input (valid sql):

select
    id,
    foo,
    -- bar, /* the thing */
from facts

output (invalid sql):

SELECT
  `id`,
  `foo`
/* bar, /* the thing */ */
FROM `facts`
@georgesittas
Copy link
Collaborator

Interesting one, thanks. May be tricky to fix but we'll take a closer look here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants