-
Notifications
You must be signed in to change notification settings - Fork 764
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
feat(bigquery): add EXPORT DATA statement support #4688
feat(bigquery): add EXPORT DATA statement support #4688
Conversation
Hey @ArnoldHueteG, thank you for your contribution! Could you please run |
5e34015
to
05fc102
Compare
ID_VAR_TOKENS = { | ||
*parser.Parser.ID_VAR_TOKENS, | ||
TokenType.EXPORT, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this token in the base class' set instead of copying it here.
parts = [] | ||
while True: | ||
part = self._parse_var() | ||
if not part: | ||
break | ||
parts.append(part.name) | ||
if not self._match(TokenType.DOT): | ||
break | ||
|
||
if not parts: | ||
self.raise_error("Expected connection name after WITH CONNECTION") | ||
|
||
with_connection = exp.Identifier(this=".".join(parts)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not parse the connection name manually here, consider using _parse_table_parts
instead.
if self._match_text_seq("OPTIONS"): | ||
self._match(TokenType.L_PAREN) | ||
options = self._parse_properties() | ||
self._match(TokenType.R_PAREN) | ||
else: | ||
self.raise_error("Expected 'OPTIONS' after 'EXPORT DATA'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to clean this up using the OPTIONS
property parser.
else: | ||
self.raise_error("Expected 'OPTIONS' after 'EXPORT DATA'") | ||
|
||
self._match_text_seq("AS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._match_text_seq("AS") | |
self._match(TokenType.ALIAS) |
# Parse the full SELECT statement | ||
query = self._parse_statement() | ||
if not isinstance(query, exp.Select): | ||
self.raise_error("Expected SELECT statement in EXPORT DATA") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to do error handling like this, SQLGlot is intentionally lenient in these cases.
Hey @ArnoldHueteG, thank you for the contribution & iterations, I have some bandwidth available so I'll drive this to the finish line. |
Add support for BigQuery's EXPORT DATA statement including: