Skip to content

[CALCITE-7732] Make TABLE optional for LATERAL table function calls - #5214

Open
darpan-14 wants to merge 2 commits into
apache:mainfrom
darpan-14:CALCITE-7732
Open

[CALCITE-7732] Make TABLE optional for LATERAL table function calls#5214
darpan-14 wants to merge 2 commits into
apache:mainfrom
darpan-14:CALCITE-7732

Conversation

@darpan-14

Copy link
Copy Markdown

Jira Link

CALCITE-7732

Changes Proposed

Calcite allows table functions in the FROM clause without the TABLE(...)
wrapper:

SELECT *
FROM fn(args)

However, explicitly specifying LATERAL currently makes the wrapper mandatory:

SELECT *
FROM t, LATERAL TABLE(fn(t.a))

This change makes TABLE optional in that context, allowing:

SELECT *
FROM t, LATERAL fn(t.a)

The existing wrapped syntax remains supported and unchanged.

The parser recognizes unqualified and schema-qualified function names and
constructs the same LATERAL and COLLECTION_TABLE parse tree used by the
wrapped form. Existing handling of LATERAL TABLE(...), LATERAL UNNEST(...),
and lateral subqueries remains unchanged.

@sonarqubecloud

Copy link
Copy Markdown


// Detect LATERAL function(...) without adding a multi-token JavaCC
// lookahead sequence to parse errors for existing LATERAL syntax.
private boolean isLateralImplicitTableFunctionAhead() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not crazy about this function. Is there a simpler way to do it, maybe by refactoring the grammar a bit?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, have updated the implementation. Could you please check again?

@mihaibudiu

Copy link
Copy Markdown
Contributor

This is much better; please squash the commits for merging
Also, please note that your commit message is not the same as the JIRA issue

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