question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for lateral view explode clause

See original GitHub issue

getting error when trying to get the tables for sql below,

sql = """
WITH uisd_filter_table as (
    select
        session_id,
        srch_id,
        srch_ci,
        srch_co,
        srch_los,
        srch_sort_type,
        impr_list
    from
        uisd
    where
        datem <= date_sub(date_add(current_date(), 92), 7 * 52)
        and lower(srch_sort_type) in ('expertpicks', 'recommended')
        and srch_ci <= date_sub(date_add(current_date(), 92), 7 * 52)
        and srch_co >= date_sub(date_add(current_date(), 1), 7 * 52)
)
select
    DISTINCT session_id,
    srch_id,
    srch_ci,
    srch_co,
    srch_los,
    srch_sort_type,
    l.impr_property_id as expe_property_id,
    l.impr_position_across_pages
from
    uisd_filter_table lateral view explode(impr_list) table as l
"""

How to reproduce the error:

p = Parser(sql)
print(p.tables)

Error:

Traceback (most recent call last):
  File "/Users/asalam/vscode/new/source_analyser/utils.py", line 152, in <module>
    print(p.tables)
  File "/Users/asalam/Library/Python/3.8/lib/python/site-packages/sql_metadata/parser.py", line 398, in tables
    with_names = self.with_names
  File "/Users/asalam/Library/Python/3.8/lib/python/site-packages/sql_metadata/parser.py", line 544, in with_names
    if token.next_token.normalized in WITH_ENDING_KEYWORDS:
AttributeError: 'NoneType' object has no attribute 'normalized'

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
collerekcommented, Jun 22, 2021

@abecus The original bug was resolved but the tables still will return wrong data as the lateral view explode is not yet supported. Therefore I changed the name and label of this issue.

1reaction
macbrecommented, Jun 10, 2021

Tricky one. Then comes the question if we should for instance support PIVOT as well?

Let’s deal with this one in a separate PR / GitHub discussions thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LATERAL VIEW Clause - Spark 3.3.1 Documentation
The LATERAL VIEW clause is used in conjunction with generator functions such as EXPLODE , which will generate a virtual table containing one...
Read more >
Hive Lateral View Explode with where clause - what runs first
I am trying to understand if WHERE clause runs after or before with LATERAL VIEW EXPLODE in hive. For example if I have...
Read more >
LATERAL VIEW clause | Databricks on AWS
Used in conjunction with generator functions such as EXPLODE , which generates a virtual table containing one or more rows. LATERAL VIEW ......
Read more >
Hive Explode / Lateral View clarification - Cloudera Community
A lateral view first applies the UDTF to each row of base table and then joins resulting output rows to the input rows...
Read more >
LATERAL VIEW clause - Azure Databricks - Microsoft Learn
Used in conjunction with generator functions such as EXPLODE , which generates a virtual table containing one or more rows. LATERAL VIEW ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found