Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: update note on predicate pushdown optimization (fixed in 0.6.0)

...

Lateral view is used in conjunction with user-defined table generating functions such as explode(). As mentioned in 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.

Important note

...

Info
titleVersion

Prior to Hive 0.6.0, lateral view

...

did not support the predicate push-down optimization

...

. In Hive 0.5.0 and earlier, if you used a WHERE clause

...

your query may not

...

have compiled. A workaround was to add set hive.optimize.ppd=false; before your query. The fix was made in Hive 0.6.0; see https://issues.apache.org/jira/browse/HIVE-1056

...

: Predicate push down does not work with UDTF's.

Example

Consider the following base table named pageAds. It has two columns: pageid (name of the page) and adid_list (an array of ads appearing on the page):

string pageid

Array<int> adid_list

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="475f8c7f084ddb02-b376caca-48fe4f40-918cb3bd-7fb971b8cd942f981ac5493b"><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="5a8c8bed1943d05a-70ae79df-447b425c-9825a394-dbb9a6879c08639094391a7e"><ac:plain-text-body><![CDATA[

"contact_page"

[3, 4, 5]

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

...

Array<int> col1

Array<string> col2

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2b062d5ee58fae9b-f21e3930-42214bac-b0bfb09c-c1e99410a677c337ca70436f"><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="d03d57e49072d5b6-29015321-48794234-8c07bcc5-42fc6ad213be75c1c96c6885"><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="a62c84e163cee291-a9b9527f-4fb045ad-9aeb9c31-493c1cf60f0545f3896db00c"><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="b9028b369f94223e-cc81929e-45074f84-b44cbc86-b3a900d37bb09668d59e6b83"><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="60777a791214e1db-30d3f27e-45544d9c-94549c67-afc327067faa269cc410376b"><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="19d734af9c70dea1-62397131-44ec413c-a604b14b-6ac2bfe492a48bbc5727901b"><ac:plain-text-body><![CDATA[

4

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

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

...