Skip to content
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

Bigquery parse unexpected token found (= ) in elseif clause #3009

Closed
razvan-am opened this issue Feb 22, 2024 · 0 comments · Fixed by #3011
Closed

Bigquery parse unexpected token found (= ) in elseif clause #3009

razvan-am opened this issue Feb 22, 2024 · 0 comments · Fixed by #3011

Comments

@razvan-am
Copy link

Code:

import sqlglot

my_str = """BEGIN

DECLARE MY_VAR INT64 DEFAULT 1;

SET MY_VAR = (SELECT 0);

IF MY_VAR = 1 THEN
    SELECT 'TRUE';
ELSEIF MY_VAR = 0 THEN
    SELECT 'FALSE';
ELSE
    SELECT 'NULL';
END IF;
END
"""

parsed_objects = sqlglot.parse(my_str, dialect='bigquery')

print(parsed_objects)

error:

sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 9, Col: 15.
  VAR INT64 DEFAULT 1;

SET MY_VAR = (SELECT 0);

IF MY_VAR = 1 THEN
    SELECT 'TRUE';
ELSEIF MY_VAR = 0 THEN
    SELECT 'FALSE';
ELSE
    SELECT 'NULL';
END IF;
END

= is underlined

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

Successfully merging a pull request may close this issue.

1 participant