presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/PostgreSqlClient.java/PostgreSqlClient/arrayAsJsonReadFunction
class PostgreSqlClient:    private SliceReadFunction arrayAsJsonReadFunction(ConnectorSession session, ColumnMapping baseElementMapping)
    {
        return (resultSet, columnIndex) -> {
            // resolve array type
            Object jdbcArray = resultSet.getArray(columnIndex).getArray();
            int arrayDimensions = arrayDepth(jdbcArray);

            ReadFunction readFunction = baseElementMapping.getReadFunction();
            Type type = baseElementMapping.getType();
            for (int i = 0; i < arrayDimensions; i++) {
                readFunction = arrayReadFunction(type, readFunction);
                type = new ArrayType(type);
            }

            // read array into a block
            Block block = ((BlockReadFunction) readFunction).readBlock(resultSet, columnIndex);

            // cast block to JSON slice
            try {
                return (Slice) typeManager.getCoercion(type, jsonType)
                        .invokeExact(session, block);
            }
            catch (Throwable throwable) {
                throw new PrestoException(JDBC_ERROR, "Cast to JSON failed: " + throwable.getMessage(), throwable);
            }
        };
    }