Kirill Tkalenko created CALCITE-7688:
----------------------------------------
Summary: 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
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)