Scalding: Column Reordering In a Write Statement

125 views
Skip to first unread message

Brian Arnold

unread,
May 23, 2013, 11:13:20 AM5/23/13
to cascadi...@googlegroups.com
Hi,

I am currently running into an issue where after i perform the following chained groupBy statement below, I cannot change the ordering of the fields in the write statement.  

....
.groupBy(('id,'week,'year)) {
    g => g.sum('soldQuantity -> 'aggrQuantity)
             .average('soldQuantity -> 'avgQuantity)          
....

.write(Csv(args('output), ",", fields = ('id, 'week, 'year, 'avgQuantity, 'aggrQuantity), quote = StringUtils.EMPTY))


In my chained groupBy statement I perform the sum first and the average second, but in my output I want to have the average first and the sum second.  I know that I can just change the order in which I am doing my groupBy statement, but it seems like if I am specifying the fields in a particular order in my write stement, it should output the fields in that order regardless of the order in which I actually performed them in previous statements. Will changing the order of the fields in the write statement not actually order them in that way in the output?

Thanks!
Brian

Oscar Boykin

unread,
May 23, 2013, 5:39:23 PM5/23/13
to cascadi...@googlegroups.com
use project to change the order:

.groupBy {
  
}
.project('avgQuantity, 'aggrQuantity)

That's the best way, I think.


Brian

--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascading-use...@googlegroups.com.
To post to this group, send email to cascadi...@googlegroups.com.
Visit this group at http://groups.google.com/group/cascading-user?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Oscar Boykin :: @posco :: http://twitter.com/posco
Reply all
Reply to author
Forward
0 new messages