You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Vitalii Diravka (JIRA)" <ji...@apache.org> on 2018/07/11 15:14:00 UTC

[jira] [Commented] (DRILL-6417) Project is not pushed into scan if use subquery with UNION operator

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

Vitalii Diravka commented on DRILL-6417:
----------------------------------------

This is not an issue. See more in CALCITE-2410.
 It is not allowed to transpose Project with a filtering SetOp operators, since it can lead to incorrect result.

USE CASE:
{code:java}
Table1
id | Name    |
-------------
1  | John    |
2  | Steaven |{code}
{code:java}
Table2
id | Name    |
-------------
3  | John    |
4  | Aman    |{code}
{code:sql}
SELECT `Name` FROM (SELECT * FROM `Table1` UNION SELECT * FROM `Table2`)
{code}
The correct output is:
{code:SQL}
Name    |
--------
John    |
Steaven |
John    |
Aman    |
{code}
 If the top Project will be applied to Scan operators it will lead to the wrong output:
{code:SQL}
Name    |
--------
John    |
Steaven |
Aman    |
{code}


> Project is not pushed into scan if use subquery with UNION operator
> -------------------------------------------------------------------
>
>                 Key: DRILL-6417
>                 URL: https://issues.apache.org/jira/browse/DRILL-6417
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.14.0
>            Reporter: Anton Gozhiy
>            Assignee: Vitalii Diravka
>            Priority: Major
>         Attachments: Test_data.tar.gz
>
>
> *Data:*
> Use attached dataset
> *Query:*
> {code:sql}
> explain plan for select id
> from 
>   (select id, part_col, int_col, bool_col, date_col, float_col, time_col, ts_col
>    from dfs.tmp.`DRILL_3855_test_data`
>    where part_col = 'Partition_one' or part_col = 'Partition_two'
>    union
>    select id, part_col, int_col, bool_col, date_col, float_col, time_col, ts_col
>    from dfs.tmp.`DRILL_3855_test_data`
>    where part_col = 'Partition_two' or part_col = 'Partition_three')
> where int_col = 0
> {code}
> *Expected plan:*
> {noformat}
> Scan ... columns=[`part_col`, `id`, `int_col`]
> {noformat}
> *Actual plan:*
> {noformat}
> Scan ... columns=[`part_col`, `id`, `int_col`, `bool_col`, `date_col`, `float_col`, `time_col`, `ts_col`]
> {noformat}
> *Notes:*
> Works as expected if change "union" to "union all"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)