Another option would be to allow a udf to return many top level fields. In some sense, this is what flatten should have done in the first place.
The use of star is intriguing, but there is an inherent problem, logically speaking since in normal queries * can be replaced for a list of fields. In this usage, it hard to understand how that might be. It would be unpleasant if I could extract all fields or one field but not two. Would you consider a syntax like this? select t.b.(x,y) from t Sent from my iPhone > On Oct 3, 2015, at 16:51, andrew <[email protected]> wrote: > > Hey Jacques, > > The first option feels more natural to me, but I’m not sure I understand your > point regarding how an alias would render it meaningless. Could you explain > that? > > Thanks, > A > >> On Oct 3, 2015, at 8:54 AM, Jacques Nadeau <[email protected]> wrote: >> >> Hey All, >> >> One of the use cases that we're trying to solve in Drill is unrolling an >> inner map. This is used frequently since various types of outputs from UDFs >> are maps. Imagine a situation where records are effectively: >> >> { >> id: 123, >> b: { >> x:10, >> y:20 >> } >> } >> >> We want to the output of the operation to be >> >> { >> id: 123, >> x: 10, >> y:20 >> } >> >> This is frequently useful if you want to present data to a bi tool. The >> question is, what is the right way to express this concept in SQL? The two >> ideas I have are: >> >> select t.id, t.b.* from t; >> >> OR >> >> select t.id, t.b as * from t >> >> The first seems to fit well with the existing pattern around * from SQL. >> However, we would need to validate that there was no use of an alias since >> that would be meaningless in this context. Thinking about that led me to >> the second idea. >> >> Any other thoughts/proposals? What do other people think? >
