that's flatMap.

val rows: TypedPipe[(PageId, List[AdId])] = ...
rows.flatMap { case (page, ads) =>
  val pageIdPairs: List[(PageId, AdId)] = ads.map { ad => (page, ad) }
  pageIdPairs
}

or more succinctly:

rows.flatMap { case (page, ads) => ads.map((page, _)) }

the name comes map + flatten, so you first do a map, then you flatten
(remove one layer of nesting).

Does that make sense?


On Tue, Aug 20, 2019 at 1:01 PM Jing Lu <[email protected]> wrote:

> Hi Oscar,
>
> Thanks for helping.
>
> For example, if I have a table like this:
>
> pageid
>
> adid_list
>
> contact_page
>
> [3, 4, 5]
>
> front_page
>
> [1, 2, 3]
>
> I want to create another table like this:
>
> pageid (string)
>
> adid (int)
>
> "front_page"
>
> 1
>
> "front_page"
>
> 2
>
> "front_page"
>
> 3
>
> "contact_page"
>
> 3
>
> "contact_page"
>
> 4
>
> "contact_page"
>
> 5
>
>
> Thanks,
> Jing
>
>
>
>
> On Tue, Aug 20, 2019 at 3:41 PM Oscar Boykin <[email protected]> wrote:
>
>> I don't really know lateral view explode, but from what I can read it
>> looks like flatMap + joining/aggregation. Do you want to give an example of
>> the problem you have in mind and we can give a more concrete answer?
>>
>> On Tue, Aug 20, 2019 at 12:30 PM Jing Lu <[email protected]> wrote:
>>
>>> Dear Scalding community,
>>>
>>> In HIVE, "LATERAL VIEW EXPLODE" is frequently used if the value is a
>>> list. Is there any way in Scalding, we can do something similar?
>>>
>>>
>>> Thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Scalding Development" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/scalding-dev/e8c7bff9-1257-452c-8ced-353643cd7727%40googlegroups.com
>>> <https://groups.google.com/d/msgid/scalding-dev/e8c7bff9-1257-452c-8ced-353643cd7727%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Scalding Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scalding-dev/CAJVaavFMS7RuGfKvFC0f%2B0Fmr9fXjdDG13O-JLhZBPFRL7FWJQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/scalding-dev/CAJVaavFMS7RuGfKvFC0f%2B0Fmr9fXjdDG13O-JLhZBPFRL7FWJQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Scalding Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/scalding-dev/CALgODVVP0xYNPcyJHGGpapJNmy6shsu20kiOSMNDeJQbcEpChw%40mail.gmail.com.

Reply via email to