```sql
CREATE TABLE local_test_int32 ( id String, id_hash Int32) ENGINE = MergeTree ORDER BY (id_hash, id);

create table test_int32  as local_test_int32 
ENGINE = Distributed('test_cluster_two_shards' , currentDatabase(), local_test_int32, id_hash);

SELECT count() 
FROM  test_int32
PREWHERE id_hash IN ( -2146278902,-2147452843)
SETTINGS  optimize_skip_unused_shards = 1;

Received exception from server (version 22.2.2):
Code: 92. DB::Exception: Received from localhost:9000. 
DB::Exception: Cannot infer type of an empty tuple: While processing tuple(). (EMPTY_DATA_PASSED)
```

@azat 


```sql
select arrayJoin([-2146278902,-2147452843]) % 2;
┌─modulo(arrayJoin([-2146278902, -2147452843]), 2)─┐
│                                                0 │
│                                               -1 │
└──────────────────────────────────────────────────┘
```

```sql
-- but it's OK if ids are positive

SELECT arrayJoin([2146278902, 2147452843]) % 2
┌─modulo(arrayJoin([2146278902, 2147452843]), 2)─┐
│                                              0 │
│                                              1 │
└────────────────────────────────────────────────┘

SELECT count() 
FROM  test_int32
PREWHERE id_hash IN ( 2146278902,2147452843)
SETTINGS  optimize_skip_unused_shards = 1;

0 rows in set. Elapsed: 0.004 sec.



-- and it's OK if ids are negative and shard is the same

SELECT arrayJoin([-2146278903, -2147452843]) % 2
┌─modulo(arrayJoin([-2146278903, -2147452843]), 2)─┐
│                                               -1 │
│                                               -1 │
└──────────────────────────────────────────────────┘

SELECT count() 
FROM  test_int32
PREWHERE id_hash IN ( -2146278903, -2147452843)

0 rows in set. Elapsed: 0.004 sec.

```

No issue with earlier versions (for example 20.8.17.25)
#include <Interpreters/ExpressionActions.h>
#include <Interpreters/convertFieldToType.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTLiteral.h>
#include <Parsers/ASTIdentifier.h>
#include <DataTypes/DataTypesNumber.h>
#include <Interpreters/OptimizeShardingKeyRewriteInVisitor.h>
namespace
{
using namespace DB;
Field executeFunctionOnField(
    const Field & field,
    const std::string & name,
    const ExpressionActionsPtr & sharding_expr,
    const DataTypePtr & type,
    const std::string & sharding_key_column_name)
{
    ColumnWithTypeAndName column;
    column.column = type->createColumnConst(1, field);
    column.name = name;
    column.type = type;
    Block block{column};
    size_t num_rows = 1;
    sharding_expr->execute(block, num_rows);
    ColumnWithTypeAndName & ret = block.getByName(sharding_key_column_name);
    return (*ret.column)[0];
}
bool shardContains(