Skip to content

Support ORDER BY ALL Syntax in StarRocks #65873

@LiShuMing

Description

@LiShuMing

Background & Motivation

Modern analytical engines increasingly provide simplified ordering syntax to improve developer ergonomics and reduce boilerplate in SQL tests.

This shorthand tells the engine to sort by all projected columns in the SELECT list, in column order, without requiring users to explicitly list each column.

For StarRocks, supporting ORDER BY ALL would bring two key benefits:

  • Cleaner and more maintainable SQL tests
    • Regression tests often require deterministic result ordering. When the SELECT list is long—or generated programmatically—writing and updating a full ORDER BY col1, col2, ... clause is error-prone.
    • ORDER BY ALL would ensure deterministic ordering using a simple, stable syntax.
  • Improved compatibility and developer experience
    Aligning with ClickHouse and Snowflake enhances cross-engine portability and lowers friction for developers writing portable benchmark/test SQL.

Proposed Behavior

ORDER BY ALL should be interpreted as: Sort the output using all columns in the SELECT list, in the same sequence as they appear in the select clause, defaulting to ascending order for each column.

Example:

SELECT a, b, c
FROM t
ORDER BY ALL;

Equivalent to:

SELECT a, b, c
FROM t
ORDER BY a, b, c;

Use Cases

  • Regression tests requiring stable deterministic ordering
  • Auto-generated SQL queries
  • Workflows comparing results across multiple warehouses/OLAP engines

Further

Should ORDER BY ALL respect aliases and expressions exactly as listed?

  • Interaction with: ORDER BY 1, 2
  • Window functions
  • SELECT * (Should ORDER BY ALL expand *?)
  • Backward compatibility and error handling

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementMake an enhancement to StarRocks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions