{
  "schema_version": 2,
  "id": "integrate/redis-data-integration/data-pipelines/transform-examples/redis-remove-field-example",
  "title": "Remove fields from a key",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/1.19.1/data-pipelines/transform-examples/redis-remove-field-example/",
  "summary": "",
  "content": "\nBy default, RDI adds fields to\n[hash](https://redis.io/docs/latest/develop/data-types/hashes) or\n[JSON](https://redis.io/docs/latest/develop/data-types/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`](https://redis.io/docs/latest/integrate/redis-data-integration/1.19.1/reference/data-transformation/remove_field) transformation.\n\n## Remove a single field\n\nThe 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.\u003csource-name\u003e.connection.database` field defined in\n[`config.yaml`](https://redis.io/docs/latest/integrate/redis-data-integration/1.19.1/data-pipelines/pipeline-config)).\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:\u003cemployeeid\u003e`.\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```yaml\nname: 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\n```\n\nIf you queried the generated target data from the default transformation\nusing [`redis-cli`](https://redis.io/docs/latest/develop/tools/cli), you would\nsee something like the following:\n\n```bash\n\u003e 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.\n```\n\nUsing the job file above, the data omits the `hiredate` field:\n\n```bash\n \u003e 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.\n```\n\n## Remove multiple fields\n\nThe `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```yaml\nname: 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\n```\n\nIf you query the data, you can see that it also omits the\n`birthdate` field:\n\n```bash\n\u003e 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.\n```\n\n## Using `remove_field` with `add_field`\n\nThe `remove_field` transformation is very useful in combination with\n[`add_field`](https://redis.io/docs/latest/integrate/redis-data-integration/1.19.1/data-pipelines/transform-examples/redis-add-field-example).\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`](https://redis.io/docs/latest/integrate/redis-data-integration/1.19.1/data-pipelines/transform-examples/redis-add-field-example#using-add_field-with-remove_field)\nfor an example of how to do this.\n",
  "tags": ["docs","integrate","rs","rdi"],
  "last_updated": "2026-09-19T17:55:58-07:00"
}
