Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/generator/datasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 5 additions & 0 deletions src/generator/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
9 changes: 9 additions & 0 deletions src/schema/datasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
2 changes: 2 additions & 0 deletions src/schema/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export interface DatasourceOptions<TSchema extends SchemaDefinition> {
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 */
Expand Down
Loading