feat(bigquery): support LOAD DATA INTO TEMP TABLE syntax#7675
Open
simonlourson wants to merge 1 commit into
Open
feat(bigquery): support LOAD DATA INTO TEMP TABLE syntax#7675simonlourson wants to merge 1 commit into
simonlourson wants to merge 1 commit into
Conversation
georgesittas
approved these changes
May 25, 2026
Collaborator
georgesittas
left a comment
There was a problem hiding this comment.
Thank you for the PR, I've a small ask but should be good to go otherwise.
Comment on lines
+714
to
+732
| def _parse_load_data(self) -> exp.LoadData | exp.Command: | ||
| if self._match_text_seq("DATA"): | ||
| overwrite = self._match(TokenType.OVERWRITE) | ||
| temp = False | ||
| if self._match(TokenType.INTO): | ||
| temp = self._match(TokenType.TEMPORARY) | ||
| self._match(TokenType.TABLE) | ||
|
|
||
| return self.expression( | ||
| exp.LoadData( | ||
| this=self._parse_table(schema=True), | ||
| overwrite=overwrite, | ||
| temp=temp, | ||
| files=self._match_text_seq("FROM", "FILES") | ||
| and exp.Properties(expressions=self._parse_wrapped_properties()), | ||
| ) | ||
| ) | ||
| return self._parse_as_command(self._prev) | ||
|
|
Collaborator
There was a problem hiding this comment.
Let's refactor Parser._parse_load instead of overriding it in BigQuery. The core logic is more or less the same.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for BigQuery's
LOAD DATA INTO TEMP TABLEsyntax, which was previously failing to parse because the base_parse_loadused_match_pair(INTO, TABLE)which requiresINTOto be immediately followed byTABLE, with no room for theTEMP/TEMPORARYkeyword inbetween.
Changes
sqlglot/expressions/dml.py: Added"temp": FalsetoLoadData.arg_typessqlglot/parsers/bigquery.py: Added a BigQuery-specific_parse_load_data()override that handles all three variants and registered itunder
TokenType.LOADinSTATEMENT_PARSERSsqlglot/generator.py: Updatedloaddata_sql()to emitINTO TEMP TABLEwhentemp=Truetests/dialects/test_bigquery.py: AddedLOAD DATA INTO TEMP TABLEto the existing round-trip testAll three BigQuery LOAD DATA variants are supported and round-trip correctly
Ref: https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/load-statements