@polyglot-sql/sdk 0.5.1 → 0.5.2

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.
package/README.md CHANGED
@@ -604,24 +604,32 @@ are marked as `virtual`.
604
604
  ## Compact Query Analysis
605
605
 
606
606
  Use `analyzeQuery` when you need summary facts instead of the full AST or full
607
- lineage graph:
607
+ lineage graph. `relations` contains sources visible in the analyzed scope;
608
+ `baseTables` contains deduplicated physical dependencies across nested CTEs,
609
+ derived tables, subqueries, and set-operation branches. With a schema,
610
+ parseable detailed type strings such as `DECIMAL(10,2)` are preserved in
611
+ projection `typeHint` values.
608
612
 
609
613
  ```typescript
610
614
  import { analyzeQuery, Dialect } from '@polyglot-sql/sdk';
611
615
 
612
- const result = analyzeQuery('SELECT CAST(total AS TEXT) AS total_text FROM orders', {
616
+ const result = analyzeQuery('SELECT SUM(o.amount) AS total FROM orders AS o', {
613
617
  dialect: Dialect.Generic,
614
618
  schema: {
615
619
  tables: [
616
- { name: 'orders', columns: [{ name: 'total', type: 'INT' }] },
620
+ { name: 'orders', columns: [{ name: 'amount', type: 'DECIMAL(10,2)' }] },
617
621
  ],
618
622
  },
619
623
  });
620
624
 
621
625
  if (result.success) {
622
- console.log(result.analysis.projections[0].transformKind); // 'cast'
623
- console.log(result.analysis.relations[0].name); // 'orders'
626
+ console.log(result.analysis.projections[0].transformKind); // 'aggregation'
627
+ console.log(result.analysis.projections[0].typeHint); // 'DECIMAL(10, 2)'
628
+ console.log(result.analysis.baseTables[0].name); // 'orders'
629
+ console.log(result.analysis.baseTables[0].alias); // 'o'
624
630
  }
631
+
632
+ const duckdbSummary = analyzeQuery('SELECT 1', Dialect.DuckDB);
625
633
  ```
626
634
 
627
635
  ## OpenLineage Output
@@ -743,7 +751,7 @@ const formattedSafe = pg.formatWithOptions('SELECT a,b FROM t', Dialect.Generic,
743
751
  | `lineage(column, sql, dialect?, trimSelects?)` | Trace column lineage through a query |
744
752
  | `lineageWithSchema(column, sql, schema, dialect?, trimSelects?)` | Trace lineage with schema-based qualification |
745
753
  | `getSourceTables(column, sql, dialect?)` | Get source tables for a column |
746
- | `analyzeQuery(sql, options?)` | Return compact projection, relation, CTE, set-operation, and upstream-reference facts |
754
+ | `analyzeQuery(sql, optionsOrDialect?)` | Return compact projection, visible relation, transitive base-table, CTE, set-operation, and upstream-reference facts |
747
755
  | `openLineageColumnLineage(sql, options)` | Build an OpenLineage columnLineage facet and datasets |
748
756
  | `openLineageJobEvent(sql, options)` | Build an OpenLineage JobEvent payload |
749
757
  | `openLineageRunEvent(sql, options)` | Build an OpenLineage RunEvent payload |