-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathmetadata.test.ts
More file actions
627 lines (550 loc) · 24.8 KB
/
Copy pathmetadata.test.ts
File metadata and controls
627 lines (550 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
// Copyright (c) 2026 Databricks, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { expect } from 'chai';
import SeaSessionBackend from '../../../lib/sea/SeaSessionBackend';
import SeaOperationBackend from '../../../lib/sea/SeaOperationBackend';
import SeaTableTypeFilter from '../../../lib/sea/SeaTableTypeFilter';
import {
SeaNativeConnection,
SeaNativeStatement,
SeaNativeAsyncStatement,
} from '../../../lib/sea/SeaNativeLoader';
import IOperationBackend from '../../../lib/contracts/IOperationBackend';
import IClientContext, { ClientConfig } from '../../../lib/contracts/IClientContext';
import IDBSQLLogger, { LogLevel } from '../../../lib/contracts/IDBSQLLogger';
import HiveDriverError from '../../../lib/errors/HiveDriverError';
// ─── Fakes ───────────────────────────────────────────────────────────────────
class FakeNativeStatement implements SeaNativeStatement {
public readonly statementId = 'fake-statement-id';
public async fetchNextBatch() { return null; }
public async schema() { return { ipcBytes: Buffer.alloc(0) }; }
public async cancel() {}
public async close() {}
}
interface RecordedMetadataCall {
method: string;
args: unknown[];
returnStatement: FakeNativeStatement;
}
/**
* Connection fake that records every metadata call and the args passed
* so tests can assert on both the argument routing and the return-value
* wrapping path.
*/
class FakeMetadataConnection implements SeaNativeConnection {
public readonly sessionId = 'fake-session-id';
public readonly calls: RecordedMetadataCall[] = [];
public throwNextCall: unknown = null;
private record(method: string, args: unknown[]): FakeNativeStatement {
if (this.throwNextCall !== null) {
const err = this.throwNextCall;
this.throwNextCall = null;
throw err;
}
const returnStatement = new FakeNativeStatement();
this.calls.push({ method, args, returnStatement });
return returnStatement;
}
public async executeStatement(_sql: string): Promise<SeaNativeStatement> {
return this.record('executeStatement', [_sql]);
}
// Metadata tests exercise the dedicated list* methods (blocking
// statements); the async query path isn't used here, but the interface
// requires it. Record the call and return a minimal async handle.
public async submitStatement(_sql: string): Promise<SeaNativeAsyncStatement> {
this.record('submitStatement', [_sql]);
return {
statementId: 'fake-statement-id',
status: async () => 'Succeeded' as const,
awaitResult: async () => ({
statementId: 'fake-statement-id',
fetchNextBatch: async () => null,
schema: async () => ({ ipcBytes: Buffer.alloc(0) }),
}),
cancel: async () => {},
close: async () => {},
};
}
public async listCatalogs(): Promise<SeaNativeStatement> {
return this.record('listCatalogs', []);
}
public async listSchemas(
catalog: string | undefined,
schemaPattern: string | undefined,
): Promise<SeaNativeStatement> {
return this.record('listSchemas', [catalog, schemaPattern]);
}
public async listTables(
catalog: string | undefined,
schemaPattern: string | undefined,
tablePattern: string | undefined,
tableTypes: string[] | undefined,
): Promise<SeaNativeStatement> {
return this.record('listTables', [catalog, schemaPattern, tablePattern, tableTypes]);
}
public async listColumns(
catalog: string | undefined,
schemaPattern: string | undefined,
tablePattern: string | undefined,
columnPattern: string | undefined,
): Promise<SeaNativeStatement> {
return this.record('listColumns', [catalog, schemaPattern, tablePattern, columnPattern]);
}
public async listFunctions(
catalog: string | undefined,
schemaPattern: string | undefined,
functionPattern: string | undefined,
): Promise<SeaNativeStatement> {
return this.record('listFunctions', [catalog, schemaPattern, functionPattern]);
}
public async listTableTypes(): Promise<SeaNativeStatement> {
return this.record('listTableTypes', []);
}
public async listTypeInfo(): Promise<SeaNativeStatement> {
return this.record('listTypeInfo', []);
}
public async getPrimaryKeys(
catalog: string,
schema: string,
table: string,
): Promise<SeaNativeStatement> {
return this.record('getPrimaryKeys', [catalog, schema, table]);
}
public async getCrossReference(
parentCatalog: string | undefined | null,
parentSchema: string | undefined | null,
parentTable: string | undefined | null,
foreignCatalog: string,
foreignSchema: string,
foreignTable: string,
): Promise<SeaNativeStatement> {
return this.record('getCrossReference', [
parentCatalog, parentSchema, parentTable,
foreignCatalog, foreignSchema, foreignTable,
]);
}
public async close(): Promise<void> {}
}
function makeContext(): IClientContext {
const logger: IDBSQLLogger = { log(_level: LogLevel, _message: string): void {} };
const config = {} as ClientConfig;
return {
getConfig: () => config,
getLogger: () => logger,
getConnectionProvider: async () => { throw new Error('unused'); },
getClient: async () => { throw new Error('unused'); },
getDriver: async () => { throw new Error('unused'); },
};
}
function makeSession(connection: SeaNativeConnection): SeaSessionBackend {
return new SeaSessionBackend({ connection, context: makeContext() });
}
// ─── Tests ───────────────────────────────────────────────────────────────────
describe('SeaSessionBackend metadata methods', () => {
// ── getCatalogs ──────────────────────────────────────────────────────────
describe('getCatalogs', () => {
it('calls listCatalogs() with no args and returns SeaOperationBackend', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
const op = await session.getCatalogs({});
expect(op).to.be.instanceOf(SeaOperationBackend);
expect(conn.calls).to.have.length(1);
expect(conn.calls[0].method).to.equal('listCatalogs');
expect(conn.calls[0].args).to.deep.equal([]);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getCatalogs({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
expect((thrown as Error).message).to.match(/closed/);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
const session = makeSession(conn);
let thrown: unknown;
try { await session.getCatalogs({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getSchemas ───────────────────────────────────────────────────────────
describe('getSchemas', () => {
it('routes catalogName and schemaName to listSchemas', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
const op = await session.getSchemas({ catalogName: 'main', schemaName: 'info%' });
expect(op).to.be.instanceOf(SeaOperationBackend);
expect(conn.calls[0].method).to.equal('listSchemas');
expect(conn.calls[0].args).to.deep.equal(['main', 'info%']);
});
it('passes undefined when request fields are absent', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.getSchemas({});
expect(conn.calls[0].args).to.deep.equal([undefined, undefined]);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getSchemas({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getSchemas({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getTables ────────────────────────────────────────────────────────────
describe('getTables', () => {
it('routes all four args to listTables', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.getTables({
catalogName: 'cat',
schemaName: 'sch%',
tableName: 'tbl%',
tableTypes: ['TABLE', 'VIEW'],
});
expect(conn.calls[0].method).to.equal('listTables');
expect(conn.calls[0].args).to.deep.equal(['cat', 'sch%', 'tbl%', ['TABLE', 'VIEW']]);
});
it('passes undefined for absent fields', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.getTables({});
expect(conn.calls[0].args).to.deep.equal([undefined, undefined, undefined, undefined]);
});
it('returns SeaOperationBackend when tableTypes is absent', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getTables({});
expect(op).to.be.instanceOf(SeaOperationBackend);
});
it('wraps in SeaTableTypeFilter when tableTypes is provided', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getTables({ tableTypes: ['TABLE'] });
expect(op).to.be.instanceOf(SeaTableTypeFilter);
});
it('wraps in SeaTableTypeFilter when tableTypes is empty array', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getTables({ tableTypes: [] });
expect(op).to.be.instanceOf(SeaTableTypeFilter);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getTables({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getTables({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getTableTypes ────────────────────────────────────────────────────────
describe('getTableTypes', () => {
it('calls listTableTypes() with no args', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
const op = await session.getTableTypes({});
expect(op).to.be.instanceOf(SeaOperationBackend);
expect(conn.calls[0].method).to.equal('listTableTypes');
expect(conn.calls[0].args).to.deep.equal([]);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getTableTypes({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getTableTypes({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getTypeInfo ──────────────────────────────────────────────────────────
describe('getTypeInfo', () => {
it('calls listTypeInfo() and returns SeaOperationBackend', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getTypeInfo({});
expect(op).to.be.instanceOf(SeaOperationBackend);
expect(conn.calls[0].method).to.equal('listTypeInfo');
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getTypeInfo({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getTypeInfo({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getColumns ───────────────────────────────────────────────────────────
describe('getColumns', () => {
it('routes all four args to listColumns', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getColumns({
catalogName: 'c',
schemaName: 's',
tableName: 't',
columnName: 'col%',
});
expect(conn.calls[0].method).to.equal('listColumns');
expect(conn.calls[0].args).to.deep.equal(['c', 's', 't', 'col%']);
});
it('passes undefined for absent fields', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getColumns({});
expect(conn.calls[0].args).to.deep.equal([undefined, undefined, undefined, undefined]);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getColumns({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getColumns({}); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getFunctions ─────────────────────────────────────────────────────────
describe('getFunctions', () => {
it('routes catalogName, schemaName, functionName to listFunctions', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getFunctions({
catalogName: 'c',
schemaName: 's%',
functionName: 'fn%',
});
expect(conn.calls[0].method).to.equal('listFunctions');
expect(conn.calls[0].args).to.deep.equal(['c', 's%', 'fn%']);
});
it('passes undefined catalogName when absent', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getFunctions({ functionName: 'myfn' });
expect(conn.calls[0].args).to.deep.equal([undefined, undefined, 'myfn']);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getFunctions({ functionName: 'f' }); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try { await makeSession(conn).getFunctions({ functionName: 'f' }); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getPrimaryKeys ───────────────────────────────────────────────────────
describe('getPrimaryKeys', () => {
it('routes catalogName, schemaName, tableName to getPrimaryKeys', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getPrimaryKeys({
catalogName: 'cat',
schemaName: 'myschema',
tableName: 'orders',
});
expect(conn.calls[0].method).to.equal('getPrimaryKeys');
expect(conn.calls[0].args).to.deep.equal(['cat', 'myschema', 'orders']);
});
it('throws HiveDriverError when catalogName is absent', async () => {
const conn = new FakeMetadataConnection();
let thrown: unknown;
try { await makeSession(conn).getPrimaryKeys({ schemaName: 'sch', tableName: 'tbl' }); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
expect((thrown as Error).message).to.match(/catalogName is required/);
});
it('returns SeaOperationBackend when all args present', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getPrimaryKeys({ catalogName: 'cat', schemaName: 's', tableName: 't' });
expect(op).to.be.instanceOf(SeaOperationBackend);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try { await session.getPrimaryKeys({ catalogName: 'cat', schemaName: 's', tableName: 't' }); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'kernel-pk-error';
let thrown: unknown;
try { await makeSession(conn).getPrimaryKeys({ catalogName: 'cat', schemaName: 's', tableName: 't' }); } catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
// ── getCrossReference ────────────────────────────────────────────────────
describe('getCrossReference', () => {
it('routes all 6 fields to getCrossReference in the right order', async () => {
const conn = new FakeMetadataConnection();
await makeSession(conn).getCrossReference({
parentCatalogName: 'pc',
parentSchemaName: 'ps',
parentTableName: 'pt',
foreignCatalogName: 'fc',
foreignSchemaName: 'fs',
foreignTableName: 'ft',
});
expect(conn.calls[0].method).to.equal('getCrossReference');
expect(conn.calls[0].args).to.deep.equal(['pc', 'ps', 'pt', 'fc', 'fs', 'ft']);
});
it('returns SeaOperationBackend', async () => {
const conn = new FakeMetadataConnection();
const op = await makeSession(conn).getCrossReference({
parentCatalogName: 'pc',
parentSchemaName: 'ps',
parentTableName: 'pt',
foreignCatalogName: 'fc',
foreignSchemaName: 'fs',
foreignTableName: 'ft',
});
expect(op).to.be.instanceOf(SeaOperationBackend);
});
it('throws HiveDriverError when foreignCatalogName is absent', async () => {
const conn = new FakeMetadataConnection();
let thrown: unknown;
try {
await makeSession(conn).getCrossReference({
parentCatalogName: 'pc', parentSchemaName: 'ps', parentTableName: 'pt',
foreignCatalogName: '', foreignSchemaName: 'fs', foreignTableName: 'ft',
});
} catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
expect((thrown as Error).message).to.match(/foreignCatalogName is required/);
});
it('throws HiveDriverError when foreignSchemaName is absent', async () => {
const conn = new FakeMetadataConnection();
let thrown: unknown;
try {
await makeSession(conn).getCrossReference({
parentCatalogName: 'pc', parentSchemaName: 'ps', parentTableName: 'pt',
foreignCatalogName: 'fc', foreignSchemaName: '', foreignTableName: 'ft',
});
} catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
expect((thrown as Error).message).to.match(/foreignSchemaName is required/);
});
it('throws HiveDriverError when foreignTableName is absent', async () => {
const conn = new FakeMetadataConnection();
let thrown: unknown;
try {
await makeSession(conn).getCrossReference({
parentCatalogName: 'pc', parentSchemaName: 'ps', parentTableName: 'pt',
foreignCatalogName: 'fc', foreignSchemaName: 'fs', foreignTableName: '',
});
} catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
expect((thrown as Error).message).to.match(/foreignTableName is required/);
});
it('rejects when session is closed', async () => {
const conn = new FakeMetadataConnection();
const session = makeSession(conn);
await session.close();
let thrown: unknown;
try {
await session.getCrossReference({
parentCatalogName: 'pc',
parentSchemaName: 'ps',
parentTableName: 'pt',
foreignCatalogName: 'fc',
foreignSchemaName: 'fs',
foreignTableName: 'ft',
});
} catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
it('wraps kernel error via decodeNapiKernelError', async () => {
const conn = new FakeMetadataConnection();
conn.throwNextCall = 'napi-err';
let thrown: unknown;
try {
await makeSession(conn).getCrossReference({
parentCatalogName: 'pc', parentSchemaName: 'ps', parentTableName: 'pt',
foreignCatalogName: 'fc', foreignSchemaName: 'fs', foreignTableName: 'ft',
});
} catch (e) { thrown = e; }
expect(thrown).to.be.instanceOf(HiveDriverError);
});
});
});
// ─── SeaTableTypeFilter behavior ─────────────────────────────────────────────
describe('SeaTableTypeFilter fetchChunk row reduction', () => {
const MIXED_ROWS = [
{ TABLE_TYPE: 'TABLE', TABLE_NAME: 't1' },
{ TABLE_TYPE: 'VIEW', TABLE_NAME: 'v1' },
{ TABLE_TYPE: 'TABLE', TABLE_NAME: 't2' },
{ TABLE_TYPE: 'SYSTEM TABLE', TABLE_NAME: 's1' },
];
function makeInner(rows: object[]): IOperationBackend {
return {
id: 'fake',
hasResultSet: true,
async fetchChunk() { return rows; },
async hasMore() { return false; },
async waitUntilReady() {},
async status() { return {} as any; },
async getResultMetadata() { return {} as any; },
async cancel() { return {} as any; },
async close() { return {} as any; },
};
}
it('keeps only rows whose TABLE_TYPE is in the allowed set', async () => {
const filter = new SeaTableTypeFilter(makeInner(MIXED_ROWS), new Set(['TABLE']));
const rows = await filter.fetchChunk({ limit: 100 });
expect(rows).to.have.length(2);
expect(rows.every((r) => (r as Record<string, unknown>).TABLE_TYPE === 'TABLE')).to.be.true;
});
it('returns empty array when allowedTypes is an empty set', async () => {
const filter = new SeaTableTypeFilter(makeInner(MIXED_ROWS), new Set());
const rows = await filter.fetchChunk({ limit: 100 });
expect(rows).to.have.length(0);
});
});