@polyglot-sql/sdk 0.3.10 → 0.4.0
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 +40 -0
- package/dist/cdn/polyglot.esm.js +1618 -1543
- package/dist/index.cjs +144 -32
- package/dist/index.d.cts +98 -8
- package/dist/index.d.ts +98 -8
- package/dist/index.js +159 -31
- package/dist/polyglot_sql_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -144,31 +144,34 @@ class WasmCaseBuilder {
|
|
|
144
144
|
return this;
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* Generate SQL string
|
|
147
|
+
* Generate SQL string for the given dialect.
|
|
148
|
+
* @param {string} dialect
|
|
148
149
|
* @returns {string}
|
|
149
150
|
*/
|
|
150
|
-
to_sql() {
|
|
151
|
-
let
|
|
152
|
-
let
|
|
151
|
+
to_sql(dialect) {
|
|
152
|
+
let deferred3_0;
|
|
153
|
+
let deferred3_1;
|
|
153
154
|
try {
|
|
154
155
|
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
155
|
-
wasm$3.
|
|
156
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
wasm$3.wasmcasebuilder_to_sql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
156
159
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
157
160
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
158
161
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
159
162
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
160
|
-
var
|
|
161
|
-
var
|
|
163
|
+
var ptr2 = r0;
|
|
164
|
+
var len2 = r1;
|
|
162
165
|
if (r3) {
|
|
163
|
-
|
|
166
|
+
ptr2 = 0; len2 = 0;
|
|
164
167
|
throw takeObject(r2);
|
|
165
168
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return getStringFromWasm0(
|
|
169
|
+
deferred3_0 = ptr2;
|
|
170
|
+
deferred3_1 = len2;
|
|
171
|
+
return getStringFromWasm0(ptr2, len2);
|
|
169
172
|
} finally {
|
|
170
173
|
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
171
|
-
wasm$3.__wbindgen_export4(
|
|
174
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
/**
|
|
@@ -557,31 +560,34 @@ class WasmExpr {
|
|
|
557
560
|
}
|
|
558
561
|
}
|
|
559
562
|
/**
|
|
560
|
-
* Generate SQL string
|
|
563
|
+
* Generate SQL string for the given dialect.
|
|
564
|
+
* @param {string} dialect
|
|
561
565
|
* @returns {string}
|
|
562
566
|
*/
|
|
563
|
-
to_sql() {
|
|
564
|
-
let
|
|
565
|
-
let
|
|
567
|
+
to_sql(dialect) {
|
|
568
|
+
let deferred3_0;
|
|
569
|
+
let deferred3_1;
|
|
566
570
|
try {
|
|
567
571
|
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
568
|
-
wasm$3.
|
|
572
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
573
|
+
const len0 = WASM_VECTOR_LEN;
|
|
574
|
+
wasm$3.wasmexpr_to_sql(retptr, this.__wbg_ptr, ptr0, len0);
|
|
569
575
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
570
576
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
571
577
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
572
578
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
573
|
-
var
|
|
574
|
-
var
|
|
579
|
+
var ptr2 = r0;
|
|
580
|
+
var len2 = r1;
|
|
575
581
|
if (r3) {
|
|
576
|
-
|
|
582
|
+
ptr2 = 0; len2 = 0;
|
|
577
583
|
throw takeObject(r2);
|
|
578
584
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return getStringFromWasm0(
|
|
585
|
+
deferred3_0 = ptr2;
|
|
586
|
+
deferred3_1 = len2;
|
|
587
|
+
return getStringFromWasm0(ptr2, len2);
|
|
582
588
|
} finally {
|
|
583
589
|
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
584
|
-
wasm$3.__wbindgen_export4(
|
|
590
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
585
591
|
}
|
|
586
592
|
}
|
|
587
593
|
/**
|
|
@@ -2382,6 +2388,87 @@ function lineage_sql_with_schema$1(sql, column, schema_json, dialect, trim_selec
|
|
|
2382
2388
|
}
|
|
2383
2389
|
}
|
|
2384
2390
|
|
|
2391
|
+
/**
|
|
2392
|
+
* Build an OpenLineage columnLineage facet and dataset payload.
|
|
2393
|
+
* @param {string} sql
|
|
2394
|
+
* @param {string} options_json
|
|
2395
|
+
* @returns {string}
|
|
2396
|
+
*/
|
|
2397
|
+
function openlineage_column_lineage$1(sql, options_json) {
|
|
2398
|
+
let deferred3_0;
|
|
2399
|
+
let deferred3_1;
|
|
2400
|
+
try {
|
|
2401
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2402
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2403
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2404
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2405
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2406
|
+
wasm$3.openlineage_column_lineage(retptr, ptr0, len0, ptr1, len1);
|
|
2407
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2408
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2409
|
+
deferred3_0 = r0;
|
|
2410
|
+
deferred3_1 = r1;
|
|
2411
|
+
return getStringFromWasm0(r0, r1);
|
|
2412
|
+
} finally {
|
|
2413
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2414
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/**
|
|
2419
|
+
* Build an OpenLineage JobEvent payload. This does not send the event.
|
|
2420
|
+
* @param {string} sql
|
|
2421
|
+
* @param {string} options_json
|
|
2422
|
+
* @returns {string}
|
|
2423
|
+
*/
|
|
2424
|
+
function openlineage_job_event$1(sql, options_json) {
|
|
2425
|
+
let deferred3_0;
|
|
2426
|
+
let deferred3_1;
|
|
2427
|
+
try {
|
|
2428
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2429
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2430
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2431
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2432
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2433
|
+
wasm$3.openlineage_job_event(retptr, ptr0, len0, ptr1, len1);
|
|
2434
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2435
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2436
|
+
deferred3_0 = r0;
|
|
2437
|
+
deferred3_1 = r1;
|
|
2438
|
+
return getStringFromWasm0(r0, r1);
|
|
2439
|
+
} finally {
|
|
2440
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2441
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
/**
|
|
2446
|
+
* Build an OpenLineage RunEvent payload. This does not send the event.
|
|
2447
|
+
* @param {string} sql
|
|
2448
|
+
* @param {string} options_json
|
|
2449
|
+
* @returns {string}
|
|
2450
|
+
*/
|
|
2451
|
+
function openlineage_run_event$1(sql, options_json) {
|
|
2452
|
+
let deferred3_0;
|
|
2453
|
+
let deferred3_1;
|
|
2454
|
+
try {
|
|
2455
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2456
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2457
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2458
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2459
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2460
|
+
wasm$3.openlineage_run_event(retptr, ptr0, len0, ptr1, len1);
|
|
2461
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2462
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2463
|
+
deferred3_0 = r0;
|
|
2464
|
+
deferred3_1 = r1;
|
|
2465
|
+
return getStringFromWasm0(r0, r1);
|
|
2466
|
+
} finally {
|
|
2467
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2468
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2385
2472
|
/**
|
|
2386
2473
|
* Parse SQL into an AST (returned as JSON).
|
|
2387
2474
|
*
|
|
@@ -3570,6 +3657,9 @@ const get_dialects = __vite__wasmModule.get_dialects;
|
|
|
3570
3657
|
const get_dialects_value = __vite__wasmModule.get_dialects_value;
|
|
3571
3658
|
const lineage_sql = __vite__wasmModule.lineage_sql;
|
|
3572
3659
|
const lineage_sql_with_schema = __vite__wasmModule.lineage_sql_with_schema;
|
|
3660
|
+
const openlineage_column_lineage = __vite__wasmModule.openlineage_column_lineage;
|
|
3661
|
+
const openlineage_job_event = __vite__wasmModule.openlineage_job_event;
|
|
3662
|
+
const openlineage_run_event = __vite__wasmModule.openlineage_run_event;
|
|
3573
3663
|
const parse$1 = __vite__wasmModule.parse;
|
|
3574
3664
|
const parse_value = __vite__wasmModule.parse_value;
|
|
3575
3665
|
const plan$1 = __vite__wasmModule.plan;
|
|
@@ -3762,6 +3852,9 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3762
3852
|
lineage_sql,
|
|
3763
3853
|
lineage_sql_with_schema,
|
|
3764
3854
|
memory,
|
|
3855
|
+
openlineage_column_lineage,
|
|
3856
|
+
openlineage_job_event,
|
|
3857
|
+
openlineage_run_event,
|
|
3765
3858
|
parse: parse$1,
|
|
3766
3859
|
parse_value,
|
|
3767
3860
|
plan: plan$1,
|
|
@@ -3948,6 +4041,9 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
3948
4041
|
get_dialects_value: get_dialects_value$1,
|
|
3949
4042
|
lineage_sql: lineage_sql$1,
|
|
3950
4043
|
lineage_sql_with_schema: lineage_sql_with_schema$1,
|
|
4044
|
+
openlineage_column_lineage: openlineage_column_lineage$1,
|
|
4045
|
+
openlineage_job_event: openlineage_job_event$1,
|
|
4046
|
+
openlineage_run_event: openlineage_run_event$1,
|
|
3951
4047
|
parse: parse$2,
|
|
3952
4048
|
parse_value: parse_value$1,
|
|
3953
4049
|
plan: plan$2,
|
|
@@ -4831,9 +4927,9 @@ class Expr {
|
|
|
4831
4927
|
return new Expr(this._w.desc());
|
|
4832
4928
|
}
|
|
4833
4929
|
// -- Output --
|
|
4834
|
-
/** Generate SQL string
|
|
4835
|
-
toSql() {
|
|
4836
|
-
return this._w.to_sql();
|
|
4930
|
+
/** Generate SQL string. Defaults to generic dialect. */
|
|
4931
|
+
toSql(dialect = "generic") {
|
|
4932
|
+
return this._w.to_sql(dialect);
|
|
4837
4933
|
}
|
|
4838
4934
|
/** Return the expression AST as a plain JS object. */
|
|
4839
4935
|
toJSON() {
|
|
@@ -5369,9 +5465,9 @@ class CaseBuilder {
|
|
|
5369
5465
|
build() {
|
|
5370
5466
|
return new Expr(this._w.build_expr());
|
|
5371
5467
|
}
|
|
5372
|
-
/** Generate SQL string
|
|
5373
|
-
toSql() {
|
|
5374
|
-
return this._w.to_sql();
|
|
5468
|
+
/** Generate SQL string. Defaults to generic dialect. */
|
|
5469
|
+
toSql(dialect = "generic") {
|
|
5470
|
+
return this._w.to_sql(dialect);
|
|
5375
5471
|
}
|
|
5376
5472
|
}
|
|
5377
5473
|
function caseWhen() {
|
|
@@ -5602,6 +5698,35 @@ function getSourceTables(column, sql, dialect = "generic") {
|
|
|
5602
5698
|
return JSON.parse(resultJson);
|
|
5603
5699
|
}
|
|
5604
5700
|
|
|
5701
|
+
function normalizeOptions(options) {
|
|
5702
|
+
return {
|
|
5703
|
+
dialect: "generic",
|
|
5704
|
+
datasetMappings: {},
|
|
5705
|
+
...options
|
|
5706
|
+
};
|
|
5707
|
+
}
|
|
5708
|
+
function openLineageColumnLineage(sql, options) {
|
|
5709
|
+
const resultJson = openlineage_column_lineage$1(
|
|
5710
|
+
sql,
|
|
5711
|
+
JSON.stringify(normalizeOptions(options))
|
|
5712
|
+
);
|
|
5713
|
+
return JSON.parse(resultJson);
|
|
5714
|
+
}
|
|
5715
|
+
function openLineageJobEvent(sql, options) {
|
|
5716
|
+
const resultJson = openlineage_job_event$1(
|
|
5717
|
+
sql,
|
|
5718
|
+
JSON.stringify(normalizeOptions(options))
|
|
5719
|
+
);
|
|
5720
|
+
return JSON.parse(resultJson);
|
|
5721
|
+
}
|
|
5722
|
+
function openLineageRunEvent(sql, options) {
|
|
5723
|
+
const resultJson = openlineage_run_event$1(
|
|
5724
|
+
sql,
|
|
5725
|
+
JSON.stringify(normalizeOptions(options))
|
|
5726
|
+
);
|
|
5727
|
+
return JSON.parse(resultJson);
|
|
5728
|
+
}
|
|
5729
|
+
|
|
5605
5730
|
function diff(source, target, dialect = "generic", options = {}) {
|
|
5606
5731
|
const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
|
|
5607
5732
|
const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
|
|
@@ -5897,6 +6022,9 @@ const index = {
|
|
|
5897
6022
|
lineage: lineage,
|
|
5898
6023
|
lineageWithSchema: lineageWithSchema,
|
|
5899
6024
|
getSourceTables: getSourceTables,
|
|
6025
|
+
openLineageColumnLineage: openLineageColumnLineage,
|
|
6026
|
+
openLineageJobEvent: openLineageJobEvent,
|
|
6027
|
+
openLineageRunEvent: openLineageRunEvent,
|
|
5900
6028
|
diff: diff,
|
|
5901
6029
|
hasChanges: hasChanges,
|
|
5902
6030
|
changesOnly: changesOnly,
|
|
@@ -5905,4 +6033,4 @@ const index = {
|
|
|
5905
6033
|
Polyglot
|
|
5906
6034
|
};
|
|
5907
6035
|
|
|
5908
|
-
export { CaseBuilder, DeleteBuilder, Dialect, Expr, InsertBuilder, MergeBuilder, Polyglot, SelectBuilder, SetOpBuilder, UpdateBuilder, ValidationSeverity, WindowDefBuilder, abs, alias, and, annotateTypes, index$1 as ast, avg, boolean, caseOf, caseWhen, cast, ceil, changesOnly, coalesce, col, concatWs, condition, count, countDistinct, currentDate, currentTime, currentTimestamp, index as default, del, deleteFrom, denseRank, diff, except, exp, extract, findAll, floor, format, formatWithOptions, func, generate, getColumns, getDialects, getInferredType, getSourceTables, getVersion, greatest, hasChanges, ifNull, init, initcap, insert, insertInto, intersect, isColumn, isFunction, isInitialized, isLiteral, isSelect, least, length, lineage, lineageWithSchema, lit, ln, lower, ltrim, max, mergeInto, min, not, nullIf, or, parse, plan, power, rank, renameColumns, replace, reverse, round, rowNumber, rtrim, select, sign, sqlExpr, sqlNull, sqrt, star, subquery, substring, sum, table, tokenize, transform, transpile, trim, union, unionAll, update, upper, validate, validateWithSchema, walk };
|
|
6036
|
+
export { CaseBuilder, DeleteBuilder, Dialect, Expr, InsertBuilder, MergeBuilder, Polyglot, SelectBuilder, SetOpBuilder, UpdateBuilder, ValidationSeverity, WindowDefBuilder, abs, alias, and, annotateTypes, index$1 as ast, avg, boolean, caseOf, caseWhen, cast, ceil, changesOnly, coalesce, col, concatWs, condition, count, countDistinct, currentDate, currentTime, currentTimestamp, index as default, del, deleteFrom, denseRank, diff, except, exp, extract, findAll, floor, format, formatWithOptions, func, generate, getColumns, getDialects, getInferredType, getSourceTables, getVersion, greatest, hasChanges, ifNull, init, initcap, insert, insertInto, intersect, isColumn, isFunction, isInitialized, isLiteral, isSelect, least, length, lineage, lineageWithSchema, lit, ln, lower, ltrim, max, mergeInto, min, not, nullIf, openLineageColumnLineage, openLineageJobEvent, openLineageRunEvent, or, parse, plan, power, rank, renameColumns, replace, reverse, round, rowNumber, rtrim, select, sign, sqlExpr, sqlNull, sqrt, star, subquery, substring, sum, table, tokenize, transform, transpile, trim, union, unionAll, update, upper, validate, validateWithSchema, walk };
|
|
Binary file
|