Polyglot SQL API Documentation - v0.2.0
    Preparing search index...

    Function lineageWithSchema

    • Trace the lineage of a column through a SQL query using schema metadata.

      When a schema is provided, columns are fully qualified and type-annotated. Each LineageNode.expression will have its inferred_type field populated with the resolved SQL data type. Use ast.getInferredType(node.expression) to read it.

      Parameters

      • column: string

        Column name to trace

      • sql: string

        SQL string to analyze

      • schema: Schema

        ValidationSchema-compatible schema object

      • dialect: string = 'generic'

        Dialect for parsing/qualification (default: 'generic')

      • trimSelects: boolean = false

        Trim SELECT to only target column (default: false)

      Returns LineageResult

      import { lineageWithSchema, ast } from '@polyglot-sql/sdk';

      const result = lineageWithSchema("name", "SELECT name FROM users", {
      tables: { users: { name: "TEXT", id: "INT" } }
      });

      if (result.success) {
      const dt = ast.getInferredType(result.lineage!.expression);
      // dt => { data_type: "text" }
      }