[ 
https://issues.apache.org/jira/browse/DRILL-4572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15222606#comment-15222606
 ] 

Jinfeng Ni edited comment on DRILL-4572 at 4/2/16 1:00 AM:
-----------------------------------------------------------

This seems to be a bug in the query planner. I could re-produce this
problem, with similar query, even on 1.4 and 1.5.

{code}
select rtrim(s.name2) as name3
from (
  select
    ltrim(n_name) as `name2`,
    count(*) as num_creates
  from cp.`tpch/nation.parquet`
  group by ltrim(n_name)
  order by name2 ASC
) s limit 100
{code}

Error: SYSTEM ERROR: AssertionError: Internal error: Type
'RecordType(ANY $f0, BIGINT num_creates)' has no field 'name2'


was (Author: jni):
This seems to be a bug in the query planner. I could re-produce this
problem, with similar query, even on 1.4 and 1.5.

select rtrim(s.name2) as name3
from (
  select
    ltrim(n_name) as `name2`,
    count(*) as num_creates
  from cp.`tpch/nation.parquet`
  group by ltrim(n_name)
  order by name2 ASC
) s limit 100

Error: SYSTEM ERROR: AssertionError: Internal error: Type
'RecordType(ANY $f0, BIGINT num_creates)' has no field 'name2'

> Column Alias Not Available in Subquery
> --------------------------------------
>
>                 Key: DRILL-4572
>                 URL: https://issues.apache.org/jira/browse/DRILL-4572
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.4.0, 1.5.0, 1.6.0
>            Reporter: John Omernik
>
> In the query and error below, I have a "inside" aggregate query where the 
> groupped field is the result of a function, but I use an alias (`cdate`) to 
> reference it.  In the outer part of the query, I try to reference that alias 
> and the query fails with the error. The error seems to imply it can't see the 
> aliased field. 
> Jinfeng Ni was also able to reproduce based on the mailing list. 
> select date_part('year', s.cdate) as ydate from (
>     select 
>     to_date(createdon, 'yyyy-MM-dd HH:mm:ss') as `cdate`, count(*) as      
> num_creates 
>     from 
>     view_mytable
>    where 
>    createdon <> '0000-00-00 00:00:00' and createdon >= '2010-01-10' 
>    group by 
>     to_date(createdon, 'yyyy-MM-dd HH:mm:ss')
>     order by cdate ASC
> ) s limit 100
> SYSTEM ERROR: AssertionError: Internal error: Type 'RecordType(ANY $f0, 
> BIGINT num_creates)' has no field 'cdate'
> [Error Id: 50caacaf-0b9b-4c1c-a3e1-53248bc385c0 on 
> hadoopmapr6.brewingintel.com:31010]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to