presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/PrestoThriftBlock.java/PrestoThriftBlock/fromBlock
class PrestoThriftBlock:    public static PrestoThriftBlock fromBlock(Block block, Type type)
    {
        if (type instanceof IntegerType) {
            return PrestoThriftInteger.fromBlock(block);
        }
        if (type instanceof BigintType) {
            return PrestoThriftBigint.fromBlock(block);
        }
        if (type instanceof DoubleType) {
            return PrestoThriftDouble.fromBlock(block);
        }
        if (type instanceof VarcharType) {
            return PrestoThriftVarchar.fromBlock(block, type);
        }
        if (type instanceof BooleanType) {
            return PrestoThriftBoolean.fromBlock(block);
        }
        if (type instanceof DateType) {
            return PrestoThriftDate.fromBlock(block);
        }
        if (type instanceof TimestampType) {
            return PrestoThriftTimestamp.fromBlock(block);
        }
        if (type instanceof ArrayType) {
            Type elementType = getOnlyElement(type.getTypeParameters());
            if (BigintType.BIGINT.equals(elementType)) {
                return PrestoThriftBigintArray.fromBlock(block);
            }
            else {
                throw new IllegalArgumentException("Unsupported array block type: " + type);
            }
        }
        if (type.getBaseName().equals(JSON)) {
            return PrestoThriftJson.fromBlock(block, type);
        }
        if (type.getBaseName().equals(HYPER_LOG_LOG)) {
            return PrestoThriftHyperLogLog.fromBlock(block);
        }

        throw new IllegalArgumentException("Unsupported block type: " + type);
    }