what can i do under transformation while creating ...
# ask-ai
h
what can i do under transformation while creating custom builder?
k
When creating a custom connector with Airbyte's Connector Builder, the "transformation" feature allows you to modify records before they are sent to the destination. Here’s what you can do under transformations: ### 1. Remove Fields You can remove specific fields from records, which is useful for: - Ensuring compliance (e.g., removing PII) - Pseudonymizing sensitive data - Reducing payload size by removing large, unnecessary fields You specify the field path in the transformation configuration. For example, to remove a nested field, you provide its path, and it will be excluded from the output record. You can also use glob patterns like
**
to remove all fields with a certain name at any nesting level, or
*
to match field prefixes at the top level. This is helpful for broad or targeted data cleaning tasks before loading into your warehouse [Transformations](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/record-processing#transformations). ### 2. Custom Transformations with Python If built-in transformations are not sufficient, you can implement custom Python classes (Custom Components) to perform specialized logic, such as: - Decoding fields (e.g., base64 to UTF-8) - Normalizing or enriching data - Handling complex API behaviors Custom Components are Python dataclasses that implement specific Airbyte CDK interfaces. You can override built-in components or add new logic, giving you full control over the transformation process while still leveraging the Connector Builder framework [Custom Components](https://docs.airbyte.com/platform/1.7/connector-development/connector-builder-ui/custom-components). ### 3. Advanced Use Cases Custom transformations are especially powerful for: - Handling edge cases not covered by standard components - Extending functionality beyond declarative configuration - Iterative development, where you only customize the parts you need Example: A custom transformation could decode a base64-encoded field in each record using a Python class, as described in the GitHub issue for decoding an "xml" field [Github Issue](https://github.com/airbytehq/airbyte/issues/26423). --- In summary, under "transformation" in the custom builder, you can remove or pseudonymize fields declaratively, or implement complex, custom logic using Python classes to handle any transformation your use case requires.
h
@kapa.ai can you explain with example?
k
A message from kapa.ai
Certainly! Here’s an example of what you can do with transformations in Airbyte’s Connector Builder, based on the official documentation: --- ### Example 1: Removing a Field from Records Suppose your API returns records like this:
Copy code
json {   "id": "123",   "name": "John Doe",   "email": "john@example.com",   "content": {     "html": "<html>...</html>",     "plain_text": "..."   } }
If you want to remove the entire
content
field (perhaps because it’s large and not needed), you can add a transformation of type
remove
in the Connector Builder UI and set the path to
content
. The resulting record will look like:
Copy code
json {   "id": "123",   "name": "John Doe",   "email": "john@example.com" }
You can also use glob patterns. For example, setting the path to
**
,
name
will remove all
name
fields at any nesting level in the record. This is useful for broad data cleaning or anonymization tasks. [See more details and examples in the documentation](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#transformations). --- ### Example 2: Custom Python Transformation (Custom Component) If you need more advanced logic, such as decoding a base64-encoded field, you can implement a custom Python class. For example, to decode an
xml
field from base64 to UTF-8:
Copy code
python import base64 from dataclasses import dataclass from airbyte_cdk.sources.declarative.transformations import RecordTransformation  @dataclass class ArquiveiCustomTransformation(RecordTransformation):     def transform(self, record, config=None, stream_state=None, stream_slice=None):         record["xml"] = base64.b64decode(record["xml"]).decode("utf-8")         return record
This custom component can be used in your connector to transform each record as needed before it is sent to the destination. [Read more about custom components and their power here](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/custom-components). --- Summary: - Use the built-in "remove" transformation for simple field removal or anonymization. - Use custom Python components for advanced transformations, such as decoding, normalization, or enrichment. If you need a specific example for your use case, let me know!
h
@kapa.ai the response is
Copy code
{
  "headers": [
    {
      "name": "dx",
      "column": "Data",
      "valueType": "TEXT",
      "type": "java.lang.String",
      "hidden": false,
      "meta": true
    },
    {
      "name": "pe",
      "column": "Period",
      "valueType": "TEXT",
      "type": "java.lang.String",
      "hidden": false,
      "meta": true
    },
    {
      "name": "ou",
      "column": "Organisation unit",
      "valueType": "TEXT",
      "type": "java.lang.String",
      "hidden": false,
      "meta": true
    },
    {
      "name": "value",
      "column": "Value",
      "valueType": "NUMBER",
      "type": "java.lang.Double",
      "hidden": false,
      "meta": false
    }
  ],
  "metaData": {
    "items": {
      "201701": {
        "name": "Meskerem 2017"
      },
      "201702": {
        "name": "Tikemet 2017"
      },
      "201703": {
        "name": "Hidar 2017"
      },
      "dx": {
        "name": "Data"
      },
      "pe": {
        "name": "Period"
      },
      "aHQxr6jUXJ7": {
        "name": "Guguftu Health Post_Closed"
      },
      "ou": {
        "name": "Organisation unit"
      },
      "uZ7W7fosr5K": {
        "name": "TB_Treatment Success rate (TSR) among all forms of TB cases"
      }
    },
    "dimensions": {
      "dx": [
        "uZ7W7fosr5K"
      ],
      "pe": [
        "201701",
        "201702",
        "201703"
      ],
      "ou": [
        "aHQxr6jUXJ7"
      ]
    }
  },
  "height": 0,
  "headerWidth": 4,
  "width": 0
}
but i coulsnt remove fields with the following config transformations: - type: RemoveFields field_pointers: - - headers - height - headerWidth - width how can i fix it
k
A message from kapa.ai
Based on your response structure and the configuration you provided, the issue is with how you specify the
field_pointers
in the
RemoveFields
transformation. To remove top-level fields like
headers
,
height
,
headerWidth
, and
width
, each field should be specified as a separate array containing just the field name. For example:
Copy code
yaml transformations:   - type: RemoveFields     field_pointers:       - [ "headers" ]       - [ "height" ]       - [ "headerWidth" ]       - [ "width" ]
Each entry in
field_pointers
should be an array representing the path to the field you want to remove. For top-level fields, this is just a single-element array with the field name. If you want to remove nested fields, you would specify the full path as an array of keys. Example from the documentation:
Copy code
yaml transformations:   - type: RemoveFields     field_pointers:       - [ "path", "to", "field1" ]       - [ "path2" ]
This removes
field1
from within
path.to
and removes
path2
from the top level of the record [Record selector - Transformations](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector#transformations). Summary: Update your config as shown above, and it should correctly remove the specified top-level fields from your records. If you need to remove nested fields, specify the full path as an array. If you want to remove all fields with a certain name at any level, you can use glob patterns in the Connector Builder UI as described in the documentation [Record processing - Transformations](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#transformations).
h
@kapa.ai when the result for the end point is null or like {} or [] the yml ommits them how can i fix it
k
A message from kapa.ai
I'm sorry, but the knowledge sources do not contain explicit information on how to configure the Airbyte Connector Builder YAML to prevent omitting fields when the API response is
null
,
{}
, or
[]
. There is a related issue where users observed that NULL values are omitted in records generated by custom connectors, but no solution or workaround is provided in the available documentation or issues. The issue was marked stale and closed without a resolution, and no official guidance is present on how to force Airbyte to retain such fields in the output records or schema [source](https://github.com/airbytehq/airbyte/issues/36061). If this behavior is critical for your use case, you may want to open a new issue on the Airbyte GitHub repository or discuss it in the Airbyte community forums to get the latest recommendations or feature updates.
h
@kapa.ai version: 6.48.15 type: DeclarativeSource check: type: CheckStream stream_names: - indicator_values definitions: streams: indicator_values: type: DeclarativeStream name: indicator_values retriever: type: SimpleRetriever decoder: type: JsonDecoder requester: $ref: "#/definitions/base_requester" path: https://*.*.gov.et/api/analytics http_method: GET request_parameters: dimension: >- dx:{{ stream_partition['dx'] }},pe201701;201702;201703;201704,ou{{ stream_partition['ou'] }} record_selector: type: RecordSelector extractor: type: DpathExtractor field_path: [] partition_router: - type: ListPartitionRouter values: - wqURG81DbhS - TQZa6RHFdsh cursor_field: ou - type: ListPartitionRouter values: - EM02m2HPZG6 - PePmfAnKV3c cursor_field: dx - type: ListPartitionRouter values: - 201701;201702;201703 - 201704;201705;201706 - 201707;201708;201709 - 201710;201711;201712 cursor_field: pe schema_loader: type: InlineSchemaLoader schema: $ref: "#/schemas/indicator_values" base_requester: type: HttpRequester url_base: https://*.*.gov.et/api/analytics authenticator: type: BasicHttpAuthenticator password: "{{ config[\"password_2\"] }}" username: "{{ config[\"username_2\"] }}" streams: - $ref: "#/definitions/streams/indicator_values" spec: type: Spec connection_specification: type: object $schema: http://json-schema.org/draft-07/schema# required: - username_2 properties: password_2: type: string order: 1 title: Password always_show: true airbyte_secret: true username_2: type: string order: 0 title: Username additionalProperties: true metadata: assist: {} testedStreams: indicator_values: hasRecords: true streamHash: 15240667d4046e618331bb9c66b1c935e3248e21 hasResponse: true primaryKeysAreUnique: true primaryKeysArePresent: true responsesAreSuccessful: true autoImportSchema: indicator_values: false schemas: indicator_values: type: object properties: dx: type: string description: Indicator ID ou: type: string description: Org Unit ID pe: type: string description: Period (YYYYMM) value: type: string description: Indicator Value additionalProperties: true when the result for the end point is null or like {} or [] the yml ommits them how can i fix it
k
A message from kapa.ai
I'm sorry, but the knowledge sources do not provide a direct solution or configuration option in the YAML to force Airbyte to emit records when the API response is
null
,
{}
, or
[]
. This is a known issue reported by users, where NULL values or empty objects/arrays are omitted in the output records generated by custom connectors, and there is no documented workaround or setting to change this behavior in the current Airbyte documentation or GitHub issues. The related GitHub issue was closed without a resolution, and no official fix or configuration is described in the available sources [Github Issue](https://github.com/airbytehq/airbyte/issues/36061). If this behavior is critical for your use case, you may consider raising a new issue on the Airbyte GitHub repository or reaching out to the Airbyte community for further assistance.