import { ColumnDefinition } from '../ExpressionType.js'; import { QuerySchema, SourceSchemaTable } from '../types.js'; import { AvailableTable } from './sql_filters.js'; /** * Exposes a list of {@link SourceSchemaTable}s as a {@link QuerySchema} by only exposing the subset of the schema * referenced in a `FROM` clause. * @deprecated Legacy Sync Rules (`bucket_definitions`) implementation, kept for backwards compatibility until the next major version. See `src/legacy/README.md`. */ export class TableQuerySchema implements QuerySchema { constructor( private tables: SourceSchemaTable[], private alias: AvailableTable ) {} getColumn(table: string, column: string): ColumnDefinition | undefined { if (table != this.alias.nameInSchema) { return undefined; } for (let table of this.tables) { const t = table.getColumn(column); if (t != null) { return t; } } return undefined; } getColumns(table: string): ColumnDefinition[] { if (table != this.alias.nameInSchema) { return []; } let columns: Record = {}; for (let table of this.tables) { for (let col of table.getColumns()) { if (!(col.name in columns)) { columns[col.name] = col; } } } return Object.values(columns); } }