Skip to content

fix: check LATERAL VIEW generator functions in adapter and validator - #2956

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:lateral-view-generator-walk
Nov 24, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
tanjiroK-coder:lateral-view-generator-walk

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

PlainSelect keeps Hive/Spark LATERAL VIEW clauses in getLateralViews(), but SelectVisitorAdapter.visit(PlainSelect) still has them as a commented-out @todo and SelectValidator.visit(PlainSelect) never looks at them, so the generator function is only walked by TablesNamesFinder and the deparser. StatementFeatureVisitor builds on the adapter, which means a call in that slot never reaches the pure-function check: SELECT a FROM t LATERAL VIEW explode(purge_audit()) v AS c comes back with mayModifyData() == false and no unresolved reference and passes the read-only guard in usage.rst, while SELECT explode(purge_audit()) FROM t leaves MODIFIES_DATA possible with unresolved=[purge_audit]. Hive and Spark evaluate the generator and its arguments like a select-list call, so reflect/java_method and user UDTFs run there too. On the Validation side, with Feature.function removed, SELECT a FROM t LATERAL VIEW explode(b) v AS c validates with no errors although explode is a function call. I noticed it while comparing which PlainSelect parts TablesNamesFinder walks against the adapter, after #2928 and #2879 closed similar gaps for other clauses. The adapter now hands each generator function to its expression visitor, and SelectValidator validates it as an expression right after the joins. The new functionIsChecked and testValidateFunctionOutsideWhere cases fail before (3 failures) and pass after; Spotless, Checkstyle, PMD and SpotBugs pass, and the rest of ./gradlew check is unchanged (the only failures locally are 33 Mockito inline-mock-maker init errors and 2 temp-file permission errors that fail the same way on master on this machine).

@manticore-projects
manticore-projects merged commit ba9291f into JSQLParser:master Nov 24, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you much!

I am thinking of introducing an org. chart and making you "head of Visitors", while @minleejae would become "head of DDLs" :-)
Keep up the good work, guys. I send out much appreciation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants