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
**Features** / **Fixes** - docs: table references must be fully qualified. - Jinja `context` was common to the two templates. Now defined only once. **Deprecations** / **Breaking Changes** - `delta` is changed to `upsert` mode. `upsert` function will be renamed in `merge`. Issue #13
Copy file name to clipboardExpand all lines: bigfunctions/upsert.yaml
+24-27Lines changed: 24 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,9 @@ description: |-
14
14
15
15
| Param | Possible values |
16
16
|---|---|
17
-
| `query_or_table_or_view` | Can be a fully qualified table or view `(<project-id>.)?<dataset_id>.<table_or_view_name>`. <br> Can also be a plain query in BigQuery Standard SQL. |
18
-
| `destination_table` | Must be a fully qualified table `(<project-id>.)?<dataset_id>.<table_or_view_name>`. |
19
-
| `insertion_mode` | Three insertion mode are available:<ul><li> `"insert_only"`: existing records in `query_or_table_or_view` and not existing in `destination_table` are inserted. Deletion and update are not possible. </li><li> `"delta"`: same as `insert_only` with the updatable records. Records existing both in `query_or_table_or_view` and in `destination_table` are updated. If `recency_field` is filled, only the most recent version from source and destination is kept. </li><li> `"full"`: same as `delta` with the deletable records. Records not existing in `query_or_table_or_view` and existing in `destination_table` are deleted. </li> </ul> |
17
+
| `query_or_table_or_view` | Can be a fully qualified table or view `<project-id>.<dataset_id>.<table_or_view_name>`. <br> Can also be a plain query in BigQuery Standard SQL. |
18
+
| `destination_table` | Must be a fully qualified table `<project-id>.<dataset_id>.<table_or_view_name>`. |
19
+
| `insertion_mode` | Three insertion mode are available:<ul><li> `"insert_only"`: existing records in `query_or_table_or_view` and not existing in `destination_table` are inserted. Deletion and update are not possible. </li><li> `"upsert"`: same as `insert_only` with the updatable records. Records existing both in `query_or_table_or_view` and in `destination_table` are updated. If `recency_field` is filled, only the most recent version from source and destination is kept. </li><li> `"full"`: same as `upsert` with the deletable records. Records not existing in `query_or_table_or_view` and existing in `destination_table` are deleted. </li> </ul> |
20
20
| `primary_keys` | Combination of field identifying a record. If `primary_keys = []`, every row will be considered as a unique record. |
21
21
| `recency_field` | Orderable field (ie. `timestamp`, `integer`, ...) to identify the relative frechness of a record version. |
22
22
arguments:
@@ -31,18 +31,18 @@ arguments:
31
31
- name: recency_field
32
32
type: string
33
33
examples:
34
-
- description: "Merge tables in delta mode"
34
+
- description: "Merge tables in upsert mode"
35
35
arguments:
36
-
- "'dataset_id.source_table_or_view'"
37
-
- "'dataset_id.destination_table'"
38
-
- "'delta'"
36
+
- "'project-id.dataset_id.source_table_or_view'"
37
+
- "'project-id.dataset_id.destination_table'"
38
+
- "'upsert'"
39
39
- "['id']"
40
40
- "'timestamp_field'"
41
41
region: ALL
42
42
- description: "Merge from query in full"
43
43
arguments:
44
-
- "'select * from dataset_id.source_table_or_view where filter_field = true'"
45
-
- "'dataset_id.destination_table'"
44
+
- "'select * from project-id.dataset_id.source_table_or_view where filter_field = true'"
45
+
- "'project-id.dataset_id.destination_table'"
46
46
- "'full'"
47
47
- "['id']"
48
48
- "null"
@@ -52,7 +52,21 @@ code: |
52
52
declare context json;
53
53
declare table_columns array<string>;
54
54
55
-
assert lower(insertion_mode) in ('insert_only', 'delta', 'full') AS '`insertion_mode` must be either "insert_only", "delta", or "full"';
55
+
assert lower(insertion_mode) in ('insert_only', 'upsert', 'full') AS '`insertion_mode` must be either "insert_only", "upsert", or "full"';
0 commit comments