Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed some outdated links and added descriptions

...

Lateral view is used in conjunction with user-defined table generating functions such as explode(). As mentioned in LanguageManual UDF#UDTF Built-in Table-Generating Functions, a UDTF generates one or more output rows for each input row. A lateral view first applies the UDTF to each row of base table and then joins resulting output rows to the input rows to form a virtual table having the supplied table alias.

...

string pageid

Array<int> adid_list

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6f433195ff7937a5-de752f8e-40f1419a-872e91b4-92875199bb33cb4a637428ce"><ac:plain-text-body><![CDATA[

"front_page"

[1, 2, 3]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d2e34999be20d8c8-1813e973-44474815-baae8b34-13396ca4d2109c495e25a9a1"><ac:plain-text-body><![CDATA[

"contact_page"

[3, 4, 5]

]]></ac:plain-text-body></ac:structured-macro>

and the user would like to count the total number of times an ad appears across all pages.

A lateral view with explode() LanguageManual UDF#explode can be used to convert adid_list into separate rows using the query:

...

Array<int> col1

Array<string> col2

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c277106d36fd2fa3-74f46c97-4f444d2b-b6cea80b-ab49d16a443896a679600104"><ac:plain-text-body><![CDATA[

[1, 2]

[a", "b", "c"]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6c57ad3f9ef4fcd1-389e66fd-47204b70-99f48713-2b073c32daa85025d8bc05f3"><ac:plain-text-body><![CDATA[

[3, 4]

[d", "e", "f"]

]]></ac:plain-text-body></ac:structured-macro>

...

int mycol1

Array<string> col2

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d87f43a240dfecc6-453c09c2-4ad14159-85a3a388-eaf4c8ee917d5cb2c0765e8c"><ac:plain-text-body><![CDATA[

1

[a", "b", "c"]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="17e2a4cded140181-a2f05ea6-42154270-9c69bdf1-398e283e07d4bd989029d115"><ac:plain-text-body><![CDATA[

2

[a", "b", "c"]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d6b445eac99a9576-4f9fbd96-4e964bbb-b1edbab1-c6341476b563a95aa1b48966"><ac:plain-text-body><![CDATA[

3

[d", "e", "f"]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6a5d838475eabd3e-ff63d734-4394484f-8978bd15-237361797ca40483d0c06e72"><ac:plain-text-body><![CDATA[

4

[d", "e", "f"]

]]></ac:plain-text-body></ac:structured-macro>

...