Skip to content

Commit

Permalink
Add support for exporting null timestamp
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 364932785
  • Loading branch information
cloud-teleport committed Mar 25, 2021
1 parent c8c5b15 commit 136fded
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ public GenericRecord convert(Struct row) {
break;
case LONG:
if (spannerType.equals("TIMESTAMP")) {
Timestamp ts = row.getTimestamp(fieldName);
long microSeconds = TimeUnit.SECONDS.toMicros(ts.getSeconds())
+ TimeUnit.NANOSECONDS.toMicros(ts.getNanos());
long microSeconds=0L;
if (!nullValue) {
Timestamp ts = row.getTimestamp(fieldName);
microSeconds = TimeUnit.SECONDS.toMicros(ts.getSeconds())
+ TimeUnit.NANOSECONDS.toMicros(ts.getNanos());
}
builder.set(field, nullValue ? null : microSeconds);
} else {
builder.set(field, nullValue ? null : row.getLong(fieldName));
Expand Down

0 comments on commit 136fded

Please sign in to comment.