[ https://issues.apache.org/jira/browse/PHOENIX-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14660551#comment-14660551 ]
James Taylor commented on PHOENIX-953: -------------------------------------- I think what we need for UNNEST is an iterator that returns one row per array element. Your patch for PHOENIX-2164 seems like it's geared more toward one row per element in a VALUES clause (which is useful too, but not sure it solves this problem). For example, SELECT UNNEST(my_array) would return one row per element of the evaluated my_array array reference. So for UNNEST of an array, it'd be an iterator that mimics this, where arrayExpr is an expression that evaluates to an array and ptr is an ImmutableBytesWritable that is pointing the evaluation of the expression: {code} int numElementsInArray = getArrayLength(ptr, PDataType.arrayBaseType(arrayExpr.getDataType()), arrayExpr.getMaxLength()); for (int i = 0; i < numElementsInArray; i++) { PArrayDataType.positionAtArrayElement(ptr, i, PDataType.arrayBaseType(arrayExpr.getDataType()), arrayExpr.getMaxLength()); } {code} > Support UNNEST for ARRAY > ------------------------ > > Key: PHOENIX-953 > URL: https://issues.apache.org/jira/browse/PHOENIX-953 > Project: Phoenix > Issue Type: Sub-task > Reporter: James Taylor > Assignee: Dumindu Buddhika > > The UNNEST built-in function converts an array into a set of rows. This is > more than a built-in function, so should be considered an advanced project. > For an example, see the following Postgres documentation: > http://www.postgresql.org/docs/8.4/static/functions-array.html > http://www.anicehumble.com/2011/07/postgresql-unnest-function-do-many.html > http://tech.valgog.com/2010/05/merging-and-manipulating-arrays-in.html > So the UNNEST is a way of converting an array to a flattened "table" which > can then be filtered on, ordered, grouped, etc. -- This message was sent by Atlassian JIRA (v6.3.4#6332)