Skip to content

Commit b2ca86b

Browse files
mjgartonsunng87
authored andcommitted
Fix mapping from NaiveDate to Date32
Date32 is the number of seconds from the unix epoch, not from CE in the gregorian calendar.
1 parent 9a81f17 commit b2ca86b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

datafusion-postgres/src/datatypes.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::iter;
22
use std::str::FromStr;
33
use std::sync::Arc;
44

5-
use chrono::{DateTime, Datelike, FixedOffset, TimeZone, Utc};
5+
use chrono::{DateTime, FixedOffset, TimeZone, Utc};
66
use chrono::{NaiveDate, NaiveDateTime};
77
use datafusion::arrow::array::*;
88
use datafusion::arrow::datatypes::*;
@@ -784,9 +784,8 @@ where
784784
}
785785
Type::DATE => {
786786
let value = portal.parameter::<NaiveDate>(i, &pg_type)?;
787-
deserialized_params.push(ScalarValue::Date32(
788-
value.map(|date| date.num_days_from_ce()),
789-
));
787+
deserialized_params
788+
.push(ScalarValue::Date32(value.map(Date32Type::from_naive_date)));
790789
}
791790
// TODO: add more types
792791
_ => {

0 commit comments

Comments
 (0)