Skip to content

Commit e430fc9

Browse files
committed
add default values
1 parent 7457be4 commit e430fc9

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Alter DEFAULT value in a column of the landing Data Source
2+
3+
[Pull Request](https://github.com/tinybirdco/use-case-examples/pull/340/files)
4+
5+
- Just a add the default values to the desired columns. If the event is not sending the value or it is null, the default value will be applied.
6+
7+
8+
```diff
9+
SCHEMA >
10+
+ `timestamp` DateTime `json:$.timestamp` DEFAULT now(),
11+
+ `session_id` String `json:$.session_id` DEFAULT '',
12+
+ `action` LowCardinality(String) `json:$.action` DEFAULT 'None',
13+
+ `version` LowCardinality(String) `json:$.version` DEFAULT '1.0',
14+
+ `payload` String `json:$.payload` DEFAULT '{}',
15+
- `timestamp` DateTime `json:$.timestamp`,
16+
- `session_id` String `json:$.session_id`,
17+
- `action` LowCardinality(String) `json:$.action`,
18+
- `version` LowCardinality(String) `json:$.version`,
19+
- `payload` String `json:$.payload`
20+
```
21+
22+
- Create a PR with the change above, a new branch will be created as part of the CI process. You can double check the default value is what you expect by ingesteing some null value in the CI branch created.
23+
- To deploy the change, merge to PR to you main branch, the CD job will run and will deploy the changes.

alter_default_value_in_column/datasources/analytics_events.datasource

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ DESCRIPTION >
44
Analytics events landing data source
55

66
SCHEMA >
7-
`timestamp` DateTime `json:$.timestamp`,
8-
`session_id` String `json:$.session_id`,
9-
`action` LowCardinality(String) `json:$.action`,
10-
`version` LowCardinality(String) `json:$.version`,
11-
`payload` String `json:$.payload`
7+
`timestamp` DateTime `json:$.timestamp` DEFAULT now(),
8+
`session_id` String `json:$.session_id` DEFAULT '',
9+
`action` LowCardinality(String) `json:$.action` DEFAULT 'None',
10+
`version` LowCardinality(String) `json:$.version` DEFAULT '1.0',
11+
`payload` String `json:$.payload` DEFAULT '{}',
1212

1313
ENGINE "MergeTree"
1414
ENGINE_PARTITION_KEY "toYYYYMM(timestamp)"

0 commit comments

Comments
 (0)