UNPKG

@meta-sql/lineage

Version:

Library for processing lineage from SQL

64 lines (60 loc) 2.82 kB
import { Transformation as Transformation$1, InputField, ColumnLineageDatasetFacet } from '@meta-sql/open-lineage'; import { Select, Column as Column$1, ColumnRefItem, ExpressionValue, BaseFrom } from 'node-sql-parser'; declare class HashSet<T> implements Set<T> { private map; private hasher; constructor(hasher?: (value: T) => string); forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: unknown): void; entries(): SetIterator<[T, T]>; keys(): SetIterator<T>; values(): SetIterator<T>; [Symbol.iterator](): SetIterator<T>; [Symbol.toStringTag]: string; get size(): number; add(value: T): this; delete(value: T): boolean; clear(): this; has(value: T): boolean; intersection(other: Set<T>): HashSet<T>; } type Transformation = Exclude<Transformation$1, "masking"> & { masking: boolean; }; declare const DIRECT_TRANSFORMATION: Transformation; declare const DIRECT_IDENTITY: Transformation; declare const DIRECT_AGGREGATION: Transformation; declare class TransformationSet extends HashSet<Transformation> { constructor(values?: readonly Transformation[]); } type Column = { name: string; }; type Table = { name: string; columns: string[]; }; type Schema = { namespace: string; tables: Table[]; }; type InputColumn = { name: string; table?: string; }; type SelectWithAlias = Select & { as?: string | null; }; declare function isColumn(selectColumn: Select["columns"][number]): selectColumn is Column$1; declare function formatInputColumnName(column: ColumnRefItem): string; declare function parseInputColumnName(column: string): InputColumn; declare function getInputColumnName(column: ColumnRefItem): string | null; declare function getOutputColumnName(column: Column$1): string | null; declare function getDirectTransformationsFromExprValue(expr: ExpressionValue, parentTransformation?: Transformation): Record<string, TransformationSet>; declare function getTableExpressionsFromSelect(select: Select): { regularTables: BaseFrom[]; selectTables: SelectWithAlias[]; }; declare function mergeTransformationSet(parent: TransformationSet, child: TransformationSet): TransformationSet; declare function getColumnLineage(select: Select, schema: Schema, column: Column$1, transformations?: TransformationSet): InputField[]; declare function getLineage(select: Select, schema: Schema): ColumnLineageDatasetFacet["fields"]; export { type Column, DIRECT_AGGREGATION, DIRECT_IDENTITY, DIRECT_TRANSFORMATION, type InputColumn, type Schema, type SelectWithAlias, type Table, formatInputColumnName, getColumnLineage, getDirectTransformationsFromExprValue, getInputColumnName, getLineage, getOutputColumnName, getTableExpressionsFromSelect, isColumn, mergeTransformationSet, parseInputColumnName };