Skip to content

ORDER BY inside subqueries with PROJECT doesn't sort correctly #23

@renecannao

Description

@renecannao

SELECT (SELECT age FROM users ORDER BY age DESC LIMIT 1) does not sort correctly because ORDER BY on projected columns (non-star selects) is a pre-existing limitation. The sort key cannot be resolved after the PROJECT rewrites columns.

The sort operator evaluates key expressions against the row, but after PROJECT the column ordinals may not match the original table layout.

Fix: ensure sort keys are evaluated before projection, or pass through original column ordinals.

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