Skip to content

[Bug]: ISODate serialization truncates millisecond precision #3308

@pilis

Description

@pilis

Related Template(s)

mongodb_to_bigquery

Template Version

2026-02-03-00_rc01

What happened?

I have MongoDB to BigQuery dataflow job.

When there are ISODate (example: ISODate('2026-02-03T15:31:41.924Z')) in Mongo documents, then in BigQuery those appear in descriptive (long) format like "Feb 3, 2026, 3:31:41 PM".

This error is related to how "Read Documents" transforms MongoDB Documents to JSON here: https://github.com/GoogleCloudPlatform/DataflowTemplates/blob/main/v2/mongodb-to-googlecloud/src/main/java/com/google/cloud/teleport/v2/transforms/JavascriptDocumentTransformer.java#L150

By default it uses Relaxed JSON mode: https://github.com/mongodb/mongo-java-driver/blob/main/bson/src/main/org/bson/Document.java#L418

Gemini suggested that:

If JsonWriterSettings aren't explicitly forced to ISO-8601, the MongoDB Java driver defaults to "Relaxed" mode. In this mode, it uses the JVM's default Locale to stringify dates.
Locale.US produces: Feb 3, 2026, 3:31:41 PM
ISO Standard would be: 2026-02-03T15:31:41.924Z

Could someone take a look at this?

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions