drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khurram Faraaz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-4924) Can not use case expression within an IN predicate.
Date Mon, 03 Oct 2016 17:22:20 GMT

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

Khurram Faraaz commented on DRILL-4924:
---------------------------------------

Another observation, when we do a select * from inside the in clause, we  see a NestedLoops
join and later a HashJoin, where are when I replace the select * from by (values(1)) we see
an error, "query cannot be planned possibly due to either a cartesian join or an inequality
join".
Which of the two behaviors is expected ?

{noformat}
0: jdbc:drill:schema=dfs.tmp> explain plan for select * from `emp_tbl` where id not IN
( SELECT CASE WHEN id=1 THEN 30 else id end from (select * from `emp_tbl`));
+------+------+
| text | json |
+------+------+
| 00-00    Screen
00-01      Project(*=[$0])
00-02        Project(T11¦¦*=[$0])
00-03          SelectionVectorRemover
00-04            Filter(condition=[CASE(=($2, 0), CAST(true):BOOLEAN, IS NOT NULL($6), CAST(false):BOOLEAN,
IS NULL($4), null, <($3, $2), null, CAST(true):BOOLEAN)])
00-05              HashJoin(condition=[=($4, $5)], joinType=[left])
00-07                Project(T11¦¦*=[$0], id=[$1], $f0=[$2], $f1=[$3], id0=[$1])
00-09                  NestedLoopJoin(condition=[true], joinType=[inner])
00-12                    Project(T11¦¦*=[$0], id=[$1])
00-15                      Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath [path=maprfs:///tmp/emp_tbl]],
selectionRoot=maprfs:/tmp/emp_tbl, numFiles=1, usedMetadataFile=false, columns=[`*`]]])
00-11                    StreamAgg(group=[{}], agg#0=[COUNT()], agg#1=[COUNT($0)])
00-14                      Project($f0=[CASE(=(ITEM($0, 'id'), 1), 30, ITEM($0, 'id'))], $f1=[true])
00-17                        Project(T12¦¦*=[$0], id=[$1])
00-18                          Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath
[path=maprfs:///tmp/emp_tbl]], selectionRoot=maprfs:/tmp/emp_tbl, numFiles=1, usedMetadataFile=false,
columns=[`*`]]])
00-06                Project($f00=[$0], $f10=[$1])
00-08                  HashAgg(group=[{0}], agg#0=[MIN($1)])
00-10                    Project($f0=[CASE(=(ITEM($0, 'id'), 1), 30, ITEM($0, 'id'))], $f1=[true])
00-13                      Project(T13¦¦*=[$0], id=[$1])
00-16                        Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath
[path=maprfs:///tmp/emp_tbl]], selectionRoot=maprfs:/tmp/emp_tbl, numFiles=1, usedMetadataFile=false,
columns=[`*`]]])
{noformat}

> Can not use case expression within an IN predicate.
> ---------------------------------------------------
>
>                 Key: DRILL-4924
>                 URL: https://issues.apache.org/jira/browse/DRILL-4924
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.9.0
>            Reporter: Khurram Faraaz
>
> Can not use case expression within an IN predicate.
> Drill 1.9.0 git commit ID: f3c26e34
> Similar query works on Postgres 9.3
> {noformat}
> postgres=# select * from t1 where c1 in ( select case when c1=2 then 30 else c1 end);
>  c1 | c2
> ----+-----
>   1 |   0
>   3 |  19
>  -1 |  11
>   5 |  13
>  10 |  17
>  11 |  -1
>  13 |   1
>  17 |  20
>   0 |   9
>  19 | 100
> (10 rows)
> {noformat}
> Drill 1.9.0 returns an error
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select * from `emp_tbl` where id IN ( SELECT CASE WHEN
id=2 THEN 30 else id end );
> Error: PARSE ERROR: Encountered ")" at line 1, column 81.
> Was expecting one of:
>     "FROM" ...
>     "," ...
>     "AS" ...
>     <IDENTIFIER> ...
>     <QUOTED_IDENTIFIER> ...
>     <BACK_QUOTED_IDENTIFIER> ...
>     <BRACKET_QUOTED_IDENTIFIER> ...
>     <UNICODE_QUOTED_IDENTIFIER> ...
>     "NOT" ...
>     "IN" ...
>     "BETWEEN" ...
>     "LIKE" ...
>     "SIMILAR" ...
>     "=" ...
>     ">" ...
>     "<" ...
>     "<=" ...
>     ">=" ...
>     "<>" ...
>     "+" ...
>     "-" ...
>     "*" ...
>     "/" ...
>     "||" ...
>     "AND" ...
>     "OR" ...
>     "IS" ...
>     "MEMBER" ...
>     "SUBMULTISET" ...
>     "MULTISET" ...
>     "[" ...
> SQL Query select * from `emp_tbl` where id IN ( SELECT CASE WHEN id=2 THEN 30 else id
end )
>                                                                                 ^
> [Error Id: e6c3f120-8776-476e-8df7-7ef30f6b7307 on centos-01.qa.lab:31010] (state=,code=0)
> {noformat}



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

Mime
View raw message