```sql
create table dat (blockNum Decimal(10,0), eventTimestamp DateTime64(9) ) 
Engine=MergeTree() primary key eventTimestamp;
insert into dat values (1, '2022-01-24 02:30:00.008122000');

CREATE DICTIONARY datDictionary
(
    `blockNum` Decimal(10, 0),
    `eventTimestamp` DateTime64(9)
)
PRIMARY KEY blockNum
SOURCE(CLICKHOUSE(TABLE 'dat'))
LIFETIME(MIN 0 MAX 1000)
LAYOUT(FLAT());

select * from datDictionary;
┌─blockNum─┬────────────────eventTimestamp─┐
│        1 │ 2022-01-24 02:30:00.008122000 │
└──────────┴───────────────────────────────┘

select count(*) from dat where eventTimestamp >= (select eventTimestamp from datDictionary);

Exception on client:
Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from localhost:9000. (ATTEMPT_TO_READ_AFTER_EOF)

Connecting to localhost:9000 as user default.
Code: 210. DB::NetException: Connection refused (localhost:9000). (NETWORK_ERROR)
```

```sql
drop dictionary datDictionary;

CREATE DICTIONARY datDictionary
(
    `blockNum` Decimal(10, 0),
    `eventTimestamp` DateTime64(9)
)
PRIMARY KEY blockNum
SOURCE(CLICKHOUSE(TABLE 'dat'))
LIFETIME(MIN 0 MAX 1000)
LAYOUT(complex_key_hashed());

select count(*) from dat where eventTimestamp >= (select eventTimestamp from datDictionary);

Error on processing query: Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from localhost:9000. (ATTEMPT_TO_READ_AFTER_EOF) (version 22.7.1.1054)

Connecting to localhost:9000 as user default.
Code: 210. DB::NetException: Connection refused (localhost:9000). (NETWORK_ERROR)
```

```sql
select * from datDictionary;
┌─blockNum─┬────────────────eventTimestamp─┐
│        1 │ 2022-01-24 02:30:00.008122000 │
└──────────┴───────────────────────────────┘

select dictGet('datDictionary', 'eventTimestamp', tuple(cast('1','Decimal(10,0)')));
Code: 407. DB::Exception: Received from localhost:9000. DB::Exception: Bad scale of decimal field. (DECIMAL_OVERFLOW)
```

UInt32 min_precision = max_scale + leastDecimalPrecisionFor(max_int);
            
            if (max_scale == 0)
            {
                if (max_int == TypeIndex::Int32)
                    min_precision = DataTypeDecimal<Decimal32>::maxPrecision();
                else if (max_int == TypeIndex::Int64)
                    min_precision = DataTypeDecimal<Decimal64>::maxPrecision();
            }
            if (min_precision > DataTypeDecimal<Decimal128>::maxPrecision())
                return throwOrReturn<on_error>(types, "because the least supertype is Decimal("
                                + toString(min_precision) + ',' + toString(max_scale) + ')',
                                ErrorCodes::NO_COMMON_TYPE);
            if (have_decimal128 || min_precision > DataTypeDecimal<Decimal64>::maxPrecision())
                return std::make_shared<DataTypeDecimal<Decimal128>>(DataTypeDecimal<Decimal128>::maxPrecision(), max_scale);
            if (have_decimal64 || min_precision > DataTypeDecimal<Decimal32>::maxPrecision())
                return std::make_shared<DataTypeDecimal<Decimal64>>(DataTypeDecimal<Decimal64>::maxPrecision(), max_scale);
            return std::make_shared<DataTypeDecimal<Decimal32>>(DataTypeDecimal<Decimal32>::maxPrecision(), max_scale);
        }
    }
    
    {
        auto numeric_type = getNumericType<on_error>(type_ids);
        if (numeric_type)
            return numeric_type;
    }
    
    return throwOrReturn<on_error>(types, "", ErrorCodes::NO_COMMON_TYPE);
}
DataTypePtr getLeastSupertypeOrString(const DataTypes & types)