```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)
Field sharding_column_value,
    const std::string & sharding_column_name,
    const OptimizeShardingKeyRewriteInMatcher::Data & data)
{
    UInt64 field_value;
    
    if (!sharding_column_value.tryGet<UInt64>(field_value))
        sharding_column_value = convertFieldToType(sharding_column_value, *data.sharding_key_type);
    
    
    if (sharding_column_value.isNull())
        return false;
    Field sharding_value = executeFunctionOnField(
        sharding_column_value, sharding_column_name,
        data.sharding_key_expr, data.sharding_key_type,
        data.sharding_key_column_name);
    
    
    sharding_value = convertFieldToType(sharding_value, DataTypeUInt64());
    
    if (sharding_value.isNull())
        return false;
    UInt64 value = sharding_value.get<UInt64>();
    const auto shard_num = data.slots[value % data.slots.size()] + 1;
    return data.shard_info.shard_num == shard_num;
}
}
namespace DB
{
bool OptimizeShardingKeyRewriteInMatcher::needChildVisit(ASTPtr & , const ASTPtr & )