{
  "id": "redis-remove-field-example",
  "title": "Remove fields from a key",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-remove-field-example/",
  "summary": "",
  "tags": [
    "docs",
    "integrate",
    "rs",
    "rdi"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "84ba66976c7cbdd6214a67ebd8ffe682e386bfcf9229ebf19b64687710acff43",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "By default, RDI adds fields to\n[hash]() or\n[JSON]() objects in the target\ndatabase for each of the columns of the source table.\nThe examples below show how to omit some of those fields from the target data with the\n[`remove_field`]() transformation."
    },
    {
      "id": "remove-a-single-field",
      "title": "Remove a single field",
      "role": "content",
      "text": "The first example removes a single field from the data.\nThe `source` section selects the `employee` table of the\n[`chinook`](https://github.com/Redislabs-Solution-Architects/rdi-quickstart-postgres)\ndatabase (the optional `db` field here corresponds to the\n`sources.<source-name>.connection.database` field defined in\n[`config.yaml`]()).\n\nIn the `transform` section, the `remove_field` transformation removes the\n`hiredate` field.\n\nThe `output` section specifies `hash` as the `data_type` to write to the target, which\noverrides the default setting of `target_data_type` defined in `config.yaml`. Also, the\n`output.with.key` section specifies a custom key format of the form `emp:<employeeid>`.\nNote that any fields you remove in the `transform` section are not available for\nthe key calculation in the `output` section.\n\nThe full example is shown below:\n\n[code example]\n\nIf you queried the generated target data from the default transformation\nusing [`redis-cli`](), you would\nsee something like the following:\n\n[code example]\n\nUsing the job file above, the data omits the `hiredate` field:\n\n[code example]"
    },
    {
      "id": "remove-multiple-fields",
      "title": "Remove multiple fields",
      "role": "content",
      "text": "The `remove_field` transformation can also remove multiple fields at the same time\nif you specify them under a `fields` subsection. The example below is similar\nto the previous one but also removes the `birthdate` field: \n\n[code example]\n\nIf you query the data, you can see that it also omits the\n`birthdate` field:\n\n[code example]"
    },
    {
      "id": "using-remove-field-with-add-field",
      "title": "Using `remove_field` with `add_field`",
      "role": "content",
      "text": "The `remove_field` transformation is very useful in combination with\n[`add_field`]().\nFor example, if you use `add_field` to concatenate a person's first\nand last names, you may not need separate `firstname` and `lastname`\nfields, so you can use `remove_field` to omit them.\nSee [Using `add_field` with `remove_field`]()\nfor an example of how to do this."
    }
  ],
  "examples": [
    {
      "id": "remove-a-single-field-ex0",
      "language": "yaml",
      "code": "name: Remove hiredate from employee\nsource:\n  db: chinook\n  table: employee\ntransform:\n  - uses: remove_field\n    with:\n      field: hiredate\noutput:\n  - uses: redis.write\n    with:\n      connection: target\n      data_type: hash\n      key:\n        expression: concat(['emp:', employeeid])\n        language: jmespath",
      "section_id": "remove-a-single-field"
    },
    {
      "id": "remove-a-single-field-ex1",
      "language": "bash",
      "code": "> hgetall emp:8\n 1) \"employeeid\"\n 2) \"8\"\n 3) \"lastname\"\n 4) \"Callahan\"\n 5) \"firstname\"\n 6) \"Laura\"\n 7) \"title\"\n 8) \"IT Staff\"\n 9) \"reportsto\"\n10) \"6\"\n11) \"birthdate\"\n12) \"-62467200000000\"\n13) \"hiredate\"\n14) \"1078358400000000\"\n15) \"address\"\n16) \"923 7 ST NW\"\n.\n.",
      "section_id": "remove-a-single-field"
    },
    {
      "id": "remove-a-single-field-ex2",
      "language": "bash",
      "code": "> hgetall emp:8\n 1) \"employeeid\"\n 2) \"8\"\n 3) \"lastname\"\n 4) \"Callahan\"\n 5) \"firstname\"\n 6) \"Laura\"\n 7) \"title\"\n 8) \"IT Staff\"\n 9) \"reportsto\"\n10) \"6\"\n11) \"birthdate\"\n12) \"-62467200000000\"\n13) \"address\"\n14) \"923 7 ST NW\"\n.\n.",
      "section_id": "remove-a-single-field"
    },
    {
      "id": "remove-multiple-fields-ex0",
      "language": "yaml",
      "code": "name: Remove multiple date fields from employee\nsource:\n  db: chinook\n  table: employee\ntransform:\n  - uses: remove_field\n    with:\n      fields:\n        - field: hiredate\n        - field: birthdate\noutput:\n  - uses: redis.write\n    with:\n      connection: target\n      data_type: hash\n      key:\n        expression: concat(['emp:', employeeid])\n        language: jmespath",
      "section_id": "remove-multiple-fields"
    },
    {
      "id": "remove-multiple-fields-ex1",
      "language": "bash",
      "code": "> hgetall emp:8\n 1) \"employeeid\"\n 2) \"8\"\n 3) \"lastname\"\n 4) \"Callahan\"\n 5) \"firstname\"\n 6) \"Laura\"\n 7) \"title\"\n 8) \"IT Staff\"\n 9) \"reportsto\"\n10) \"6\"\n11) \"address\"\n12) \"923 7 ST NW\"\n.\n.",
      "section_id": "remove-multiple-fields"
    }
  ]
}
