You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@drill.apache.org by Manuel Aristaran <ma...@datawheel.us> on 2017/04/10 19:21:29 UTC

Complex types as @Workspace variables in UDFs

Hi,

After banging my head for a few hours trying to implement an array aggregation UDF (like Postgres’ array_agg()), I realized that there’s no way of keeping non-primitive values in the @Workspace of a UDF.

I posted a wish on JIRA [1], but thought I’d also ask here if there’s any workaround to this limitation.

Thanks,

[1] https://issues.apache.org/jira/browse/DRILL-5421

—
Manuel Aristarán <ma...@datawheel.us>
Datawheel LLC
Cambridge, MA




Re: Complex types as @Workspace variables in UDFs

Posted by Ted Dunning <te...@gmail.com>.
On Mon, Apr 10, 2017 at 3:53 PM, Jacques Nadeau <ja...@dremio.com> wrote:

> That is because I don't think
> aggregation functions can have complex outputs.
>

Yeah... banged into that hard in the past.

Aggregations *should* allow complex outputs.

Re: Complex types as @Workspace variables in UDFs

Posted by Jacques Nadeau <ja...@dremio.com>.
You can use an ObjectHolder to maintain a random pointer to anything in a
workspace variable. See an example here [1] (note that the reference
example is a template, not exactly a java file, you'll need to compile the
code to see the complete example). However, I don't think that [1] alone
will allow you to achieve what you want. That is because I don't think
aggregation functions can have complex outputs. (This is from historical
memory from long ago so I could be wrong about this. Maybe Jinfeng could
say for sure.)


[1]
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/codegen/templates/VarCharAggrFunctions1.java#L63

--
Jacques Nadeau
CTO and Co-Founder, Dremio

On Mon, Apr 10, 2017 at 12:21 PM, Manuel Aristaran <ma...@datawheel.us>
wrote:

> Hi,
>
> After banging my head for a few hours trying to implement an array
> aggregation UDF (like Postgres’ array_agg()), I realized that there’s no
> way of keeping non-primitive values in the @Workspace of a UDF.
>
> I posted a wish on JIRA [1], but thought I’d also ask here if there’s any
> workaround to this limitation.
>
> Thanks,
>
> [1] https://issues.apache.org/jira/browse/DRILL-5421
>
> —
> Manuel Aristarán <ma...@datawheel.us>
> Datawheel LLC
> Cambridge, MA
>
>
>
>