[
https://issues.apache.org/jira/browse/PHOENIX-945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14162940#comment-14162940
]
Maryann Xue commented on PHOENIX-945:
-------------------------------------
The limitations are:
1. The correlation condition in the inner query has to be what we currently
allow for ON conditions in joins.
2. The inner query must be an non-group-by aggregate query, such as "select
max(c1) from table1 where <correlation_condition>".
At least half of the cases in limitation 2 will benefit from PHOENIX-1299,
which will convert ANY/SOME/ALL queries into exactly the queries covered by
this fix.
Besides, I just opened PHOENIX-1332, which will eliminate the second limitation
completely. But this would require a bit of work. With those cases for which
the optimization of PHOENIX-1299 is not enough, it will depend on the
completion of PHOENIX-944, plus a special aggregate function which will allow
returning values in the same group as an array.
> Support correlated subqueries in comparison without ANY/SOME/ALL
> ----------------------------------------------------------------
>
> Key: PHOENIX-945
> URL: https://issues.apache.org/jira/browse/PHOENIX-945
> Project: Phoenix
> Issue Type: Sub-task
> Affects Versions: 3.0.0, 4.0.0, 5.0.0
> Reporter: Maryann Xue
> Assignee: Maryann Xue
> Fix For: 3.0.0, 4.0.0, 5.0.0
>
> Attachments: 945.patch
>
> Original Estimate: 336h
> Remaining Estimate: 336h
>
> Example:
> SELECT employee_number, name
> FROM employees AS Bob
> WHERE salary > (
> SELECT AVG(salary)
> FROM employees
> WHERE department = Bob.department);
> Basically we can optimize these queries into join queries, like:
> SELECT employees.employee_number, employees.name
> FROM employees INNER JOIN
> (SELECT department, AVG(salary) AS department_average
> FROM employees
> GROUP BY department) AS temp ON employees.department = temp.department
> WHERE employees.salary > temp.department_average;
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)