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

Fix: ensure pivot can be used as a table name #1734

Merged
merged 1 commit into from
Jun 6, 2023
Merged

Conversation

georgesittas
Copy link
Collaborator

No description provided.

@@ -1912,8 +1912,16 @@ def _parse_select(

this = self._parse_query_modifiers(this)
elif (table or nested) and self._match(TokenType.L_PAREN):
this = self._parse_table() if table else self._parse_select(nested=True)
this = self._parse_set_operations(self._parse_query_modifiers(this))
if self._match(TokenType.PIVOT):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about select * from (pivot)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a syntax error in both postgres and bigquery

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

georgesittas=# with pivot as (select 1) select * from (pivot);
ERROR:  syntax error at or near ")"
LINE 1: with pivot as (select 1) select * from (pivot);
                                                     ^
Screenshot 2023-06-07 at 12 59 39 AM

@tobymao tobymao merged commit e058513 into main Jun 6, 2023
@tobymao tobymao deleted the jo/pivot_fixup branch June 6, 2023 22:02
adrianisk pushed a commit to adrianisk/sqlglot that referenced this pull request Jun 21, 2023
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 this pull request may close these issues.

2 participants