try_parse_debezium_geometry_as_bytea

Function try_parse_debezium_geometry_as_bytea 

Source
fn try_parse_debezium_geometry_as_bytea(
    value: &BorrowedValue<'_>,
    create_error: impl Fn() -> AccessError,
) -> AccessResult<Option<Box<[u8]>>>
Expand description

Try to parse Debezium PostGIS geometry object.

Debezium represents PostGIS geometry as an object: {"srid": <int>, "wkb": <base64_string>}. For our current Postgres CDC ingestion, the wkb field is expected to be EWKB bytes (base64-encoded), and srid is redundant. We decode wkb into raw bytes and store it as bytea.

Note: Debezium provides an SMT to convert between WKB and EWKB, which may be useful for future unification across connectors (e.g., MySQL): see GeometryFormatTransformer.

Return semantics:

  • Ok(Some(bytes)): The input matches the Debezium geometry shape (srid is numeric AND wkb is string), and we successfully decoded wkb into bytes.
  • Ok(None): The input does NOT look like a Debezium geometry object. This allows the caller to keep the match arm focused on dispatching, and avoids misclassifying other JSON objects that might map to bytea in the future.
  • Err(...): The input looks like a Debezium geometry object, but decoding/parsing failed (e.g. invalid base64). This indicates a real data/format error and should not be silently ignored.