You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Serge Harnyk (JIRA)" <ji...@apache.org> on 2016/03/23 12:25:25 UTC

[jira] [Comment Edited] (DRILL-4399) query using OVERLAPS function executes and returns 0 rows

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

Serge Harnyk edited comment on DRILL-4399 at 3/23/16 11:25 AM:
---------------------------------------------------------------

Query before optimisation:
select 1 from tdt where (date '1999-12-01' , date '2001-12-31' ) 
overlaps ( date '2001-01-01' , tdt.cdt ) and rnum=0

Query passed to jdbc:
SELECT 1 AS "EXPR$0" FROM "tdt"
WHERE DATE '2001-12-31' >= DATE '2001-01-01' AND "cdt" >= DATE '1999-12-01' AND "rnum" = 0

Query before optimisation:
select 1 from tdt where ( date '2001-12-31', date '1999-12-01' ) 
overlaps ( date '2001-01-01' , tdt.cdt ) and rnum=0

Query passed to jdbc:
SELECT 1 AS "EXPR$0" FROM "public"."tdt"
WHERE DATE '1999-12-01' >= DATE '2001-01-01' AND "cdt" >= DATE '2001-12-31' AND "rnum" = 0

When Drill meets OVERLAPS function it transforms it to (StartA <= EndB) and (EndA >= StartB) condition.

PostgreSQL add more logic - http://www.postgresql.org/docs/9.3/static/functions-datetime.html

"When a pair of values is provided, either the start or the end can be written first; OVERLAPS automatically takes the earlier value of the pair as the start."


was (Author: sharnyk):
Query before optimisation:
select 1 from tdt where (date '1999-12-01' , date '2001-12-31' ) 
overlaps ( date '2001-01-01' , tdt.cdt ) and rnum=0

Query passed to jdbc:
SELECT 1 AS "EXPR$0" FROM "tdt"
WHERE DATE '2001-12-31' >= DATE '2001-01-01' AND "cdt" >= DATE '1999-12-01' AND "rnum" = 0

Query before optimisation:
select 1 from tdt where ( date '2001-12-31', date '1999-12-01' ) 
overlaps ( date '2001-01-01' , tdt.cdt ) and rnum=0

Query passed to jdbc:
SELECT 1 AS "EXPR$0" FROM "public"."tdt"
WHERE DATE '1999-12-01' >= DATE '2001-01-01' AND "cdt" >= DATE '2001-12-31' AND "rnum" = 0

When Drill meets OVERLAPS function it transform it to (StartA <= EndB) and (EndA >= StartB) condition.

PostgreSQL add more logic - http://www.postgresql.org/docs/9.3/static/functions-datetime.html

"When a pair of values is provided, either the start or the end can be written first; OVERLAPS automatically takes the earlier value of the pair as the start."

> query using OVERLAPS function executes and returns 0 rows
> ---------------------------------------------------------
>
>                 Key: DRILL-4399
>                 URL: https://issues.apache.org/jira/browse/DRILL-4399
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Storage - JDBC
>    Affects Versions: 1.5.0
>            Reporter: N Campbell
>            Assignee: Serge Harnyk
>
> Doc set makes not mention of this, but parses and executes
> select 1 from postgres.public.tdt where (date '1999-12-01' , date '2001-12-31' ) overlaps  ( date '2001-01-01' , tdt.cdt ) and rnum=0
> This query executed by Postgres would return 1 row
> create table TDT ( RNUM integer  not null , CDT date   ) ;
> comment on table TDT is 'This describes table TDT.';
> grant select on table TDT to public;
> insert into TDT(RNUM, CDT) values ( 0, NULL);
> insert into TDT(RNUM, CDT) values ( 1, DATE '1996-01-01');
> insert into TDT(RNUM, CDT) values ( 2, DATE '2000-01-01');
> insert into TDT(RNUM, CDT) values ( 3, DATE '2000-12-31');



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