Skip to content

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

Closed
@nicksrandall

Description

@nicksrandall

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions