[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-06-01 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16498657#comment-16498657
 ] 

ASF GitHub Bot commented on CALCITE-1884:
-

Github user asfgit closed the pull request at:

https://github.com/apache/calcite-avatica/pull/52


> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-06-01 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16498656#comment-16498656
 ] 

ASF GitHub Bot commented on CALCITE-1884:
-

Github user asfgit closed the pull request at:

https://github.com/apache/calcite-avatica/pull/11


> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-05-29 Thread Julian Hyde (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16494298#comment-16494298
 ] 

Julian Hyde commented on CALCITE-1884:
--

Might be the issue I just mailed the dev list about - it occurs on maven 3.5.2 
but not maven 3.5.3. Can you mention this on the dev list thread, please? Then 
someone will hopefully fix travis.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-05-29 Thread Sergey Nuyanzin (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16494292#comment-16494292
 ] 

Sergey Nuyanzin commented on CALCITE-1884:
--

[~julianhyde] thank you for your comment
just created a PR

however one [travis job failed 
|https://travis-ci.org/apache/calcite-avatica/builds/385394506] (others are ok) 
with timeout issue {noformat}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:javadoc (default-cli) on 
project avatica-parent: Execution default-cli of goal 
org.apache.maven.plugins:maven-javadoc-plugin:3.0.0:javadoc failed: Plugin 
org.apache.maven.plugins:maven-javadoc-plugin:3.0.0 or one of its dependencies 
could not be resolved: Could not transfer artifact 
org.apache.maven.shared:maven-artifact-transfer:jar:0.9.1 from/to central 
(https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 
[repo.maven.apache.org/151.101.44.215] failed: Connection timed out (Connection 
timed out) -> [Help 1]
{noformat}


I do not think it somehow relates to the changes

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-05-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16494261#comment-16494261
 ] 

ASF GitHub Bot commented on CALCITE-1884:
-

GitHub user snuyanzin opened a pull request:

https://github.com/apache/calcite-avatica/pull/52

CALCITE-1884 DateTimeUtils produces incorrect results for days before 
Gregorian cutovers

1. remove convertation to Gregorian in case of 
org.apache.calcite.avatica.util.DateTimeUtils#ymdToJulian
2. added tests 
3. corrected tests for CENTURY and MILLENNIUM as a side effect

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/snuyanzin/calcite-avatica CALCITE_1884

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/calcite-avatica/pull/52.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #52


commit 9943d1971cbfbb8a3dbaa843cf0e6d2ae8aad3b4
Author: snuyanzin 
Date:   2018-05-29T15:08:05Z

1) remove convertation to Gregorian in case of 
org.apache.calcite.avatica.util.DateTimeUtils#ymdToJulian
2) added tests




> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-05-29 Thread Julian Hyde (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16494186#comment-16494186
 ] 

Julian Hyde commented on CALCITE-1884:
--

[~Sergey Nuyanzin] Your changes look good. I am testing now.

Can you please create a PR at https://github.com/apache/calcite-avatica/pulls. 
ASF needs to know that you are willingly contributing the IP.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-05-29 Thread Sergey Nuyanzin (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16493701#comment-16493701
 ] 

Sergey Nuyanzin commented on CALCITE-1884:
--

hello
some observations:
there is a method _org.apache.calcite.avatica.util.DateTimeUtils#ymdToJulian_ 
which is trying to convert date to Gregorian if it before cutover. To behave 
like PostgreSQL this convertation could be removed then no other code changes 
are required. All the tests mentioned in this issue passed.
please have a look at 
https://github.com/apache/calcite-avatica/compare/master...snuyanzin:CALCITE_1884
 to see changes
If nobody minds I could push changes to the mentioned PR

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
> Fix For: avatica-1.12.0
>
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-02-27 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16379178#comment-16379178
 ] 

Julian Hyde commented on CALCITE-1884:
--

Freeze early next week if possible.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-02-26 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16377600#comment-16377600
 ] 

Haohui Mai commented on CALCITE-1884:
-

Still working on it, it should be available soon. How does the timeline look 
like for Avatica 1.11?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-02-26 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16377349#comment-16377349
 ] 

Julian Hyde commented on CALCITE-1884:
--

Any chance we could get this finished before Avatica 1.11?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-01-27 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16342050#comment-16342050
 ] 

Julian Hyde commented on CALCITE-1884:
--

I added the following to {{DateTimeUtilsTest.testDateToString}}.

{noformat}final int d1900 = -(70 * 365 + 70 / 4);
final int century = 100 * 365 + 100 / 4;
checkDateString("1900-01-01", d1900);
// +1 because 1800 is not a leap year
final int d1800 = d1900 - century + 1;
checkDateString("1800-01-01", d1800);
final int d1700 = d1800 - century + 1;
checkDateString("1700-01-01", d1700);
final int d1600 = d1700 - century;
checkDateString("1600-01-01", d1600);
final int d1500 = d1600 - century + 1;
checkDateString("1500-01-01", d1500); // fails, about 10 days off
{noformat}

It all succeeds except 1500-01-01, which is about 10 days off. It looks as if 
your code has a gap at the gregorian cutover, 1582-10-15. PostgreSQL does not 
have this gap, because it stays in "new style":

{noformat}
select date '1900-01-01' - 109573 * interval '1' day as d # returns 1600-01-01
select date '1900-01-01' - 115859 * interval '1' day as d # returns 1500-10-16
select date '1900-01-01' - 115860 * interval '1' day as d # returns 1500-10-15
select date '1900-01-01' - 115861 * interval '1' day as d # returns 1500-10-14
select date '1900-01-01' - 146097 * interval '1' day as d # returns 1500-01-01
{noformat}

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-01-26 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16341875#comment-16341875
 ] 

