Class LogicalType
Schema.Field; a path-keyed mirror is also exposed via
getDefaultValues() for callers that need positional access (e.g.,
Connect-style serialization).
Default-value path semantics (matching the Flink converters):
the key is a list of indices that walks from the root into the field.
For STRUCT(a INT, b STRUCT(b1 STRING)), a's default is at
[0] and b.b1's is at [1, 0]. ARRAY elements use
index 0; MAP key/value use 0/1.
-
Constructor Summary
ConstructorsConstructorDescriptionLogicalType(Schema rootSchema) LogicalType(Schema rootSchema, Map<String, Schema> namedTypes) LogicalType(Schema rootSchema, Map<String, Schema> namedTypes, List<SchemaReference> references, Map<String, String> resolvedReferences) LogicalType(String namespace, Schema rootSchema, Map<String, Schema> namedTypes, List<SchemaReference> references, Map<String, String> resolvedReferences) LogicalType(String namespace, Schema rootSchema, Map<String, Schema> namedTypes, List<SchemaReference> references, Map<String, String> resolvedReferences, Map<List<Integer>, Object> defaultValues) LogicalType(String namespace, Schema rootSchema, Map<String, Schema> namedTypes, Set<String> externalTypes, List<SchemaReference> references, Map<String, String> resolvedReferences, Map<List<Integer>, Object> defaultValues) LogicalType(String namespace, Schema rootSchema, Map<String, Schema> namedTypes, Set<String> externalTypes, Map<String, String> externalImports, List<SchemaReference> references, Map<String, String> resolvedReferences, Map<List<Integer>, Object> defaultValues) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcollectNamedRefs(Schema schema, Set<String> sink) Walkschemaand collect the qualified names of everyNAMED_TYPE_REFencountered.booleanNames of locally-defined types that are not reachable from the root via the named-type-ref graph.Path-keyed map of field-default values collected during conversion.Per-FQN binding from a synthetic-wrapper external typeName to the original$refURI it stands in for.FQNs innamedTypeswhose body originated from an external schema (an entry inresolvedReferences) rather than from a locally- defined type.Subset ofgetNamedTypes()that are NOT ingetExternalTypes()— the entries the user authored locally.Locally-defined named types, keyed by their qualified name.The document-level namespace, or null if none.inthashCode()booleanTrue ifffqnis part of a cycle in the named-type-ref graph formed bynamedTypes— i.e., a self-reference or mutual recursion through other peers.static booleanStatic form ofisCyclic(String)for use during conversion when a builder map is being populated and theLogicalTypeinstance does not yet exist.booleanisExternal(String fqn) True ifffqnis a key ingetExternalTypes().booleanReturns true ifkeyrepresents a nested type — i.e.Group named types by parent.Returns the parent named-type key ofkeyunder the dotted-path nesting convention, ornullifkeyis top-level.static StringStatic form ofparentOf(String)for use during validation before aLogicalTypeinstance exists (e.g., inside the visitor).topLevelAncestor(String key) Walks parent links viaparentOf(java.lang.String)until reaching a top-level type.toString()
-
Constructor Details
-
LogicalType
-
LogicalType
-
LogicalType
-
LogicalType
-
LogicalType
-
LogicalType
-
LogicalType
-
-
Method Details
-
getRootSchema
-
getNamedTypes
Locally-defined named types, keyed by their qualified name.Nesting convention: a key like
Outer.InnerwhereOuteris also a key in this map indicates thatInneris nested insideOuter. The dot acts as the nesting separator. When a key has dots but no prefix matches another key, the dots are interpreted as a namespace prefix and the type is top-level. SeeparentOf(java.lang.String)andnestingTree()for accessors that interpret the convention.Only the Protobuf writer emits the nesting structurally (as proto's native nested messages). Avro and JSON Schema emit dotted-name types as flat top-level entries (their full names just contain dots).
-
getExternalTypes
FQNs innamedTypeswhose body originated from an external schema (an entry inresolvedReferences) rather than from a locally- defined type. Writers use this set to decide whether to re-emit the type as an inline definition (for entries NOT in this set) or as an import /$ref(for entries IN this set).The set is populated by readers when they lazily promote external bodies into
namedTypes, and by the DDL visitor by inferring external-ness from usage (anyNAMED_TYPE_REFFQN not declared locally). -
isExternal
True ifffqnis a key ingetExternalTypes(). -
getExternalImports
Per-FQN binding from a synthetic-wrapper external typeName to the original$refURI it stands in for. Populated by the JSON reader when it synthesizesRef<N>-style names for non-canonical $refs (whole-doc, arbitrary JSON Pointers, and other shapes that don't extract cleanly to a$defskey), and by the DDL visitor when it parsesUSING TYPE x FOR '<uri>'statements.The JSON writer consults this map to emit those externals as a local
#/$defs/<name>reference whose body is a single{"$ref": "<uri>", "logical.ref": true}passthrough — keeping the indirection scoped to the active document instead of requiring a separately-published wrapper subject. Empty for LT-canonical workspaces.Avro and Proto writers reject any LT carrying entries here: synthetic wrappers are JSON-specific (the URI-vs-name impedance only exists for JSON's $ref model). Use a fresh, format-appropriate LT instead.
Independence from
getReferences().externalImportscarries wire-format binding (typeName → URI used in$ref); thereferenceslist carries SR coordinates (subject + version used by the SR client to fetch external content). They are populated independently — DDL'sUSING TYPEpopulatesexternalImportsbut never the references list. To produce an SR-publishable LT from DDL, attach areferenceslist (with matchingresolvedReferencescontent) separately after the visitor runs. -
getLocalNamedTypes
Subset ofgetNamedTypes()that are NOT ingetExternalTypes()— the entries the user authored locally. Writers use this accessor to iterate "the local stuff to inline-emit" without re-emitting external bodies that should appear as imports. -
getReferences
-
getResolvedReferences
-
getNamespace
The document-level namespace, or null if none. -
findOrphanNamedTypes
Names of locally-defined types that are not reachable from the root via the named-type-ref graph. These are dropped by single-root encoders such as Avro; multi-root encoders (Protobuf top-level messages, JSON $defs) may still emit them. -
parentOf
Returns the parent named-type key ofkeyunder the dotted-path nesting convention, ornullifkeyis top-level.The parent is the longest dotted prefix of
keythat itself exists innamedTypes. Example: with named typesOuterandOuter.Inner,parentOf("Outer.Inner")returns"Outer";parentOf("Outer")returnsnull(no matching prefix → top-level).Dots that do not correspond to a defined parent are namespace dots (top-level). So
parentOf("com.example.Foo")with nocom.exampletype defined returnsnull— the dots are just the namespace prefix. -
parentOf
Static form ofparentOf(String)for use during validation before aLogicalTypeinstance exists (e.g., inside the visitor). -
topLevelAncestor
Walks parent links viaparentOf(java.lang.String)until reaching a top-level type. Returnskeyitself ifkeyis already top-level. -
isNested
Returns true ifkeyrepresents a nested type — i.e. it has a parent innamedTypesper the dotted-path convention. -
nestingTree
Group named types by parent. The map keys cover every entry ofnamedTypes; the values are the immediate children (one nesting level deep). Top-level types appear under thenullparent.Used by writers that emit nesting natively (Protobuf): walk the entry for
null(top-level messages), then recursively walk each child's entry to nest its children inside. -
collectNamedRefs
Walkschemaand collect the qualified names of everyNAMED_TYPE_REFencountered. Recurses through structural composites (struct, union, array, multiset, map) but does not follow the named-type-ref itself — callers do that vianamedTypes. -
isCyclic
True ifffqnis part of a cycle in the named-type-ref graph formed bynamedTypes— i.e., a self-reference or mutual recursion through other peers. -
isCyclic
Static form ofisCyclic(String)for use during conversion when a builder map is being populated and theLogicalTypeinstance does not yet exist. -
getDefaultValues
Path-keyed map of field-default values collected during conversion.Each key is a list of zero-based indices that walks from the root schema into the field carrying the default. Each container type contributes indices to the path according to a fixed convention:
- STRUCT: the field's positional index. A struct with three
fields contributes
0,1, or2for its first, second, or third field respectively. - MAP:
0for the key type,1for the value type. - MULTISET:
0for the element type. - ARRAY: format-dependent. The Avro reader contributes
0for the element type; the Proto and JSON readers contribute no index (descending into the element type uses the parent path directly). See each*ToLogicalTypeConverter's class-level Javadoc for the format-specific rule. (TODO: unify across formats.) - Wrapper structs (proto
_RepeatedWrapper,_ElementWrapper,_OneofWrappermarked withflink.wrapped=true) are transparent: they contribute no index — descending into the wrapped payload uses the parent path. This keeps default-value paths aligned with the structure of the returned schema (which doesn't surface the wrapper layer). - Leaf types (primitives, enum, named-type-ref) carry the value and do not extend the path.
Worked examples (assuming the root is a STRUCT):
STRUCT { a: INT (default 1) } → { [0] = 1 } STRUCT { a: INT, m: MAP<STRING, INT> (key default "k", value default 5) } → { [1, 0] = "k", [1, 1] = 5 } STRUCT { nested: STRUCT { value: STRUCT { a: INT (default 17), b: INT (default 18) } } } → { [0, 0, 0] = 17, [0, 0, 1] = 18 } STRUCT { arr: ARRAY<STRUCT { value: STRUCT { a: INT (default 17), b: INT (default 18) } }> } → Proto: { [0, 0, 0] = 17, [0, 0, 1] = 18 } // ARRAY adds no index → Avro/JSON: { [0, 0, 0, 0] = 17, [0, 0, 0, 1] = 18 } // ARRAY adds [0] STRUCT { wrappedMap: MAP<BIGINT, BIGINT> (proto-wrapped, key default 15, value default 16) } → { [0, 0] = 15, [0, 1] = 16 } // wrapper is transparent; just MAP key/value - STRUCT: the field's positional index. A struct with three
fields contributes
-
equals
-
hashCode
public int hashCode() -
toString
-