<@U04S8PLJWMT> I have an API response in this form...
# ask-ai
l
@kapa.ai I have an API response in this format { "ListaDeFiltro": [ { "Contrato": { "Matricula": "13113131" }, "SaldoFinal": "00:00", "OcorrenciasAusencias": [ { "DataOcorrencia": "05/03/2025", "Inicio": "06/03/2025 04:09", "Fim": "06/03/2025 04:17", "Tipo": { "Descricao": "Intervalo irregular", "Justificativa": "Debito" }, "QtdeHoras": "-00:08" }, ]}] } I want to make ListaDeFiltro.*.OcorrenciasAusencias the record list with the record selector however, I want to pull the "Contrato.Matricula" to appear in the record Maybe use add field?
k
Yes, you can achieve this in Airbyte by using the record selector to extract records from
ListaDeFiltro.*.OcorrenciasAusencias
and then use a transformation to add the
Contrato.Matricula
field to each record. ### 1. Record Selector Set the
field_path
in your selector to:
Copy code
yaml field_path: ["ListaDeFiltro", "*", "OcorrenciasAusencias", "*"]
This will extract each object inside every
OcorrenciasAusencias
array within each item of
ListaDeFiltro
as a record. ([Reference](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector)) ### 2. Add Field Transformation To pull
Contrato.Matricula
from the parent object and add it to each record, use the
AddFields
transformation. The value can be referenced using the
parent
context:
Copy code
yaml transformations:   - type: AddFields     fields:       - path: ["Matricula"]         value: "{{ parent['Contrato']['Matricula'] }}"
This will add a top-level field
Matricula
to each record, containing the value from the parent object. ([Reference](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector#transformations)) ### Example Stream Definition
Copy code
yaml stream:   # ... other stream config ...   selector:     extractor:       field_path: ["ListaDeFiltro", "*", "OcorrenciasAusencias", "*"]   transformations:     - type: AddFields       fields:         - path: ["Matricula"]           value: "{{ parent['Contrato']['Matricula'] }}"
Note: The use of
parent
in the template is supported for referencing the parent object when extracting nested records, as described in the transformations documentation. --- This approach will give you each
OcorrenciasAusencias
record with an additional
Matricula
field from its parent object. If you need to add the field at a different path or with a different name, adjust the
path
accordingly.
l
@kapa.ai I think "parent" is not available
k
A message from kapa.ai
You are correct—based on the current Airbyte documentation and the linked issues, the context variable parent is not available in record transformations. The only available context objects for transformations are: - record - stream_state - stream_slice - stream_interval - stream_partition There is an open feature request to make the full response (or parent context) available in transformations, but as of now, this is not supported in Airbyte's config-based connector framework. This limitation is specifically discussed in the following sources, where users have requested access to the parent or response object for exactly your use case, but it is not yet implemented [Connector/Source: Publish the response object in the record transformation](https://github.com/airbytehq/airbyte/discussions/49971) [Github Issue: Publish the response object in the record transformation](https://github.com/airbytehq/airbyte/issues/50395). Current workaround: If you need to add a field from a parent object (like Contrato.Matricula) to each nested record, you cannot do this purely with transformations in the declarative YAML at this time. You would need to: - Use a custom (Python) connector, or - Pre-process the data in the API or upstream, or - Wait for this feature to be implemented in Airbyte. Summary: You cannot reference parent or response objects in transformations as of now. Only the record and a few other context objects are available. This is a known limitation and is being tracked by the Airbyte team [Connector/Source: Publish the response object in the record transformation](https://github.com/airbytehq/airbyte/discussions/49971).