Haohui Mai commented on CALCITE-1884:
-

Definitely. What kinds of unit tests do you expect?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2018-01-26 Thread Timo Walther (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16340979#comment-16340979
 ] 

Timo Walther commented on CALCITE-1884:
---

[~wheat9] do you think you can find some time to finish this? It would be great 
if we can remove our copy in Flink (FLINK-7237).

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>Priority: Major
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



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


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-20 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16095573#comment-16095573
 ] 

Julian Hyde commented on CALCITE-1884:
--

What does Date.toString() print for the day before 1752-09-14? Are you seeing 
it print 1752-09-02? If so, then it's shifted into old-style. But it's still 
the day before 1752-09-14, its julian day number is one smaller, and frankly 
it's just a problem with how java prints it.

SQL, which stays in new style, would print 1752-09-13.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-20 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16095574#comment-16095574
 ] 

Julian Hyde commented on CALCITE-1884:
--

It would help a lot if you were to write some unit tests. Then we can discuss 
what those tests should produce.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-20 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16095201#comment-16095201
 ] 

Haohui Mai commented on CALCITE-1884:
-

bq. ... My proposal is that dateStringToUnixDate assumes that the date is in 
New Style, and that unixDateToString generates a date string in New Style ... 
old style doesn't enter into it. ...

That's what I have tried and unfortunately it did not work (on a broader 
picture).

See 
https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java#L1646
 for more details.





> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093907#comment-16093907
 ] 

Haohui Mai commented on CALCITE-1884:
-

I have verified that {{CAST(DATE '1752-09-20' - INTERVAL '10' DAY AS 
VARCHAR(10))}} returns {{1752-09-10}} in another project. Can you suggest how 
to add this as a unit test in avatica?

bq. If you want a function that is consistent with Java's internal 
representation of dates, maybe you need a new function. That was not the goal 
of this function.

I think there is some misunderstanding here. It is the approach but not the 
goal of the PR.

This PR proposes to represent all the dates internally in Julian day that also 
considers both the old and the new styles (which happens to be consistent with 
Java representation). All users externally will only see the "new-style" dates. 
Does it make sense to you?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093829#comment-16093829
 ] 

Julian Hyde commented on CALCITE-1884:
--

It's difficult to make claims about the behavior of java.sql.Date because a lot 
of operations (e.g. extracting days of the week, converting to a string) occur 
in the context of a calendar, usually GregorialCalendar, and/or a locale.

One can run a SQL query, convert the results to a string, and examine the 
results in a context where no Java is involved. The SQL standard is written in 
those terms. As I said in CALCITE-1832, It follows from the SQL standard that 
{{CAST(DATE '1752-09-20' - INTERVAL '10' DAY AS VARCHAR(10))}} should return 
the string '1752-09-10'. I think your change breaks that.

If you want a function that is consistent with Java's internal representation 
of dates, maybe you need a new function. That was not the goal of this function.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093810#comment-16093810
 ] 

Haohui Mai commented on CALCITE-1884:
-

The PR did change the tests in DateTimeUtilTests as now it produces results 
without the rounding errors. Other existing tests should cover other cases. Do 
you have any other tests that you have in mind might be beneficial?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093796#comment-16093796
 ] 

Julian Hyde commented on CALCITE-1884:
--

I assume your PR intends to change the specification. If so why are there no 
new tests?

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Haohui Mai (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093787#comment-16093787
 ] 

Haohui Mai commented on CALCITE-1884:
-

It turns out that this is more complicated that just switching everything to 
the "new style" internally, because {{java.sql.Date}} / {{java.Date}} actually 
uses the "old styles" and handles the dates before the cutovers. The cleaner 
fix is to just implement the required algorithm to handle all these cases 
gracefully.

Please take a look at the PR. Comments are appreciated.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093780#comment-16093780
 ] 

ASF GitHub Bot commented on CALCITE-1884:
-

GitHub user haohui opened a pull request:

https://github.com/apache/calcite-avatica/pull/11

[CALCITE-1884] DateTimeUtils produces incorrect results for days before the 
Gregorian cutovers

This PR augments the supports of Julian days that are before the Gregorian 
cutovers in DateTimeUtils.

It implements the algorithm from the book "Astronomical Algorithms" by Jean 
Meeus, 1998.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/haohui/calcite-avatica CALCITE-1884

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/calcite-avatica/pull/11.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #11


commit a62c3108eb4cb1474c8540104744c44e34ccf66d
Author: Haohui Mai 
Date:   2017-07-19T20:51:51Z

[CALCITE-1884] DateTimeUtils produces incorrect results for days before 
Gregorian cutovers.




> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (CALCITE-1884) DateTimeUtils produces incorrect results for days before Gregorian cutovers

2017-07-19 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16093779#comment-16093779
 ] 

Julian Hyde commented on CALCITE-1884:
--

You've now made this bug a duplicate of CALCITE-1832, which I recently closed 
as not-a-bug because it is intended behavior.

> DateTimeUtils produces incorrect results for days before Gregorian cutovers
> ---
>
> Key: CALCITE-1884
> URL: https://issues.apache.org/jira/browse/CALCITE-1884
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Affects Versions: 1.13.0
>Reporter: Haohui Mai
>Assignee: Haohui Mai
>
> dateStringToUnixDate() / unixDateToString() do not return consistent result.
> The following test fails:
> {noformat}
>   @Test public void testUnixDate() {
> int days = DateTimeUtils.dateStringToUnixDate("1500-04-30");
> assertEquals("1500-04-30", DateTimeUtils.unixDateToString(days));
>   }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)