[ 
https://issues.apache.org/jira/browse/CALCITE-7732?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Darpan Lunagariya (e6data) reassigned CALCITE-7732:
---------------------------------------------------

    Assignee: Darpan Lunagariya (e6data)

> Make the TABLE keyword optional for table function calls in LATERAL context
> ---------------------------------------------------------------------------
>
>                 Key: CALCITE-7732
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7732
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Fabian Hueske
>            Assignee: Darpan Lunagariya (e6data)
>            Priority: Major
>
> h3. Summary
> Calcite currently requires the {{TABLE}} keyword when a table function is 
> invoked together with the explicit {{LATERAL}} keyword. This issue proposes 
> making {{TABLE}} optional in that position, so that both of the following are 
> accepted:
> {code:sql}
> -- explicit form (still supported, unchanged)
> SELECT * FROM t, LATERAL TABLE(fn(t.a))
> -- new, TABLE keyword omitted
> SELECT * FROM t, LATERAL fn(t.a)
> {code}
> The {{TABLE}} keyword remains fully supported, it simply becomes optional. 
> Existing queries continue to parse and behave exactly as before; this is a 
> purely additive, backward-compatible change.
> h3. Motivation
> As of CALCITE-6254 (1.37.0), a table function can be invoked in the 
> {{{}FROM{}}}/{{{}JOIN{}}} position without the {{TABLE(...)}} wrapper:
> {code:sql}
> SELECT * FROM fn(args)          -- OK since 1.37.0
> SELECT * FROM t JOIN fn(args) ON ...
> {code}
> However, once the {{LATERAL}} keyword is written explicitly, the {{TABLE}} 
> wrapper becomes mandatory again. This leaves an inconsistent matrix:
> ||Syntax||Supported today||
> |{{FROM t, fn(args)}} (implicit lateral, no {{{}TABLE{}}})|(/) (CALCITE-6254)|
> |{{FROM t, LATERAL TABLE(fn(args))}}|(/)|
> |{{FROM t, TABLE(fn(args))}}|(/)|
> |{{FROM t, LATERAL fn(args)}}|(x)|
> Requiring {{TABLE}} _only_ when {{LATERAL}} is spelled out is a syntactic 
> inconsistency. The {{TABLE}} keyword adds no information in this context and 
> bloats the syntax. Several vendors treat it as optional. Making it optional 
> under {{LATERAL}} completes the matrix and aligns the two spellings.
> h3. Backward compatibility
> Fully backward compatible:
>  * {{TABLE}} stays a legal, supported keyword — it is only made optional.
>  * All existing queries ({{{}LATERAL TABLE(fn(...)){}}}, 
> {{{}TABLE(fn(...)){}}}, plain {{{}fn(...){}}}) parse and behave identically.
>  * The change only adds an optional syntax path; no existing behavior is 
> removed or altered.
> h3. References
>  * CALCITE-6254 — Support table function calls in FROM clause without TABLE() 
> wrapper (direct precedent, 1.37.0)
>  * CALCITE-1490 — Allow table functions without explicit TABLE (dup of 6254)
>  * CALCITE-4396 — Allow table valued functions in FROM and JOIN without TABLE 
> clause (dup of 6254)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to