madlib-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From njayaram2 <...@git.apache.org>
Subject [GitHub] incubator-madlib pull request #116: Unnest 2d array
Date Tue, 18 Apr 2017 19:14:03 GMT
Github user njayaram2 commented on a diff in the pull request:

    https://github.com/apache/incubator-madlib/pull/116#discussion_r112038736
  
    --- Diff: methods/array_ops/src/pg_gp/array_ops.sql_in ---
    @@ -636,3 +663,30 @@ CREATE OR REPLACE FUNCTION MADLIB_SCHEMA.array_cum_prod(x anyarray)
RETURNS anya
     AS 'MODULE_PATHNAME', 'array_cum_prod'
     LANGUAGE C IMMUTABLE
     m4_ifdef(`__HAS_FUNCTION_PROPERTIES__', `NO SQL', `');
    +
    +/**
    + * @brief This function takes a 2-D array as the input and unnests it
    + *        by one level.
    + *        It returns a set of 1-D arrays that correspond to rows of
    + *        the input array as well as an ID column with values corresponding
    + *        to positions occupied by the 1-D arrays within the 2-D array.
    + *
    + * @param x Array x
    + * @returns Set of 1-D arrays that corrspond to rows of x and an ID column.
    + *
    + */
    +CREATE OR REPLACE FUNCTION MADLIB_SCHEMA.array_unnest_2d_to_1d(x ANYARRAY, OUT unnest_2d_to_1d_id
BIGINT, OUT unnest_2d_to_1d_result ANYARRAY)
    +RETURNS SETOF RECORD
    +AS
    +$BODY$
    +  SELECT t2.r::bigint, array_agg($1[t2.r][t2.c] order by t2.c) FROM
    +  (
    +    SELECT generate_series(array_lower($1,2),array_upper($1,2)) as c, t1.r
    +    FROM
    +    (
    +      SELECT generate_series(array_lower($1,1),array_upper($1,1)) as r
    +    ) t1
    +  ) t2
    +GROUP BY t2.r
    +$BODY$
    +LANGUAGE sql IMMUTABLE;
    --- End diff --
    
    Having online docs with usage/example for this function would be helpful. We can have
something similar to what is present in `.../incubator-madlib/methods/stemmer/src/pg_gp/porter_stemmer.sql_in`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message