[
https://issues.apache.org/jira/browse/DRILL-2777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14612540#comment-14612540
]
Jinfeng Ni commented on DRILL-2777:
-----------------------------------
The query in the CTAS is not valid, as Drill does not allow flatten() in ORDER
BY /GROUP BY.
This has been fixed in DRILL-3316. Commit:
ffae1691c0cd526ed1095fbabbc0855d016790d7
Create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst) lst,
flatten(lst_lst[0]) from cp.`employee.json` order by flatten(lst_lst[0]);
Error: UNSUPPORTED_OPERATION ERROR: Flatten function is not supported in Order
By
See Apache Drill JIRA: DRILL-2181
> CTAS, order by and flatten of repeated list result in ExpandConversionRule
> error
> --------------------------------------------------------------------------------
>
> Key: DRILL-2777
> URL: https://issues.apache.org/jira/browse/DRILL-2777
> Project: Apache Drill
> Issue Type: Bug
> Components: Query Planning & Optimization
> Reporter: Rahul Challapalli
> Assignee: Jinfeng Ni
> Fix For: 1.2.0
>
> Attachments: data.json, error.log
>
>
> git.commit.id.abbrev=f066786
> The below query results in an error :
> {code}
> create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst) lst,
> flatten(lst_lst[0]) from `data1.json` order by flatten(lst_lst[0]);
> Query failed: IndexOutOfBoundsException: index (2) must be less than size (2)
> Error: exception while executing query: Failure while executing query.
> (state=,code=0)
> {code}
> The logs indicate an assertion error :
> {code}
> Caused by: java.lang.AssertionError: Internal error: Error while applying
> rule ExpandConversionRule, args
> [rel#1757858:AbstractConverter.PHYSICAL.SINGLETON([]).[2](child=rel#1757856:Subset#8.PHYSICAL.ANY([]).[2],convention=PHYSICAL,DrillDistributionTraitDef=SINGLETON([]),sort=[2])]
> {code}
> The query itself does not have any issues. Also the below variants work :
> {code}
> 1. No flatten of repeated list in the select clause
> create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst[0]) from
> `data1.json` order by flatten(lst_lst[0]);
> 2. Removing the flatten from the order by. (Ordering by a scalar has no
> issues)
> create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst) lst,
> flatten(lst_lst[0]) from `data1.json`;
> {code}
> Attached the data set and the complete error log file
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)