Skip to content

Commit e5767d7

Browse files
Merge pull request #2167 from ilianiliev-redis/improve-row-format-full-documentation
Improving documentation for row_format full
2 parents e25fd26 + a8c99de commit e5767d7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

content/integrate/redis-data-integration/data-pipelines/transform-examples/redis-row-format.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,48 @@ output:
102102
expression: concat(['addresses-full', '#', values(key)[0]])
103103
language: jmespath
104104
```
105+
106+
### Important notes when using `row_format: full`
107+
108+
- The `before` object will be `null` for `insert` and `create` operations, and the `after` object will be `null` for `delete` operations. If you are building the output key manually, you should account for this and ensure that you are not trying to access fields from a `null` object, as shown in the example below:
109+
110+
```yaml
111+
source:
112+
table: addresses
113+
row_format: full
114+
115+
output:
116+
- uses: redis.write
117+
with:
118+
key:
119+
language: jmespath
120+
# The following pattern will fail for delete operations. In those cases `after` is null, the resulting key will
121+
# be 'addresses:None' and the key won't be removed from the target
122+
# expression: concat(['addresses:', after.ID])
123+
124+
# This pattern works for all operations, by using the ID from the `after` object if it is available,
125+
# and falling back to the ID from the `before` object if not.
126+
expression: concat(['addresses:', after.ID || before.ID])
127+
128+
# Another option is to use the ID from the `key` object
129+
# expression: concat(['addresses:', values(key)[0]])
130+
```
131+
132+
Please note that you should not use `key` in combination with `row_format: full` and more than one output, as the `key` object will be overwritten by the previous output. This is a known limitation of the current implementation and is subject to change in future versions.
133+
134+
135+
- The final result of the processing (which is what will be stored in the output) is the value of the `after` object. This means you must reference the fields using the `after` prefix unless you change the output structure in a transformation step. Also, when you add new fields, you must prefix them with `after.` to ensure that they are added to the correct part of the output:
136+
137+
```yaml
138+
source:
139+
table: addresses
140+
row_format: full
141+
142+
transform:
143+
- uses: add_field
144+
with:
145+
field: after.city_state # use this to add the new field to the final output
146+
# field: city_state # use this if you need a temporary field in the transformation steps, but not in the final output
147+
expression: concat([after.CITY, ', ', after.STATE])
148+
language: jmespath
149+
```

0 commit comments

Comments
 (0)