You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0d765ab
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,8 +151,8 @@ For a batch transform, use `Client`. You should only need the following methods:
151
151
*`find_file_path(file_name)` – Resolve a bundled file (placed under `payload/files/`) to a `pathlib.Path` that exists. Works the same locally and inside Data Cloud — see [Bundled file resolution](#bundled-file-resolution) below for the full lookup order. Raises `FileNotFoundError` if the file isn't found.
152
152
*`read_dlo(name)` – Read from a Data Lake Object by name
153
153
*`read_dmo(name)` – Read from a Data Model Object by name
154
-
*`write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
155
-
*`write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
154
+
*`write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Lake Object by name with a Spark dataframe
155
+
*`write_to_dmo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe
156
156
157
157
For a streaming (delta) transform, use `StreamingClient`, which exposes the streaming counterparts:
158
158
*`read_dlo_deltas()` – Read the streaming change feed (deltas) of a Data Lake Object as a streaming DataFrame.
> Currently we only support reading from DMOs and writing to DMOs or reading from DLOs and writing to DLOs, but they cannot mix.
178
178
179
+
### Writing Currency fields
180
+
181
+
A DLO or DMO with a Currency field has a system field, `cdp_sys_record_currency__c`, that holds each record's ISO currency code. Data Explorer UI uses it to display currency values, and shows a blank value if it's null (Query Editor still shows it).
182
+
183
+
Code Extensions don't set `cdp_sys_record_currency__c` for you, since only your script knows what currency its amounts are in. When writing to an object with Currency fields, set it yourself:
184
+
185
+
```python
186
+
from pyspark.sql.functions import lit
187
+
188
+
# Either source has Currency fields: keep its cdp_sys_record_currency__c in your output
- Use an ISO code that exists in your org's configured currency rates.
196
+
- When aggregating, group by the currency code so amounts in different currencies aren't summed together.
197
+
198
+
See [`docs/examples/script/currency_totals`](docs/examples/script/currency_totals) for a complete example.
199
+
179
200
### Streaming (delta) transforms
180
201
181
202
Streaming BYOC transforms process a Data Lake Object's Change Data Feed continuously instead of reading a bounded snapshot. Use a `StreamingClient` and its `*_deltas` methods in place of the batch `Client` read/write methods:
A Code Extension for Batch Transform that sums `Payment__dll` amounts per customer and writes them to `Customer_Payment_Totals__dll`, a DLO with a Currency field, setting the `cdp_sys_record_currency__c` system field so Data Explorer UI can display the totals.
4
+
5
+
## What it demonstrates
6
+
7
+
-**Carrying `cdp_sys_record_currency__c` through** from the source rows to the output. Code Extensions don't auto-populate `cdp_sys_record_currency__c`. And if it's null, Data Explorer shows the Currency value as blank. See [Writing Currency fields](../../../../README.md#writing-currency-fields).
8
+
-**Grouping by currency** so EUR and USD amounts are never summed together. Customer `C1` gets one EUR row and one USD row.
9
+
- If all amounts are in one known currency, one can also use `lit("EUR")` instead of copying a column.
0 commit comments