From 4544d918bfa1923a3cb034015c3df05cedc263d4 Mon Sep 17 00:00:00 2001 From: gnzjgo Date: Fri, 29 May 2026 13:44:36 +0200 Subject: [PATCH 1/3] Add datasource backfill skip support Amp-Thread-ID: https://ampcode.com/threads/T-019e738b-7322-762d-908b-25843851b369 Co-authored-by: Amp --- src/generator/datasource.test.ts | 12 ++++++++++++ src/generator/datasource.ts | 5 +++++ src/schema/datasource.test.ts | 9 +++++++++ src/schema/datasource.ts | 2 ++ 4 files changed, 28 insertions(+) diff --git a/src/generator/datasource.test.ts b/src/generator/datasource.test.ts index 06b6561..5c2ec8c 100644 --- a/src/generator/datasource.test.ts +++ b/src/generator/datasource.test.ts @@ -109,6 +109,18 @@ describe('Datasource Generator', () => { expect(result.content).toContain(' SELECT id'); }); + it('includes backfill skip when provided', () => { + const ds = defineDatasource('test_ds', { + schema: { + id: t.string(), + }, + backfill: 'skip', + }); + + const result = generateDatasource(ds); + expect(result.content).toContain('BACKFILL skip'); + }); + it("includes indexes block when provided", () => { const ds = defineDatasource("test_ds", { schema: { diff --git a/src/generator/datasource.ts b/src/generator/datasource.ts index a0d8ed4..1fbbd2e 100644 --- a/src/generator/datasource.ts +++ b/src/generator/datasource.ts @@ -346,6 +346,11 @@ export function generateDatasource( parts.push(indexes); } + if (datasource.options.backfill === "skip") { + parts.push(""); + parts.push("BACKFILL skip"); + } + // Add Kafka configuration if present if (datasource.options.kafka) { parts.push(""); diff --git a/src/schema/datasource.test.ts b/src/schema/datasource.test.ts index bca9594..21a1e31 100644 --- a/src/schema/datasource.test.ts +++ b/src/schema/datasource.test.ts @@ -170,6 +170,15 @@ describe("Datasource Schema", () => { ]); }); + it("accepts backfill skip configuration", () => { + const ds = defineDatasource("events_rollup", { + schema: { id: t.string() }, + backfill: "skip", + }); + + expect(ds.options.backfill).toBe("skip"); + }); + it("validates datasource index fields", () => { expect(() => defineDatasource("events", { diff --git a/src/schema/datasource.ts b/src/schema/datasource.ts index 5cc393d..d854bcd 100644 --- a/src/schema/datasource.ts +++ b/src/schema/datasource.ts @@ -144,6 +144,8 @@ export interface DatasourceOptions { forwardQuery?: string; /** Secondary indexes for MergeTree-family engines */ indexes?: readonly DatasourceIndex[]; + /** Skip backfilling data when creating a datasource targeted by a materialized view */ + backfill?: "skip"; /** Kafka ingestion configuration */ kafka?: KafkaConfig; /** S3 ingestion configuration */ From bc2782ac8562dbdd8a2a6beadbb934cb038e592b Mon Sep 17 00:00:00 2001 From: gnzjgo Date: Mon, 1 Jun 2026 10:43:41 +0200 Subject: [PATCH 2/3] Bump package version Amp-Thread-ID: https://ampcode.com/threads/T-019e738b-7322-762d-908b-25843851b369 Co-authored-by: Amp --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e0a611..9dd3b22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tinybirdco/sdk", - "version": "0.0.74", + "version": "0.0.75", "description": "TypeScript SDK for Tinybird Forward - define datasources and pipes as TypeScript", "type": "module", "main": "./dist/index.js", From 0f9d2828e78307e9fc0a61743bc7fccde39340c3 Mon Sep 17 00:00:00 2001 From: gnzjgo Date: Mon, 1 Jun 2026 12:19:24 +0200 Subject: [PATCH 3/3] Bump package version to 0.0.76 Amp-Thread-ID: https://ampcode.com/threads/T-019e738b-7322-762d-908b-25843851b369 Co-authored-by: Amp --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dd3b22..9d623a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tinybirdco/sdk", - "version": "0.0.75", + "version": "0.0.76", "description": "TypeScript SDK for Tinybird Forward - define datasources and pipes as TypeScript", "type": "module", "main": "./dist/index.js",