```
select version();
┌─version()───┐
│ 22.5.1.2079 │
└─────────────┘

CREATE TABLE order
(
    `ID` String,
    `Type` Enum8('TYPE_0' = 0, 'TYPE_1' = 1, 'TYPE_2' = 2),
    `Num` UInt64,
    `Data` String,
    `RowCreatedAt` DateTime DEFAULT now()
)
ENGINE = ReplacingMergeTree()
PARTITION BY toYYYYMMDD(RowCreatedAt)
PRIMARY KEY ID
ORDER BY (ID, Type, Num)
TTL RowCreatedAt + toIntervalWeek(6)
SETTINGS index_granularity = 8192;

insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;
insert into order (ID, Type, Num, Data, RowCreatedAt) select toString(cityHash64(ID)%2000), case cityHash64(ID)%3 when 0 then 'TYPE_0' when 1 then 'TYPE_1' when 2 then 'TYPE_2' ELSE 'TYPE_0' END, cityHash64(ID), ID, toDateTime(toUInt32(now()) - round(rand32() / 4294967295 * 4100000, 0))  from generateRandom('ID String ', 1, 1000) limit 100000;

select count(*) from order;
┌─count()─┐
│  892441 │
└─────────┘

set optimize_move_to_prewhere = 0;
SELECT Data
FROM order
WHERE (ID = '1') AND (Type = 'TYPE_1')
ORDER BY Num ASC
FORMAT `Null`

Ok.

set optimize_move_to_prewhere = 1;
SELECT Data
FROM order
WHERE (ID = '1') AND (Type = 'TYPE_1')
ORDER BY Num ASC
FORMAT `Null`

Received exception from server (version 22.5.1):
Code: 10. DB::Exception: Received from localhost:9000. DB::Exception: Not found column Type in block. There are only columns: ID, Num, equals(Type, 'TYPE_1'), Data. (NOT_FOUND_COLUMN_IN_BLOCK)

```
{
    auto columns = select_query->select()->children;
    const auto * expr_with_alias = dynamic_cast<const ASTWithAlias *>(argument.get());
    if (expr_with_alias && !expr_with_alias->alias.empty())
        return false;
    const auto * ast_literal = typeid_cast<const ASTLiteral *>(argument.get());
    if (!ast_literal)
        return false;
    auto which = ast_literal->value.getType();
    if (which != Field::Types::UInt64)
        return false;
    auto pos = ast_literal->value.get<UInt64>();
    if (!pos || pos > columns.size())
        throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
                "Positional argument out of bounds: {} (exprected in range [1, {}]",
                        pos, columns.size());
    const auto & column = columns[--pos];
    if (typeid_cast<const ASTIdentifier *>(column.get()) || typeid_cast<const ASTLiteral *>(column.get()))
    {
        argument = column->clone();
    }
    else if (typeid_cast<const ASTFunction *>(column.get()))
    {
        std::function<void(ASTPtr)> throw_if_aggregate_function = [&](ASTPtr node)
        {
            if (const auto * function = typeid_cast<const ASTFunction *>(node.get()))
            {