Skip to content

Commit 593caea

Browse files
authored
fix: mentions snowflake sink (#3794)
Signed-off-by: Gašper Grom <gasper.grom@gmail.com>
1 parent c946af1 commit 593caea

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

services/libs/tinybird/datasources/mentions.datasource

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ SCHEMA >
4545
`projectSlug` LowCardinality(String) `json:$.projectSlug` DEFAULT '',
4646
`createdAt` DateTime64(3) `json:$.createdAt` DEFAULT now64(3),
4747
`bookmarked` UInt8 `json:$.bookmarked`,
48-
`keywords` Array(String) `json:$.keywords[:]`
48+
`keywords` Array(String) `json:$.keywords[:]`,
49+
`authorFollowerCount` Nullable(Int32) `json:$.authorFollowerCount`,
50+
`tags` Array(Nullable(String)) `json:$.tags[:]`
4951

5052
ENGINE ReplacingMergeTree
5153
ENGINE_PARTITION_KEY toYear(timestamp)

services/libs/tinybird/pipes/octolens_mentions_sink.pipe

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
DESCRIPTION >
22
Sink pipe to export Octolens mentions data to Kafka for Snowflake ingestion.
33
Reads from mentions datasource using FINAL to get deduplicated data.
4-
Runs daily at 00:30 UTC, exporting all data (full snapshot).
4+
Runs daily at 00:30 UTC, exporting only data created since the last run.
5+
Uses createdAt filter to get rows added the previous day (incremental sync).
56

67
NODE octolens_mentions_select_fields
78
SQL >
@@ -28,8 +29,11 @@ SQL >
2829
createdAt,
2930
bookmarked,
3031
arrayStringConcat(keywords, ',') as keywords,
32+
authorFollowerCount,
33+
arrayStringConcat(tags, ',') as tags,
3134
toStartOfDay(now()) as date
3235
FROM mentions FINAL
36+
WHERE createdAt >= toStartOfDay(now()) - INTERVAL 1 DAY AND createdAt < toStartOfDay(now())
3337

3438
TYPE SINK
3539
EXPORT_SERVICE kafka

0 commit comments

Comments
 (0)