<#2754 bug: UUID incremental replication keys cann...
# meltano-repo-activity
g
#2754 bug: UUID incremental replication keys cannot be compared with UUID-strings coming from the state Issue created by edgarrmondragon Singer SDK Version 0.41.0 Is this a regression? • Yes Python Version NA Bug scope Taps (catalog, state, etc.) Operating System NA Description When a SQL tap defines a UUID column as a replication key, the step where the value coming from the record and the value coming from the state dictionary are compared to increment the bookmark crashes because the
>=
operation is not supported between a `uuid.UUID`1 instance and a string. We can fix by simply adding a branch to sdk/singer_sdk/helpers/_typing.py Lines 40 to 45 in</meltano/sdk/commit/ae7516b8a16d625c05258570c74e242f1cf64e88|ae7516b> | def to_json_compatible(val: t.Any) -> t.Any: # noqa: ANN401 | | -------------------------------------------------------------------------------- | | """Return as string if datetime. JSON does not support proper datetime types.""" | | if isinstance(val, (datetime.datetime,)): | | # Make naive datetimes UTC | | return (val.replace(tzinfo=UTC) if val.tzinfo is None else val).isoformat("T") | | return val | that checks for an instance of
uuid.UUID
and returns the stringified value. The resulting string-to-string comparison should be safe down to the millisecond. Note This may be only be an issue in a very narrow set of use cases, in particular where the experimental sortable UUID Version 72 is enabled via database extensions, such as `pg_uuidv7`3. Related: • MeltanoLabs/tap-postgres#519 • #2753 Link to Slack/Linen No response Footnotes 1. https://docs.python.org/3/library/uuid.html#uuid.UUID ↩️ 2. https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7 ↩️ 3. https://github.com/craigpastro/pg_uuidv7 ↩️ meltano/sdk