You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Mihai Budiu (Jira)" <ji...@apache.org> on 2026/08/07 17:03:00 UTC
[jira] [Resolved] (CALCITE-7688) Support scalar subqueries in table function arguments
[ https://issues.apache.org/jira/browse/CALCITE-7688?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mihai Budiu resolved CALCITE-7688.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in [https://github.com/apache/calcite/commit/a2a973ee074065553f082827b654cf43693ae060]
Thank you for the bug report and fix [~ktkalenko@gridgain.com]
> Support scalar subqueries in table function arguments
> -----------------------------------------------------
>
> Key: CALCITE-7688
> URL: https://issues.apache.org/jira/browse/CALCITE-7688
> Project: Calcite
> Issue Type: Improvement
> Reporter: Kirill Tkalenko
> Assignee: Kirill Tkalenko
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> Calcite currently does not rewrite scalar subqueries that occur inside *{{TableFunctionScan}}* arguments. Existing *{{SubQueryRemoveRule}}* variants handle subqueries in {*}{{Project}}{*}, {*}{{Filter}}{*}, and {*}{{Join}}{*}, but leave *{{RexSubQuery}}* expressions inside table function calls.
> Add support for uncorrelated and correlated scalar subqueries, including expressions containing multiple scalar subqueries:
> {code:java}
> SELECT *
> FROM TABLE(my_function((SELECT value FROM t), 1));
> SELECT *
> FROM TABLE(my_function((SELECT 4) + (SELECT 6), 1));
> SELECT *
> FROM person p
> CROSS JOIN LATERAL TABLE(
> my_function((SELECT p.id + 1), p.id)
> ); {code}
> Scalar subqueries should follow standard SQL cardinality semantics:
> * zero rows produce NULL;
> * one row produces its value;
> * more than one row raises an error.
> The resulting logical plan should be executable by both the *Enumerable* and *Interpreter* implementations.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)