Before you file an issue
Verified issue exist on v30.6.0
Also validated that the example sql is runnable in Spark:
WITH my_table AS (
SELECT ARRAY(NAMED_STRUCT('name', 'alice'), NAMED_STRUCT('name', 'bob')) AS items
)
SELECT ci.name
FROM my_table
LATERAL VIEW EXPLODE(items) ci AS ci;
Fully reproducible code snippet
import sqlglot
from sqlglot.optimizer import optimize
sql = """
SELECT ci.name
FROM my_table
LATERAL VIEW EXPLODE(items) ci AS ci
"""
schema = {"my_table": {"items": "ARRAY<STRUCT<name:STRING>>"}}
optimize(sql, schema=schema, dialect="spark")
# sqlglot.errors.OptimizeError: Unknown column: name
Before you file an issue
Verified issue exist on v30.6.0
Also validated that the example sql is runnable in Spark:
Fully reproducible code snippet