how does airbyte use the builder's schema? does it...
# ask-ai
l
how does airbyte use the builder's schema? does it use the "type": ["string", "null"] the null annotation for something instead of "required"?
k
Airbyte uses the schema defined in the Connector Builder (the "declared schema") to shape the records that are processed and synced. This schema is a JSON Schema definition that specifies which fields and nested fields are present, their types, and whether they can be missing or null. ### Use of
"type": ["string", "null"]
vs.
"required"
- Nullability with
"type": ["string", "null"]
: Airbyte prefers to indicate that a field can be missing or null by including
"null"
in the
type
array for that field (e.g.,
"type": ["string", "null"]
). This means the field is optional and can be either a string or null. This approach is recommended because many sources cannot guarantee that all fields are present in every record. If a field is not always present, it should not be listed as
"required"
, and its type should include
"null"
to avoid validation errors or issues in the destination when a null value is encountered. > "In these cases, sources should not list them as
required
fields, and add that the property can be null in the jsonSchema, e.g.
[null, string]
. If a null property is found for a non-nullable schema, a validation error may occur in the platform or the destination may have trouble storing the record." [Data Types in Records – Record structure](https://docs.airbyte.com/platform/1.7/understanding-airbyte/supported-data-types#record-structure) - Role of
"required"
: The
"required"
keyword in JSON Schema is used to specify that a field must always be present. Airbyte documentation suggests not marking fields as required unless you are certain they will always be present in every record. Instead, using the nullable type pattern (
["string", "null"]
) is safer and more robust for most use cases, as it prevents errors when fields are missing or null in the data. - Practical Example: When you define a schema in the builder, Airbyte uses this to: - Allow users to select columns/fields for sync. - Recreate the data structure in the destination. - Detect schema changes. - Validate records during syncs. If a field is defined as
"type": ["string", "null"]
, Airbyte will accept both string and null values for that field, and will not raise errors if the field is missing or null in a record. This is the recommended approach for optional fields in Airbyte schemas. [Connector Builder UI – Declared schema](https://docs.airbyte.com/platform/1.7/connector-development/connector-builder-ui/record-processing#declared-schema) [Schema Reference](https://docs.airbyte.com/platform/1.7/connector-development/schema-reference) Summary: Airbyte uses the
"type": ["string", "null"]
pattern to handle optional or nullable fields, rather than relying on the
"required"
keyword. This ensures that missing or null values do not cause validation errors during syncs, making the integration more robust and reliable.