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="2bfe333ed5dd52a9-10e2b03d-48ed4b90-97c2b668-70c9a909804b97bfad409bf4"><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="d7fe13d2d6b6d25d-274592ed-4a184b8c-aabc914f-c594558869103a8f45da2ffd"><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="69c6d881fc343be9-2a4c27ca-4ca649be-b404932b-a483525f589ff6f294ba7edc"><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="7eb7b4dca1dd4276-edcfa0ef-47d14406-97ef9103-eec720437325ae37ef3a04d1"><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="401308b8e8f85cb5-52b97440-40644df1-abf2a31d-d32086e40b3382537b71f184"><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="2c0d0cd2767932be-8962db06-440c41e6-a352af60-bb5c09cd05e5166dc0b0da93"><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="16693f71faaa7eeb-8bd87788-42494a5c-a5c2972f-ec605cd4dcc180a86a2bb32f"><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="ffcb008e433d5b95-12cc09ee-470b44d5-8332a6fe-a5844cc1627690b3a035c873"><ac:plain-text-body><![CDATA[

4

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

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

...