[
https://issues.apache.org/jira/browse/DRILL-3204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14582664#comment-14582664
]
Sean Hsuan-Yi Chu edited comment on DRILL-3204 at 6/11/15 11:08 PM:
--------------------------------------------------------------------
The reason is:
When {color: red} order by {color} is not specified, Calcite has a smart
(bugged though...) mechanism to figure out if a column happens to be sorted (in
subquery).
We can argue it is not necessary, but it could prove usefulness sometimes. For
example,
Rank() needs {color: red} order by {color}, but we do not want our query to get
blocked simply because {color: red} order by {color} is written in the subquery:
{code:sql}
select Rank(...) over(partition by a)
from (
select a
from ...
order by a
)
{code}
was (Author: seanhychu):
The reason is:
When {color: red} order by {color} is not specified, Calcite has a smart
(bugged though...) mechanism to figure out if a column happens to be sorted (in
subquery).
We can argue it is not necessary, but it could prove usefulness sometimes. For
example,
Rank() needs {color: red} order by {color}, but we do not want our query to get
blocked simple because {color: red} order by {color} is written in the subquery:
{code:sql}
select Rank(...) over(partition by a)
from (
select a
from ...
order by a
)
{code}
> Problem in name resolution with window functions
> ------------------------------------------------
>
> Key: DRILL-3204
> URL: https://issues.apache.org/jira/browse/DRILL-3204
> Project: Apache Drill
> Issue Type: Bug
> Components: Query Planning & Optimization
> Affects Versions: 1.0.0
> Reporter: Victoria Markman
> Assignee: Sean Hsuan-Yi Chu
> Priority: Blocker
> Labels: window_function
> Fix For: 1.1.0
>
>
> Trying to use window functions with the join and window aggregate function on
> one of the columns coming out of join, get an error:
> {code}
> 0: jdbc:drill:schema=dfs> select sum(t1.a1) over(partition by t1.b1) from
> t1, t2 where t1.c1 = t2.c2 group by t1.a1, t1.b1;
> Error: PARSE ERROR: At line 0, column 0: Column 'a1' is ambiguous
> [Error Id: 3a6c4906-c48f-41c7-b9e1-3f59a951e55f on atsqa4-133.qa.lab:31010]
> (state=,code=0)
> {code}
> Tables used in the query:
> {code}
> 0: jdbc:drill:schema=dfs> select * from t1 limit 1;
> +-----+--------+-------------+
> | a1 | b1 | c1 |
> +-----+--------+-------------+
> | 1 | aaaaa | 2015-01-01 |
> +-----+--------+-------------+
> 1 row selected (0.133 seconds)
> 0: jdbc:drill:schema=dfs> select * from t2 limit 1;
> +-----+------+-------------+
> | a2 | b2 | c2 |
> +-----+------+-------------+
> | 0 | zzz | 2014-12-31 |
> +-----+------+-------------+
> 1 row selected (0.121 seconds)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)