Skip to content

Commit

Permalink
SNOW-1196082: FIx inserting and reading timestamps not symetric if t…
Browse files Browse the repository at this point in the history
…oo much columns inserted with batch (#1794)
  • Loading branch information
sfc-gh-ext-simba-jy authored Jul 2, 2024
1 parent f39eff4 commit 3fee6f9
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,19 @@ private synchronized String synchronizedTimestampFormat(String o, String type) {
int nano = times.right;

Timestamp v1 = new Timestamp(sec * 1000);
ZoneOffset offsetId;
// For timestamp_ntz, use UTC timezone. For timestamp_ltz, use the local timezone to minimise
// the gap.
if ("TIMESTAMP_LTZ".equals(type)) {
TimeZone tz = TimeZone.getDefault();
cal.setTimeZone(tz);
cal.clear();
timestampFormat.setCalendar(cal);
offsetId = ZoneId.systemDefault().getRules().getOffset(Instant.ofEpochMilli(v1.getTime()));
} else {
offsetId = ZoneOffset.UTC;
}

ZoneOffset offsetId = ZoneId.systemDefault().getRules().getOffset(Instant.now());

return timestampFormat.format(v1) + String.format("%09d", nano) + " " + offsetId;
}

Expand Down
Loading

0 comments on commit 3fee6f9

Please sign in to comment.