@@ -31,15 +31,16 @@ database (the optional `db` value here corresponds to the
3131` sources.<source-name>.connection.database `  value defined in
3232[ ` config.yaml ` ] ({{< relref "/integrate/redis-data-integration/data-pipelines/data-pipelines#the-configyaml-file" >}})).
3333
34- In the ` transform `  section, the ` add_field `  transformation adds an extra field called ` fullname ` 
35- to the object, which is created by concatenating  the existing  ` firstname `   and ` lastname `  fields using 
36- a  [ SQL expression ] ( https://www.simplilearn.com/tutorials/sql-tutorial/concat-function-in-sql  ) .
37- You can also specify ` jmespath `  as the ` language `  if you prefer to create the new
38- field with a  [ JMESPath ] ( https://jmespath. org/ )  expression
34+ In the ` transform `  section, the ` add_field `  transformation adds an extra field called ` localphone ` 
35+ to the object, which is created by removing  the country  and area code from the  ` phone ` 
36+ field with the  ` regex_replace() `   [ JMESPath ] ( https://jmespath.org/  )  function .
37+ You can also specify ` sql `  as the ` language `  if you prefer to create the new
38+ field with an  [ SQL ] ( https://en.wikipedia. org/wiki/SQL  )  expression. 
3939
4040The ` output `  section specifies ` hash `  as the ` data_type `  to write to the target, which
4141overrides the default setting of ` target_data_type `  defined in ` config.yaml ` . Also, the
42- ` output.with.key `  section specifies a custom key format of the form ` cust:<customerid> ` .
42+ ` output.with.key `  section specifies a custom key format of the form ` cust:<id> `  where
43+ the ` id `  part is generated by the ` uuid() `  function.
4344
4445The full example is shown below:
4546
@@ -50,16 +51,16 @@ source:
5051transform :
5152  - uses : add_field 
5253    with :
53-       expression : concat(firstname , '  ', lastname )
54-       field : fullname 
55-       language : sql 
54+       expression : regex_replace(phone , '\+[0-9]+ (\([0-9]+\) )? ', '' )
55+       field : localphone 
56+       language : jmespath 
5657output :
5758  - uses : redis.write 
5859    with :
5960      connection : target 
6061      data_type : hash 
6162      key :
62-         expression : concat(['cust:', customerid ]) 
63+         expression : concat(['cust:', uuid() ]) 
6364        language : jmespath 
6465` ` ` 
6566
@@ -68,34 +69,33 @@ using [`redis-cli`]({{< relref "/develop/connect/cli" >}}), you would
6869see something like the following :
6970
7071` ` ` 
71- > hgetall cust:14 
7272 1) "customerid" 
73-  2) "14 " 
73+  2) "27 " 
7474 3) "firstname" 
75-  4) "Mark " 
75+  4) "Patrick " 
7676 5) "lastname" 
77-  6) "Philips " 
78-  7) "company" 
79-  8) "Telus" 
80-  9 ) "address "
81- 10 ) "8210 111 ST NW "
77+  6) "Gray " 
78+ . 
79+ . 
80+ 17 ) "phone "
81+ 18 ) "+1 (520) 622-4200 "
8282. 
8383. 
8484` ` ` 
8585
86- Using the job file above, the data also includes the new `fullname ` field :
86+ Using the job file above, the data also includes the new `localphone ` field :
8787
8888` ` ` 
89-  1) "customerid" 
90-  2) "14 " 
89+    1) "customerid" 
90+  2) "27 " 
9191 3) "firstname" 
92-  4) "Mark " 
92+  4) "Patrick " 
9393 5) "lastname" 
94-  6) "Philips " 
94+  6) "Gray " 
9595 . 
9696 . 
97- 27 ) "fullname "
98- 28 ) "Mark Philips "
97+ 23 ) "localphone "
98+ 24 ) "622-4200 "
9999` ` ` 
100100
101101# # Add multiple fields
0 commit comments