Class LogicalTypeConversion
java.lang.Object
io.confluent.kafka.schemaregistry.type.logical.LogicalTypeConversion
Converts a logical types DDL script into the native schema it denotes.
Shared by everything that reads DDL, so that a script means the same thing wherever it is
read -- in the registry, which converts a submitted body before storing it, and in a
LogicalSchemaProvider, which converts one while parsing. Callers differ only in where
they resolve references and what they do with the result, so those stay with them; everything
that decides what the script means lives here.
Parsing and conversion are separate calls because a caller classifies a body before converting it, and splitting them lets it do both from a single parse.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDerives the name given to a converted root that the script leaves anonymous.static ParsedSchematoNative(LogicalTypesParser.ScriptContext script, Schema schema, Map<String, String> resolvedReferences) Converts an already-parsed script into the native schema forschema's type, named after its subject and carrying its metadata, rule set and references.Parsestextas a DDL script, or returns empty if it is not one.
-
Method Details
-
tryParse
Parsestextas a DDL script, or returns empty if it is not one.This decides only the form of the body. A script that parses but is semantically invalid is still DDL, and says so when converted.
-
toNative
public static ParsedSchema toNative(LogicalTypesParser.ScriptContext script, Schema schema, Map<String, String> resolvedReferences) Converts an already-parsed script into the native schema forschema's type, named after its subject and carrying its metadata, rule set and references.- Parameters:
script- the parsed script, fromtryParse(String)schema- what was submitted: its subject names the converted root, and its schema type decides the target formatresolvedReferences- the schema's references resolved to their definitions, which the caller looks up however it can- Throws:
ValidationException- if the script is not a valid logical type, or cannot be represented in the requested format
-
rowName
Derives the name given to a converted root that the script leaves anonymous. A script that names its root uses that name instead, so this applies only to a bareSTRUCT.
-