@tinybirdco/sdk 0.0.69 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,6 +100,13 @@ describe('Engine Configurations', () => {
100
100
  });
101
101
  });
102
102
 
103
+ describe('Null', () => {
104
+ it('creates Null config', () => {
105
+ const config = engine.null();
106
+ expect(config.type).toBe('Null');
107
+ });
108
+ });
109
+
103
110
  describe('getEngineClause', () => {
104
111
  it('generates basic MergeTree clause', () => {
105
112
  const config = engine.mergeTree({ sortingKey: ['id'] });
@@ -187,6 +194,12 @@ describe('Engine Configurations', () => {
187
194
  expect(clause).toContain('ENGINE_SIGN "sign_col"');
188
195
  expect(clause).toContain('ENGINE_VERSION "version_col"');
189
196
  });
197
+
198
+ it('generates Null engine without MergeTree directives', () => {
199
+ const clause = getEngineClause(engine.null());
200
+ expect(clause).toBe('ENGINE Null');
201
+ expect(clause).not.toContain('ENGINE_SORTING_KEY');
202
+ });
190
203
  });
191
204
 
192
205
  describe('Helper functions', () => {
@@ -79,10 +79,18 @@ export interface VersionedCollapsingMergeTreeConfig extends BaseMergeTreeConfig
79
79
  version: string;
80
80
  }
81
81
 
82
+ /**
83
+ * Null engine configuration
84
+ * Discards inserted rows and returns an empty response when read
85
+ */
86
+ export interface NullEngineConfig {
87
+ type: "Null";
88
+ }
89
+
82
90
  /**
83
91
  * Union type of all engine configurations
84
92
  */
85
- export type EngineConfig =
93
+ export type MergeTreeEngineConfig =
86
94
  | MergeTreeConfig
87
95
  | ReplacingMergeTreeConfig
88
96
  | SummingMergeTreeConfig
@@ -90,6 +98,8 @@ export type EngineConfig =
90
98
  | CollapsingMergeTreeConfig
91
99
  | VersionedCollapsingMergeTreeConfig;
92
100
 
101
+ export type EngineConfig = MergeTreeEngineConfig | NullEngineConfig;
102
+
93
103
  /**
94
104
  * Helper to normalize sorting key to array format
95
105
  */
@@ -121,6 +131,9 @@ function normalizeSortingKey(key: string | readonly string[]): readonly string[]
121
131
  * sortingKey: ['date', 'metric_name'],
122
132
  * columns: ['value'],
123
133
  * });
134
+ *
135
+ * // Null engine for materialized view source tables
136
+ * engine.null();
124
137
  * ```
125
138
  */
126
139
  export const engine = {
@@ -196,19 +209,27 @@ export const engine = {
196
209
  type: "VersionedCollapsingMergeTree",
197
210
  ...config,
198
211
  }),
212
+
213
+ /**
214
+ * Null - Discards inserted rows and returns no rows when read
215
+ * Best for: Materialized view source tables that transform and discard raw input
216
+ */
217
+ null: (): NullEngineConfig => ({
218
+ type: "Null",
219
+ }),
199
220
  } as const;
200
221
 
201
222
  /**
202
223
  * Get the sorting key as an array
203
224
  */
204
- export function getSortingKey(config: EngineConfig): readonly string[] {
225
+ export function getSortingKey(config: MergeTreeEngineConfig): readonly string[] {
205
226
  return normalizeSortingKey(config.sortingKey);
206
227
  }
207
228
 
208
229
  /**
209
230
  * Get the primary key as an array (defaults to sorting key)
210
231
  */
211
- export function getPrimaryKey(config: EngineConfig): readonly string[] {
232
+ export function getPrimaryKey(config: MergeTreeEngineConfig): readonly string[] {
212
233
  if (config.primaryKey) {
213
234
  return normalizeSortingKey(config.primaryKey);
214
235
  }
@@ -219,6 +240,10 @@ export function getPrimaryKey(config: EngineConfig): readonly string[] {
219
240
  * Generate the engine clause for a datasource file
220
241
  */
221
242
  export function getEngineClause(config: EngineConfig): string {
243
+ if (config.type === "Null") {
244
+ return "ENGINE Null";
245
+ }
246
+
222
247
  const parts: string[] = [`ENGINE "${config.type}"`];
223
248
 
224
249
  if (config.partitionKey) {