Re: Converting an InternalRow to a Row

2017-01-07 Thread Andy Dang
Ah, I missed that bit of documentation my bad :). That totally explains the behavior! Thanks a lot! --- Regards, Andy On Sat, Jan 7, 2017 at 10:11 AM, Liang-Chi Hsieh wrote: > > Hi Andy, > > Thanks for sharing the code snippet. > > I am not sure if you miss something in the snippet, becau

Re: Converting an InternalRow to a Row

2017-01-07 Thread Liang-Chi Hsieh
Hi Andy, Thanks for sharing the code snippet. I am not sure if you miss something in the snippet, because some function signature are not matched, e.g., @Override public StructType bufferSchema() { return new UserDefineType(schema, unboundedEncoder); } Maybe you define a c

Re: Converting an InternalRow to a Row

2017-01-06 Thread Andy Dang
Hi Liang-Chi, The snippet of code is below. If I bind the encoder early (the schema doesn't change throughout the execution), the final result is a list of the same entries. @RequiredArgsConstructor public class UDAF extends UserDefinedAggregateFunction { // Do not resolve and bind this expr

Re: Converting an InternalRow to a Row

2017-01-05 Thread Liang-Chi Hsieh
Can you show how you use the encoder in your UDAF? Andy Dang wrote > One more question about the behavior of ExpressionEncoder > > . > > I have a UDAF that has ExpressionEncoder > > as a member variable. > > However, if call resolveAndBind() eagerly on this encoder, it appears to > break th

Re: Converting an InternalRow to a Row

2017-01-05 Thread Andy Dang
One more question about the behavior of ExpressionEncoder. I have a UDAF that has ExpressionEncoder as a member variable. However, if call resolveAndBind() eagerly on this encoder, it appears to break the UDAF. Bascially somehow the deserialized row are all the same during the merge step. Is it t

Re: Converting an InternalRow to a Row

2017-01-05 Thread Andy Dang
Perfect. The API in Java is bit clumsy though What I ended up doing in Java (the val is from lombok, if anyone's wondering): val attributes = JavaConversions.asJavaCollection(schema.toAttributes()).stream().map(Attribute::toAttribute).collect(Collectors.toList()); val encoder = Row

Re: Converting an InternalRow to a Row

2017-01-04 Thread Liang-Chi Hsieh
You need to resolve and bind the encoder. ExpressionEncoder enconder = RowEncoder.apply(struct).resolveAndBind(); Andy Dang wrote > Hi all, > (cc-ing dev since I've hit some developer API corner) > > What's the best way to convert an InternalRow to a Row if I've got an > InternalRow and the co