Expand description
Shared type-mapping vocabulary across formats and storage targets.
Decode-side (source format -> Arrow/PgType):
pg_type::PgType: a PostgreSQL-facing type bridging Arrow, decoded JSON values, and SQL DDL text - the common ground across the Protobuf/Avro/JSON decode paths.identifiers: SQL identifier validation/quoting.json_arrow: basic (schemaless) JSON -> Arrow type inference.json_schema: JSON Schema document ($schema/type/format) ->PgType, distinct fromjson_arrow(which infers from an already-decoded value, not a schema document).avro(featureavro): Avro schema -> Arrow type mapping.
Protobuf’s Arrow-type derivation lives in the separate twg-proto-schema
crate (it needs descriptor-tree traversal that doesn’t belong here) -
this crate doesn’t re-export it to avoid a dependency both ways; use
both crates together if you need Protobuf and Postgres/Avro/JSON type
mapping in the same place.
Storage-target side (Arrow/PgType -> a table/wire format’s own type system):
delta::DeltaType: Delta Lake’s schema type system - built from the public Delta protocol spec.iceberg::IcebergType: Apache Iceberg’s schema type system (field IDs are NOT assigned here - that’s a schema-evolution concern for the caller, not a type-mapping one; see the module doc comment) - also built from the public Iceberg spec.zerobus_sink::ProtoFieldType: the sink-direction type system for building OUTGOING protobuf descriptors - deliberately a much smaller, coarser 7-variant type set thanPgType, with its own widening rules and Delta/Unity Catalog type-name mappings. Does NOT carry any fixed metadata-column table: that is a specific application’s column contract, not generic type-mapping vocabulary, and belongs in the calling application instead.
delta/iceberg bridge through Arrow (reusing PgType’s existing
Arrow bridge as the hub) rather than hand-rolling separate PgType-to-X
logic; zerobus_sink::ProtoFieldType is its own independent type
system, not re-derived through the hub, because the sink’s coarser
vocabulary does not map cleanly onto it.
Re-exports§
pub use pg_type::PgType;
Modules§
- avro
- Avro schema -> Arrow schema mapping. Feature-gated behind
avrosince it pulls inapache-avro. - delta
- Delta Lake’s schema type system, per the public Delta Transaction Log
Protocol spec (
PROTOCOL.md#primitive-types/#struct-field). This is a documented, versioned open format, so this mapping is built directly from the spec. - iceberg
- Apache Iceberg’s schema type system, per the public format spec
(
https://iceberg.apache.org/spec/#schemas-and-data-types) - a documented, versioned open format, built directly from the spec. - identifiers
- SQL identifier validation and quoting.
- json_
arrow - Basic JSON value -> Arrow type inference. Deliberately simpler than
crate::pg_type::PgType::from_json_value- this is for a schemaless JSON-to-Arrow decode path (no string sniffing for UUID/timestamp/date; arrays, objects, and null all collapse toUtf8), not the richer SQL-facing inferencePgTypedoes. The two serve different purposes and are not duplicates to reconcile. - json_
schema - Maps a JSON Schema document (the declarative
$schema/type/formatformat, e.g. from a schema registry) tocrate::pg_type::PgType. Distinct fromcrate::pg_type::PgType::from_json_value, which infers from an already-decoded value instead of a schema document. - pg_type
PgType: aPostgreSQL-facing type that bridges Arrow, JSON values, and SQL DDL text - the shared type-mapping vocabulary used across Protobuf/Avro/JSON decode paths.from_arrow_type/to_arrow_typeare inverses of each other (mostly - Arrow has strictly more scalar variants than Postgres, sofrom_arrow_typeis lossy in the narrowing direction by design), andfrom_json_valuegives type inference straight from a decodedserde_json::Value(used when a source format’s own schema doesn’t give you a type directly, e.g. schemaless JSON payloads).- zerobus_
sink ProtoFieldType: the SINK-direction type system - building outgoing protobuf descriptors (e.g. for a Zerobus-style ingest wire protocol), as opposed totwg-proto-schema’s decode-direction mapping (an INCOMING protobuf descriptor -> Arrow).