[
https://issues.apache.org/jira/browse/DRILL-3679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14709493#comment-14709493
]
Deneche A. Hakim commented on DRILL-3679:
-----------------------------------------
Looking at the plan, this looks similar to DRILL-3680: the Project operator
couldn't find {{w0$o00}} because both window functions output to the same field
{{w0$o0}}
{noformat}
explain plan for select rnum, ntile(4) over(order by position_id) from (select
position_id, row_number() over(order by position_id) as rnum from
cp.`employee.json`);
00-00 Screen
00-01 ProjectAllowDup(rnum=[$0], EXPR$1=[$1])
00-02 Project(w0$o0=[$1], w0$o00=[$2])
00-03 Window(window#0=[window(partition {} order by [0] range between
UNBOUNDED PRECEDING and CURRENT ROW aggs [NTILE($2)])])
00-04 SelectionVectorRemover
00-05 Sort(sort0=[$0], dir0=[ASC])
00-06 Project(position_id=[$1], w0$o0=[$2])
00-07 Window(window#0=[window(partition {} order by [1] range
between UNBOUNDED PRECEDING and CURRENT ROW aggs [ROW_NUMBER()])])
00-08 SelectionVectorRemover
00-09 Sort(sort0=[$1], dir0=[ASC])
00-10 Project(T7¦¦*=[$0], position_id=[$1])
00-11 Scan(groupscan=[EasyGroupScan
[selectionRoot=classpath:/employee.json, numFiles=1, columns=[`*`],
files=[classpath:/employee.json]]])
...
}, {
"pop" : "window",
"@id" : 7,
"child" : 8,
"aggregations" : [ {
"ref" : "`w0$o0`",
"expr" : "row_number(1) "
} ],
"orderings" : [ {
"expr" : "`position_id`",
"order" : "ASC",
"nullDirection" : "UNSPECIFIED"
} ],
"start" : -9223372036854775808,
"end" : -9223372036854775808,
"initialAllocation" : 1000000,
"maxAllocation" : 10000000000,
"withins" : [ ],
"cost" : 463.0
},
...
}, {
"pop" : "window",
"@id" : 3,
"child" : 4,
"aggregations" : [ {
"ref" : "`w0$o0`",
"expr" : "ntile(4) "
} ],
"orderings" : [ {
"expr" : "`position_id`",
"order" : "ASC",
"nullDirection" : "UNSPECIFIED"
} ],
"start" : -9223372036854775808,
"end" : -9223372036854775808,
"initialAllocation" : 1000000,
"maxAllocation" : 10000000000,
"withins" : [ ],
"cost" : 463.0
}, {
"pop" : "project",
"@id" : 2,
"exprs" : [ {
"ref" : "`w0$o0`",
"expr" : "`w0$o0`"
}, {
"ref" : "`w0$o00`",
"expr" : "`w0$o0`"
} ],
"child" : 3,
"initialAllocation" : 1000000,
"maxAllocation" : 10000000000,
"cost" : 463.0
}, {
...
+------+------+
{noformat}
> IOB Exception : when window functions used in outer and inner query
> -------------------------------------------------------------------
>
> Key: DRILL-3679
> URL: https://issues.apache.org/jira/browse/DRILL-3679
> Project: Apache Drill
> Issue Type: Bug
> Components: Query Planning & Optimization
> Affects Versions: 1.2.0
> Environment: private-branch
> https://github.com/adeneche/incubator-drill/tree/new-window-funcs
> Reporter: Khurram Faraaz
> Assignee: Deneche A. Hakim
> Labels: window_function
> Fix For: 1.2.0
>
>
> IOB Exception seen when two different window functions are used in inner and
> outer queries.
> {code}
> 0: jdbc:drill:schema=dfs.tmp> select rnum, position_id, ntile(4) over(order
> by position_id) from (select position_id, row_number() over(order by
> position_id) as rnum from cp.`employee.json`);
> java.lang.RuntimeException: java.sql.SQLException: SYSTEM ERROR:
> IndexOutOfBoundsException: index: 0, length: 4 (expected: range(0, 0))
> Fragment 0:0
> [Error Id: 8e0cbf82-842d-4fa7-ab0d-1d982a3d6c24 on centos-03.qa.lab:31010]
> at sqlline.IncrementalRows.hasNext(IncrementalRows.java:73)
> at
> sqlline.TableOutputFormat$ResizingRowsProvider.next(TableOutputFormat.java:87)
> at sqlline.TableOutputFormat.print(TableOutputFormat.java:118)
> at sqlline.SqlLine.print(SqlLine.java:1583)
> at sqlline.Commands.execute(Commands.java:852)
> at sqlline.Commands.sql(Commands.java:751)
> at sqlline.SqlLine.dispatch(SqlLine.java:738)
> at sqlline.SqlLine.begin(SqlLine.java:612)
> at sqlline.SqlLine.start(SqlLine.java:366)
> at sqlline.SqlLine.main(SqlLine.java:259)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)