[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2017-02-16 Thread Khurram Faraaz (JIRA)

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

Khurram Faraaz commented on DRILL-4939:
---

Thanks for confirming the behavior and for explaining.

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2017-02-16 Thread Serhii Harnyk (JIRA)

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

Serhii Harnyk commented on DRILL-4939:
--

[~khfaraaz] This function returns correct result, and it's behavior does not 
changed. According to 
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
 you should use pattern -MM-dd. If you want to use Postgres-based date-time 
format, you should use function sql_to_date.
{code:sql}
values(to_date('2016-09-22','-MM-dd'));
+-+
|   EXPR$0|
+-+
| 2016-09-22  |
+-+
{code}

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2017-02-16 Thread Khurram Faraaz (JIRA)

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

Khurram Faraaz commented on DRILL-4939:
---

[~sharnyk] The example used in this JIRA still returns incorrect results, 
should we not allow such usage ? Should we report a warning/error for queries 
like the one below ? 

{noformat}
0: jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2016-01-22  |
+-+
1 row selected (0.192 seconds)
{noformat}

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2017-02-15 Thread Kunal Khatua (JIRA)

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

Kunal Khatua commented on DRILL-4939:
-

[~khfaraaz] Please verify this and check in relevant tests.

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2017-02-13 Thread Serhii Harnyk (JIRA)

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

Serhii Harnyk commented on DRILL-4939:
--

to_date function requires date-time pattern in JodaTime format 
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html
where mm is a minute of hour. 
In 
[c9a6ac4|https://github.com/apache/drill/commit/c9a6ac4fc8859693b7b0a71885afb700f81e345c]
 added new UDF sql_to_date, which requires Postgres-based date-time format.
So next query returns correct result:
{code} 
0: jdbc:drill:zk=local> values(sql_to_date('2016-09-22','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2016-09-22  |
+-+
{code}

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2016-10-10 Thread Arina Ielchiieva (JIRA)

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

Arina Ielchiieva commented on DRILL-4939:
-

This should be fixed once DRILL-4864 will be merged.

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



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


[jira] [Commented] (DRILL-4939) to_date function returns incorrect result

2016-10-10 Thread Khurram Faraaz (JIRA)

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

Khurram Faraaz commented on DRILL-4939:
---

Month part of '-MM-DD' is wrong in the results returned by to_date 
function, here are some tests for which to_date returns wrong results.

{noformat}
0: jdbc:drill:schema=dfs.tmp> values(to_date('2015-09-22','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2015-01-22  |
+-+
1 row selected (0.124 seconds)
0: jdbc:drill:schema=dfs.tmp> values(to_date('2015-10-22','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2015-01-22  |
+-+
1 row selected (0.125 seconds)
0: jdbc:drill:schema=dfs.tmp> values(to_date('2012-11-22','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2012-01-22  |
+-+
1 row selected (0.116 seconds)
0: jdbc:drill:schema=dfs.tmp> values(to_date('2012-11-10','-mm-dd'));
+-+
|   EXPR$0|
+-+
| 2012-01-10  |
+-+
1 row selected (0.163 seconds)
{noformat}

> to_date function returns incorrect result
> -
>
> Key: DRILL-4939
> URL: https://issues.apache.org/jira/browse/DRILL-4939
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Execution - Data Types
>Affects Versions: 1.9.0
>Reporter: Khurram Faraaz
>Priority: Critical
>
> to_date function returns wrong result
> correct results from Postgres
> {noformat}
> postgres=# values(to_date('2016-09-22','-mm-dd'));
>   column1
> 
>  2016-09-22
> (1 row)
> {noformat}
> wrong results returned by Drill 1.9.0 git commit id: 4edabe7a
> {noformat}
> : jdbc:drill:schema=dfs.tmp> values(to_date('2016-09-22','-mm-dd'));
> +-+
> |   EXPR$0|
> +-+
> | 2016-01-22  |
> +-+
> 1 row selected (0.125 seconds)
> {noformat}
> Postgres 9.3 returns true for below query whereas drill 1.9.0 returns false.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = 
> to_date('2016-09-22','-mm-dd')) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.146 seconds)
> postgres=# select (res1 = to_date('2016/09/22','-mm-dd')) res2
> postgres-# from
> postgres-# (
> postgres(# select (case when (false) then null else cast('2016/09/22' as 
> date) end) res1
> postgres(# from (values(1)) foo
> postgres(# ) foobar;
>  res2
> --
>  t
> (1 row)
> {noformat}
> Postgres 9.3 returns an error for below query, where as Drill git commit ID: 
> 4edabe7a returns some results.
> This looks like it has to do with the to_date function in drill.
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> select (res1 = to_date(2016/09/22)) res2
> . . . . . . . . . . . . . . > from
> . . . . . . . . . . . . . . > (
> . . . . . . . . . . . . . . > select (case when (false) then null else 
> cast('2016/09/22' as date) end) res1
> . . . . . . . . . . . . . . > from (values(1)) foo
> . . . . . . . . . . . . . . > ) foobar;
> ++
> |  res2  |
> ++
> | false  |
> ++
> 1 row selected (0.166 seconds)
> {noformat}



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