Skip to content

Commit 0941b56

Browse files
authored
Merge pull request #825 from quixoten/dc/bq-datetime-err
try an additional format to parse bq timestamps
2 parents 0f0b835 + 4c317b4 commit 0941b56

File tree

1 file changed

+6
-3
lines changed
  • connectorx/src/sources/bigquery

1 file changed

+6
-3
lines changed

connectorx/src/sources/bigquery/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ impl<'r, 'a> Produce<'r, NaiveDateTime> for BigQuerySourceParser {
768768
.as_str()
769769
.ok_or_else(|| anyhow!("cannot get str from json value"))?;
770770
NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S")
771+
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S%.f"))
771772
.map_err(|_| ConnectorXError::cannot_produce::<NaiveDateTime>(Some(s.into())))?
772773
}
773774
}
@@ -838,9 +839,11 @@ impl<'r, 'a> Produce<'r, Option<NaiveDateTime>> for BigQuerySourceParser {
838839
.as_str()
839840
.ok_or_else(|| anyhow!("cannot get str from json value"))?;
840841
Some(
841-
NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S").map_err(|_| {
842-
ConnectorXError::cannot_produce::<NaiveDateTime>(Some(s.into()))
843-
})?,
842+
NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S")
843+
.or_else(|_| NaiveDateTime::parse_from_str(s, "%Y-%m-%dT%H:%M:%S%.f"))
844+
.map_err(|_| {
845+
ConnectorXError::cannot_produce::<NaiveDateTime>(Some(s.into()))
846+
})?,
844847
)
845848
}
846849
}

0 commit comments

Comments
 (0)