Area: Ingestion Issues
Sub-Area: Kafka Ingestion / Schema Registry / Schema Parsing
Applies to: OSS + Cloud
Issue
After Kafka ingestion, some topics appear in DataHub with no schema. The ingestion report shows one of these warnings for the affected topics:
Unable to find a matching subject name for the topic in the schema registryFailed to get subject schema from schema registry-
Failed to retrieve schema for topic(with the messageTopic will be treated as schemaless.) Protobuf schema produced no fieldsAll sampled messages for topic failed to decode; it will be treated as schemalessSampled messages for topic but inferred no fields; treating it as schemaless
For Protobuf topics, the log can also show Failed to compile protobuf schema <name>, returning empty fields or Failed to compile protobuf schema <name>: <error>.
You Might Be Asking
- Why do some of my Kafka topics show up in DataHub without a schema?
- Does DataHub read messages from a topic to build a schema when the topic has no schema registry subject?
- What happens if the messages in a topic have different shapes?
- Why does my Protobuf topic fail on imports like
google/type/date.proto? - I see a recursion error during Kafka ingestion. Is that why the schema is missing?
Cause
The Kafka source gets each topic's schema from the schema registry. A topic has no schema in DataHub when one of these happens:
- The registry has no subject that matches the topic. By default the source looks for
<topic>-valueand<topic>-key(TopicNameStrategy). If your producers use RecordNameStrategy, the subject names don't match the topic name. - The registry returns a schema, but DataHub can't parse it. The source catches the error, reports it, and treats the topic as schemaless.
- A Protobuf schema imports a
.protofile that DataHub can't find. DataHub reads imported files from the schema's references in the registry. The Kafka source has no setting for a local protoc include path. - A Protobuf schema defines a message type that another topic already compiled in the same ingestion run. The second schema compiles to no fields.
DataHub doesn't read messages from the topic to build a schema unless you turn on schema_resolution. It's off by default.
Solution
-
Run a test recipe for only the failing topics.
Create a separate recipe that targets the affected topics. Note that
consumer_configgoes underconnection. Leavestateful_ingestionandprofilingout of this test recipe, so the test run doesn't touch your main pipeline's state. See Recipes and the DataHub sink.source: type: kafka config: connection: bootstrap: "<broker-host>:9092" schema_registry_url: "http://<schema-registry-host>:8081" consumer_config: security.protocol: SSL topic_patterns: allow: - "^<failing-topic-name>$" sink: type: datahub-rest config: server: "<your-datahub-gms-url>" token: "<your-access-token>"topic_patterns.allowtakes regular expressions. Run it with debug logging and read the warnings for the topic:datahub --debug ingest -c kafka-test.yml -
If the report says
Unable to find a matching subject name for the topic in the schema registry.The registry has no
<topic>-valuesubject for the topic. Check which case you're in:-
The schema is registered under a different subject name, for example because producers use RecordNameStrategy. Map the topic to its subjects with
topic_subject_map:source: type: kafka config: topic_subject_map: "<topic-name>-value": "<value-subject-name>" "<topic-name>-key": "<key-subject-name>" -
The topic has no schema in the registry at all. Register the schema in your schema registry. DataHub then reads it on the next run.
-
You want DataHub to work out the schema without a registry entry. Turn on schema resolution. It's available in acryl-datahub 1.7.0 and later:
source: type: kafka config: schema_resolution: enabled: trueWith this on, DataHub first tries other subject naming strategies (your
topic_subject_map, RecordNameStrategy, TopicRecordNameStrategy). If none of them finds a subject, DataHub samples messages from the topic and infers the fields. See Schema Resolution.Inference merges every field it sees across all sampled messages. Messages with different shapes still produce a schema. A field that holds values of different types gets one type, picked in this order: double, long, boolean, array, then string. For example, a field seen as both a string and an integer becomes
long. The topic stays schemaless when no message arrives withinsample_timeout_seconds(default 2 seconds), when every sampled message fails to decode, or when the sampled messages yield no fields.offset_reset_strategycontrols where sampling starts:hybrid(the default) reads recent messages first and falls back to the start of the topic.Schema resolution runs for topics that have no schema object and no fields. This includes topics where the subject fetch failed. DataHub samples a topic only when no naming strategy finds a subject for it. If the registry has the exact
<topic>-valuesubject, DataHub finds it again, so it does not sample the topic. This is true even when DataHub could not parse the schema. The topic then shows the raw schema with no fields. A Protobuf schema that fails to compile, or compiles to no fields, also keeps its schema object. DataHub does not sample these topics.
-
-
If the report says
Failed to get subject schema from schema registryorFailed to retrieve schema for topic.The two warnings have different meanings:
-
Failed to get subject schema from schema registrymeans DataHub found the subject but could not fetch its latest version. -
Failed to retrieve schema for topicmeans DataHub could not process an Avro or JSON schema.
For Protobuf, a parse failure shows as
Failed to parse protobuf schemaorProtobuf schema produced no fields. See step 4.The warning includes the exception text. Check that the latest version of the subject is a valid Avro, Protobuf or JSON schema. Then upgrade the CLI as in step 5. If the schema is valid and the error stays on the latest release, contact DataHub Support with the schema and the full warning.
Self-referencing Avro records are not a cause here. The Avro converter stops when a record type refers back to itself, so those schemas produce fields.
-
-
If the topic uses Protobuf and the log shows import errors such as
google/type/date.proto.DataHub builds the Protobuf schema from the main schema plus the schemas listed in its references in the registry. Fix it this way:
- For
google.type.Dateandgoogle.type.Decimal, upgrade the CLI. acryl-datahub 1.7.0 and later add built-in definitions forgoogle/type/date.protoandgoogle/type/decimal.protowhen the registry doesn't provide them. - For any other imported
.protofile, register it in the schema registry and add it as a reference of the topic's schema. There is no recipe setting for a local include path.
If the report says
Protobuf schema produced no fieldsand the debug log says the schemacontains symbols already registered in global descriptor pool, another topic already compiled a message type with the same fully qualified name in this run. DataHub compiles Protobuf schemas into one descriptor pool per process, so only the first topic that defines the type gets fields. Turning onschema_resolutiondoes not help these topics, because the registry did return a schema for them. To get their schemas, ingest them in separate runs, for example with separate recipes whosetopic_patternseach include only one of the topics that share the type. See PROTOBUF Schema Type Limitations. - For
-
Upgrade the CLI.
pip install --upgrade 'acryl-datahub[kafka]' datahub versionIf you run ingestion from the DataHub UI, set the source's CLI Version to the latest release.
-
Re-run your main ingestion and check the topic.
Apply the fix to your main recipe, run it, and open the topic in DataHub to confirm the schema is there.
Recursion errors come from profiling, not schema parsing
Maximum recursion depth exceeded while profiling topic <topic> comes from data profiling. DataHub emits the topic's schema before it profiles the topic, so this error drops only the profile and the report shows Failed to profile topic. The schema stays. To avoid the error, lower profiling.nested_field_max_depth (default 10).