<@U04S8PLJWMT> I have a child stream and want to a...
# ask-ai
t
@kapa.ai I have a child stream and want to add a field from the parrent stream via the transformation add field option. It works for {{ stream_partition.id }} which is the defined parrent key but does not seem to work for other fields in the parrent response.
k
You are correct: in Airbyte's Connector Builder, you can add a parent stream's key (the partition field, e.g.,
id
) to child stream records using a transformation with
{{ stream_partition.id }}
. This works because the partition value is explicitly passed to the child stream as part of the partitioning mechanism. However, for other fields from the parent record, simply referencing them via
{{ stream_partition.other_field }}
in a transformation does not work by default. Only the partition field (the one defined as
partition_field
in your
ParentStreamConfig
) is automatically available in
stream_partition
for use in transformations and URL paths. To include additional fields from the parent record in the child stream's context, you need to use the
extra_fields
property in your
ParentStreamConfig
. This allows you to specify which additional fields from the parent should be included in the stream slice and made available to the child stream. You can then access these fields in your transformation using
{{ stream_slice.extra_fields.<field_name> }}
. Example configuration:
Copy code
yaml partition_router:   type: SubstreamPartitionRouter   parent_stream_configs:     - type: ParentStreamConfig       stream: ...       parent_key: id       partition_field: id       extra_fields:         - [ "name" ]         - [ "category", "type" ]
In your child stream transformation, you can then use:
Copy code
yaml - type: AddFields   fields:     - path: [ "parent_name" ]       value: "{{ stream_slice.extra_fields.name }}"     - path: [ "parent_category_type" ]       value: "{{ stream_slice.extra_fields.category.type }}"
This approach ensures that additional parent fields are available for use in transformations in the child stream, not just the partition key itself. If you do not use
extra_fields
, only the partition field will be available in
stream_partition
for transformations, which matches the behavior you observed. For more details, see the documentation on [ParentStreamConfig and extra_fields](https://docs.airbyte.com/platform/1.6/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/ParentStreamConfig) and [advanced partitioning configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/partitioning#advanced-configuration).
New message text here
A message from kapa.ai
New message text here
t
amazing that works!