-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle native types for joined queries
- Loading branch information
Showing
12 changed files
with
526 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use bigdecimal::{BigDecimal, ParseBigDecimalError}; | ||
use chrono::*; | ||
use std::str::FromStr; | ||
|
||
pub(crate) fn parse_date(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
chrono::NaiveDate::parse_from_str(str, "%Y-%m-%d") | ||
.map(|date| DateTime::<Utc>::from_utc(date.and_hms_opt(0, 0, 0).unwrap(), Utc)) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_timestamptz(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
DateTime::parse_from_rfc3339(str) | ||
} | ||
|
||
pub(crate) fn parse_timestamp(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
NaiveDateTime::parse_from_str(str, "%Y-%m-%dT%H:%M:%S%.f") | ||
.map(|dt| DateTime::from_utc(dt, Utc)) | ||
.or_else(|_| DateTime::parse_from_rfc3339(str).map(DateTime::<Utc>::from)) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_time(str: &str) -> Result<DateTime<FixedOffset>, chrono::ParseError> { | ||
chrono::NaiveTime::parse_from_str(str, "%H:%M:%S%.f") | ||
.map(|time| { | ||
let base_date = chrono::NaiveDate::from_ymd_opt(1970, 1, 1).unwrap(); | ||
|
||
DateTime::<Utc>::from_utc(base_date.and_time(time), Utc) | ||
}) | ||
.map(DateTime::<FixedOffset>::from) | ||
} | ||
|
||
pub(crate) fn parse_money(str: &str) -> Result<BigDecimal, ParseBigDecimalError> { | ||
// We strip out the currency sign from the string. | ||
BigDecimal::from_str(&str[1..]).map(|bd| bd.normalized()) | ||
} | ||
|
||
pub(crate) fn parse_decimal(str: &str) -> Result<BigDecimal, ParseBigDecimalError> { | ||
BigDecimal::from_str(str).map(|bd| bd.normalized()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ mod enum_type; | |
mod float; | ||
mod int; | ||
mod json; | ||
mod native; | ||
mod string; | ||
mod through_relation; |
1 change: 1 addition & 0 deletions
1
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/native/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod postgres; |
Oops, something went wrong.