You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Allison Wang (Jira)" <ji...@apache.org> on 2022/10/14 15:53:00 UTC

[jira] [Created] (SPARK-40800) Always inline expressions in OptimizeOneRowRelationSubquery

Allison Wang created SPARK-40800:
------------------------------------

             Summary: Always inline expressions in OptimizeOneRowRelationSubquery
                 Key: SPARK-40800
                 URL: https://issues.apache.org/jira/browse/SPARK-40800
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 3.4.0
            Reporter: Allison Wang


SPARK-39699 made `CollpaseProjects` more conservative. This has impacted correlated subqueries that Spark used to be able to support. For example, a correlated one-row scalar subquery that has a higher-order function:
{code:java}
CREATE TEMP VIEW t1 AS SELECT ARRAY('a', 'b') a 

SELECT (
  SELECT array_sort(a, (i, j) -> rank[i] - rank[j]) AS sorted
  FROM (SELECT MAP('a', 1, 'b', 2) rank)
) FROM t1{code}
This will throw an exception after SPARK-39699:

 
{code:java}
Unexpected operator Join Inner
:- Aggregate [[a,b]], [[a,b] AS a#252]
:  +- OneRowRelation
+- Project [map(keys: [a,b], values: [1,2]) AS rank#241]
   +- OneRowRelation
 in correlated subquery{code}
because the projects inside the subquery can no longer be collapsed. We should always inline expressions if possible to avoid adding domain joins and support a wider range of correlated subqueries. 

 

 



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org