Skip to content

Commit

Permalink
fix(sink): json timestamptz should contain UTC suffix Z
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu committed Oct 27, 2023
1 parent 23b69c4 commit 55fcf52
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/connector/src/sink/encoder/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ fn datum_to_json_object(
(DataType::Timestamptz, ScalarRefImpl::Timestamptz(v)) => {
// risingwave's timestamp with timezone is stored in UTC and does not maintain the
// timezone info and the time is in microsecond.
let parsed = v.to_datetime_utc().naive_utc();
let v = parsed.format("%Y-%m-%d %H:%M:%S%.6f").to_string();
let parsed = v.to_datetime_utc();
let v = parsed.to_rfc3339_opts(chrono::SecondsFormat::Micros, true);
json!(v)
}
(DataType::Time, ScalarRefImpl::Time(v)) => {
Expand Down Expand Up @@ -429,7 +429,7 @@ mod tests {
&CustomJsonType::None,
)
.unwrap();
assert_eq!(tstz_value, "2018-01-26 18:30:09.453000");
assert_eq!(tstz_value, "2018-01-26T18:30:09.453000Z");

let ts_value = datum_to_json_object(
&Field {
Expand Down

0 comments on commit 55fcf52

Please sign in to comment.