@polyglot-sql/sdk 0.1.10 → 0.1.11
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 +15 -1
- package/dist/cdn/polyglot.esm.js +1378 -1353
- package/dist/index.cjs +40 -0
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +59 -1
- package/dist/polyglot_sql_wasm_bg.wasm +0 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -532,7 +532,7 @@ if (!result.success) {
|
|
|
532
532
|
Trace how columns flow through SQL queries, from source tables to the result set.
|
|
533
533
|
|
|
534
534
|
```typescript
|
|
535
|
-
import { lineage, getSourceTables } from '@polyglot-sql/sdk';
|
|
535
|
+
import { lineage, lineageWithSchema, getSourceTables } from '@polyglot-sql/sdk';
|
|
536
536
|
|
|
537
537
|
// Trace a column through joins, CTEs, and subqueries
|
|
538
538
|
const result = lineage('total', 'SELECT o.total FROM orders o JOIN users u ON o.user_id = u.id');
|
|
@@ -541,6 +541,19 @@ if (result.success) {
|
|
|
541
541
|
console.log(result.lineage.downstream); // source nodes
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
// Schema-aware lineage (same schema format as validateWithSchema)
|
|
545
|
+
const schema = {
|
|
546
|
+
tables: [
|
|
547
|
+
{ name: 'users', columns: [{ name: 'id', type: 'INT' }] },
|
|
548
|
+
{ name: 'orders', columns: [{ name: 'user_id', type: 'INT' }] },
|
|
549
|
+
],
|
|
550
|
+
};
|
|
551
|
+
const schemaLineage = lineageWithSchema(
|
|
552
|
+
'id',
|
|
553
|
+
'SELECT id FROM users u JOIN orders o ON u.id = o.user_id',
|
|
554
|
+
schema,
|
|
555
|
+
);
|
|
556
|
+
|
|
544
557
|
// Get all source tables that contribute to a column
|
|
545
558
|
const tables = getSourceTables('total', 'SELECT o.total FROM orders o JOIN users u ON o.user_id = u.id');
|
|
546
559
|
if (tables.success) {
|
|
@@ -625,6 +638,7 @@ const formattedSafe = pg.formatWithOptions('SELECT a,b FROM t', Dialect.Generic,
|
|
|
625
638
|
| Function | Description |
|
|
626
639
|
|----------|-------------|
|
|
627
640
|
| `lineage(column, sql, dialect?, trimSelects?)` | Trace column lineage through a query |
|
|
641
|
+
| `lineageWithSchema(column, sql, schema, dialect?, trimSelects?)` | Trace lineage with schema-based qualification |
|
|
628
642
|
| `getSourceTables(column, sql, dialect?)` | Get source tables for a column |
|
|
629
643
|
| `diff(source, target, dialect?, options?)` | Diff two SQL statements |
|
|
630
644
|
| `hasChanges(edits)` | Check if diff has non-keep edits |
|