Describe what's wrong
Order by used on a distributed table with an alias seems to shuffle the columns.
Does it reproduce on the most recent release?
Yes - v25.7.2
How to reproduce
Table setup
CREATE TABLE shard_Test ON CLUSTER `{cluster}`
(
`a` String,
`b` Float64,
`c` Float64,
`d` Float64,
`e` Float64 ALIAS b + c,
`f` Float64 ALIAS c + d
)
ENGINE = MergeTree
ORDER BY a;
CREATE TABLE Test ON CLUSTER `{cluster}`
(
`a` String,
`b` Float64,
`c` Float64,
`d` Float64,
`e` Float64 ALIAS b + c,
`f` Float64 ALIAS c + d
)
ENGINE = Distributed('{cluster}', 'default', 'shard_Test', rand());
INSERT INTO Test VALUES('a', 1,2,3);
Simple query
SELECT
e,
f
FROM Test
┌─e─┬─f─┐
1. │ 3 │ 5 │
└───┴───┘
Query with order by
SELECT
e,
f
FROM Test
ORDER BY a ASC
┌─e─┬─f─┐
1. │ 5 │ 3 │
└───┴───┘
Expected behavior
Both queries should return the sames results
Additional context
probably linked to #85895
Describe what's wrong
Order by used on a distributed table with an alias seems to shuffle the columns.
Does it reproduce on the most recent release?
Yes - v25.7.2
How to reproduce
Table setup
Simple query
Query with order by
Expected behavior
Both queries should return the sames results
Additional context
probably linked to #85895