public static Map<Class<?>, Integer> buildVariantMapping(List<ClickHouseDataType> variantDataTypes) {
        Map<Class<?>, Integer> variantMapping = new HashMap<>();

        TreeMap<ClickHouseDataType, Integer> intTypesMappings = new TreeMap<>(Comparator.comparingInt(ORDERED_BY_RANGE_INT_TYPES::indexOf));
        TreeMap<ClickHouseDataType, Integer> decTypesMappings = new TreeMap<>(Comparator.comparingInt(ORDERED_BY_RANGE_DECIMAL_TYPES::indexOf));

        for (int ordNum = 0; ordNum < variantDataTypes.size(); ordNum++) {
            ClickHouseDataType dataType = variantDataTypes.get(ordNum);
            Set<Class<?>> classSet = DATA_TYPE_TO_CLASS.get(dataType);

            final int finalOrdNum = ordNum;
            if (classSet != null) {
                if (ORDERED_BY_RANGE_INT_TYPES.contains(dataType)) {
                    intTypesMappings.put(dataType, ordNum);
                } else if (ORDERED_BY_RANGE_DECIMAL_TYPES.contains(dataType)) {
                    decTypesMappings.put(dataType, ordNum);
                } else {
                    classSet.forEach(c -> variantMapping.put(c, finalOrdNum));
                }
            }
        }

        // add integers
        for (java.util.Map.Entry<ClickHouseDataType, Integer> entry : intTypesMappings.entrySet()) {
            DATA_TYPE_TO_CLASS.get(entry.getKey()).forEach(c -> variantMapping.put(c, entry.getValue()));
        }
        // add decimals
        for (java.util.Map.Entry<ClickHouseDataType, Integer> entry : decTypesMappings.entrySet()) {
            DATA_TYPE_TO_CLASS.get(entry.getKey()).forEach(c -> variantMapping.put(c, entry.getValue()));
        }

        return variantMapping;
    }
Basic ClickHouse data types.

<p>
This list is based on the list of data type families returned by
{@code SELECT * FROM system.data_type_families}

<p>
{@code LowCardinality} and {@code Nullable} are technically data types in
ClickHouse, but for the sake of this driver, we treat these data types as
modifiers for the underlying base data types.
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java