Skip to content

In correct serialization of DISTINCT ON() syntax with postgres #806

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

Closed
nicksrandall opened this issue Feb 9, 2023 · 2 comments · Fixed by #852
Closed

In correct serialization of DISTINCT ON() syntax with postgres #806

nicksrandall opened this issue Feb 9, 2023 · 2 comments · Fixed by #852

Comments

@nicksrandall
Copy link
Contributor

nicksrandall commented Feb 9, 2023

Here is the failing sql:

SELECT
   DISTINCT ON (column1) column_alias,
   column2
FROM
   table_name
ORDER BY
   column1,
   column2;

Note that this parses without errors because it parses the ON (column1) as a function.

When serializing back to string from ast, it produces:

SELECT DISTINCT ON(column1) AS column_alias, column2 FROM table_name ORDER BY column1, column2

The AS should not be there (it is an error in Postgres)

@AugustoFKL
Copy link
Contributor

@nicksrandall, thanks for the report! Are you planning to work on this, or can I do that?

@nicksrandall
Copy link
Contributor Author

@AugustoFKL go for it. I don't have bandwidth ATM.

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.

2 participants