[
https://issues.apache.org/jira/browse/BEAM-12484?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anant Damle updated BEAM-12484:
-------------------------------
Component/s: (was: sdk-java-core)
io-java-jdbc
Description:
Time handling varies between OSes:
for e.g.
{code:java}
// DB Init script
CREATE TABLE SimpleFlatRecords
(
id INTEGER AUTO_INCREMENT PRIMARY KEY,
birth_date DATE
);
INSERT INTO SimpleFlatRecords(id, birth_date)
VALUES (1, '2000-05-11'),
(2, '2001-06-12'),
(3, '2002-07-13');{code}
The Beam Row contains different dates based on OS:
MacOS:
1: '2000-05-10'
2: '2001-06-11'
3: '2002-07-12'
Linux:
1: '2000-05-11'
2: '2001-06-12'
3: '2002-07-13'
was:
Joda Time handling varies between OSes:
Fix by using `java.util.time` in `AvroUtils`
{code:java}
@Test
public void jodaDaysDiff() {
var days = org.joda.time.Days.daysBetween(org.joda.time.Instant.EPOCH,
org.joda.time.Instant.parse("2002-07-13")).getDays();
// Linux: fail // actual = 11880
// MacOS: pass
assertThat(days).isEqualTo(11881);
}
@Test
public void javaTimeDaysDiff() {
var date = java.time.Instant.parse("2002-07-13T00:00:00Z");
var days =
java.time.temporal.ChronoUnit.DAYS.between(java.time.Instant.EPOCH, date);
// Linux: pass
// MacOS: pass
assertThat(days).isEqualTo(11881);
}
{code}
> Issue with handling of logicalType Date in Avro Conversion
> ----------------------------------------------------------
>
> Key: BEAM-12484
> URL: https://issues.apache.org/jira/browse/BEAM-12484
> Project: Beam
> Issue Type: Bug
> Components: io-java-jdbc
> Affects Versions: 2.30.0
> Reporter: Anant Damle
> Assignee: Anant Damle
> Priority: P2
>
> Time handling varies between OSes:
> for e.g.
> {code:java}
> // DB Init script
> CREATE TABLE SimpleFlatRecords
> (
> id INTEGER AUTO_INCREMENT PRIMARY KEY,
> birth_date DATE
> );
> INSERT INTO SimpleFlatRecords(id, birth_date)
> VALUES (1, '2000-05-11'),
> (2, '2001-06-12'),
> (3, '2002-07-13');{code}
> The Beam Row contains different dates based on OS:
> MacOS:
> 1: '2000-05-10'
> 2: '2001-06-11'
> 3: '2002-07-12'
> Linux:
> 1: '2000-05-11'
> 2: '2001-06-12'
> 3: '2002-07-13'
--
This message was sent by Atlassian Jira
(v8.3.4#803005)