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="47370d5722f3d7cd-730f49d4-4b5445df-b157a758-3bc7006a367f251ff8fb1c15"><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="31186fcad7dbc5f1-dc39c7c6-42044286-8590b18a-05bf1d12e61f743fbc252834"><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="173b2086e3a3a499-601ef592-4efb4d33-a49abe8c-ca9f1e5b12602efa1619694a"><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="f517ad1ac1215b8e-5b0453df-4c70483f-8d788b9d-3941886ff92bc6bf63568e6f"><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="6a4a73524d3c6360-ddeffaeb-46d9478b-8826b810-e8dda7558f494575d778740c"><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="d277516d2fb19fac-c6989870-456649fe-a67f8d76-9e5773b3f89e3f121106447c"><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="58efc69782774c4a-26b02f05-45a74b58-9555af6d-91330d69f3342e5d333388ae"><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="ad53d97259c004f1-7d1870c6-4006421f-8ed1a980-bedb671c41f39717eea635eb"><ac:plain-text-body><![CDATA[

4

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

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

...