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(redshift): handle VALUES clause more robustly #1654

Merged
merged 1 commit into from
May 18, 2023

Conversation

georgesittas
Copy link
Collaborator

cc: @eakmanrq

@@ -181,6 +181,16 @@ def test_identity(self):
)

def test_values(self):
self.validate_all(
"SELECT * FROM (VALUES (1, 2)) AS t",
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 would previously cause an error if we were to transpile it to redshift:

    for value, column_name in zip(row, expression.args["alias"].args["columns"])
TypeError: 'NoneType' object is not iterable

write={"redshift": "SELECT * FROM (SELECT 1, 2) AS t"},
)
self.validate_all(
"SELECT * FROM (VALUES (1)) AS t1(id) CROSS JOIN (VALUES (1)) AS t2(id)",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably a rare use case of VALUES, but thought I'd include it anyway. We weren't removing the second VALUES clause because only exp.From was checked as a possible parent.

@tobymao tobymao merged commit 3f2f4df into main May 18, 2023
@tobymao tobymao deleted the jo/redshift_values_fixups branch May 18, 2023 20:27
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