Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnest 2d array #116

Closed
wants to merge 7 commits into from
Closed

Unnest 2d array #116

wants to merge 7 commits into from

Conversation

rashmi815
Copy link

Array Operations: Add function to unnest 2-D arrays into rows of 1-D arrays

JIRA: MADLIB-1086

Function to unnest 2-D array by one level (i.e. into rows of 1-D arrays).
This is needed, for instance, in K-means, so that we can get one centroid per row for follow on operations.

  • Added function to array operations
  • Added an example in k-means to demonstrate usage

@asfbot
Copy link

asfbot commented Apr 18, 2017

Can one of the admins verify this patch?

*
*/
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to have at most 80 chars in a line wherever possible, based on MADlib's coding convention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "unnest_2d_to_1d_id" can be an INTEGER, we won't have indices bigger than that.
Also maybe call it just "id" or "row_id/row_num"?

) t2
GROUP BY t2.r
$BODY$
LANGUAGE sql IMMUTABLE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@iyerr3
Copy link
Contributor

iyerr3 commented Apr 20, 2017

Jenkins, OK to test.

@asfbot
Copy link

asfbot commented Apr 20, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/41/

@asfbot
Copy link

asfbot commented Apr 20, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/madlib-pr-build/44/

@rashmi815 rashmi815 closed this Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants