@polyglot-sql/sdk 0.4.3 → 0.5.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 +22 -1
- package/dist/cdn/polyglot.esm.js +1535 -1508
- package/dist/index.cjs +123 -64
- package/dist/index.d.cts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +143 -68
- package/dist/index.node.js +121 -64
- package/dist/manual.js +139 -68
- package/dist/polyglot_sql.wasm +0 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2227,6 +2227,40 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
|
|
|
2227
2227
|
const ret = wasm$3.transpile_value(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2228
2228
|
return takeObject(ret);
|
|
2229
2229
|
}
|
|
2230
|
+
function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
|
|
2231
|
+
let deferred5_0;
|
|
2232
|
+
let deferred5_1;
|
|
2233
|
+
try {
|
|
2234
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2235
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2236
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2237
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2238
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2239
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2240
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2241
|
+
const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2242
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2243
|
+
wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
2244
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2245
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2246
|
+
deferred5_0 = r0;
|
|
2247
|
+
deferred5_1 = r1;
|
|
2248
|
+
return getStringFromWasm0(r0, r1);
|
|
2249
|
+
} finally {
|
|
2250
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2251
|
+
wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
|
|
2255
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2256
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2257
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2258
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2259
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2260
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2261
|
+
const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
|
|
2262
|
+
return takeObject(ret);
|
|
2263
|
+
}
|
|
2230
2264
|
function validate$2(sql, dialect) {
|
|
2231
2265
|
let deferred3_0;
|
|
2232
2266
|
let deferred3_1;
|
|
@@ -3021,6 +3055,8 @@ async function __polyglot_init_wasm() {
|
|
|
3021
3055
|
tokenize_value = __vite__wasmModule.tokenize_value;
|
|
3022
3056
|
transpile$1 = __vite__wasmModule.transpile;
|
|
3023
3057
|
transpile_value = __vite__wasmModule.transpile_value;
|
|
3058
|
+
transpile_with_options = __vite__wasmModule.transpile_with_options;
|
|
3059
|
+
transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
|
|
3024
3060
|
validate$1 = __vite__wasmModule.validate;
|
|
3025
3061
|
validate_with_options = __vite__wasmModule.validate_with_options;
|
|
3026
3062
|
validate_with_schema = __vite__wasmModule.validate_with_schema;
|
|
@@ -3212,6 +3248,8 @@ let tokenize$1;
|
|
|
3212
3248
|
let tokenize_value;
|
|
3213
3249
|
let transpile$1;
|
|
3214
3250
|
let transpile_value;
|
|
3251
|
+
let transpile_with_options;
|
|
3252
|
+
let transpile_with_options_value;
|
|
3215
3253
|
let validate$1;
|
|
3216
3254
|
let validate_with_options;
|
|
3217
3255
|
let validate_with_schema;
|
|
@@ -3406,6 +3444,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3406
3444
|
tokenize_value,
|
|
3407
3445
|
transpile: transpile$1,
|
|
3408
3446
|
transpile_value,
|
|
3447
|
+
transpile_with_options,
|
|
3448
|
+
transpile_with_options_value,
|
|
3409
3449
|
validate: validate$1,
|
|
3410
3450
|
validate_with_options,
|
|
3411
3451
|
validate_with_schema,
|
|
@@ -3590,6 +3630,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3590
3630
|
tokenize_value: tokenize_value$1,
|
|
3591
3631
|
transpile: transpile$2,
|
|
3592
3632
|
transpile_value: transpile_value$1,
|
|
3633
|
+
transpile_with_options: transpile_with_options$1,
|
|
3634
|
+
transpile_with_options_value: transpile_with_options_value$1,
|
|
3593
3635
|
validate: validate$2,
|
|
3594
3636
|
validate_with_options: validate_with_options$1,
|
|
3595
3637
|
validate_with_schema: validate_with_schema$1,
|
|
@@ -5055,6 +5097,67 @@ function intersect(left, right) {
|
|
|
5055
5097
|
function except(left, right) {
|
|
5056
5098
|
return left.except(right);
|
|
5057
5099
|
}
|
|
5100
|
+
function diff(source, target, dialect = "generic", options = {}) {
|
|
5101
|
+
const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
|
|
5102
|
+
const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
|
|
5103
|
+
return JSON.parse(resultJson);
|
|
5104
|
+
}
|
|
5105
|
+
function hasChanges(edits) {
|
|
5106
|
+
return edits.some((e) => e.type !== "keep");
|
|
5107
|
+
}
|
|
5108
|
+
function changesOnly(edits) {
|
|
5109
|
+
return edits.filter((e) => e.type !== "keep");
|
|
5110
|
+
}
|
|
5111
|
+
function lineage(column, sql, dialect = "generic", trimSelects = false) {
|
|
5112
|
+
const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
|
|
5113
|
+
return JSON.parse(resultJson);
|
|
5114
|
+
}
|
|
5115
|
+
function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
|
|
5116
|
+
const resultJson = lineage_sql_with_schema$1(
|
|
5117
|
+
sql,
|
|
5118
|
+
column,
|
|
5119
|
+
JSON.stringify(schema),
|
|
5120
|
+
dialect,
|
|
5121
|
+
trimSelects
|
|
5122
|
+
);
|
|
5123
|
+
return JSON.parse(resultJson);
|
|
5124
|
+
}
|
|
5125
|
+
function getSourceTables(column, sql, dialect = "generic") {
|
|
5126
|
+
const resultJson = source_tables$1(sql, column, dialect);
|
|
5127
|
+
return JSON.parse(resultJson);
|
|
5128
|
+
}
|
|
5129
|
+
function normalizeOptions(options) {
|
|
5130
|
+
return {
|
|
5131
|
+
dialect: "generic",
|
|
5132
|
+
datasetMappings: {},
|
|
5133
|
+
...options
|
|
5134
|
+
};
|
|
5135
|
+
}
|
|
5136
|
+
function openLineageColumnLineage(sql, options) {
|
|
5137
|
+
const resultJson = openlineage_column_lineage$1(
|
|
5138
|
+
sql,
|
|
5139
|
+
JSON.stringify(normalizeOptions(options))
|
|
5140
|
+
);
|
|
5141
|
+
return JSON.parse(resultJson);
|
|
5142
|
+
}
|
|
5143
|
+
function openLineageJobEvent(sql, options) {
|
|
5144
|
+
const resultJson = openlineage_job_event$1(
|
|
5145
|
+
sql,
|
|
5146
|
+
JSON.stringify(normalizeOptions(options))
|
|
5147
|
+
);
|
|
5148
|
+
return JSON.parse(resultJson);
|
|
5149
|
+
}
|
|
5150
|
+
function openLineageRunEvent(sql, options) {
|
|
5151
|
+
const resultJson = openlineage_run_event$1(
|
|
5152
|
+
sql,
|
|
5153
|
+
JSON.stringify(normalizeOptions(options))
|
|
5154
|
+
);
|
|
5155
|
+
return JSON.parse(resultJson);
|
|
5156
|
+
}
|
|
5157
|
+
function plan(sql, dialect = "generic") {
|
|
5158
|
+
const resultJson = plan$2(sql, dialect);
|
|
5159
|
+
return JSON.parse(resultJson);
|
|
5160
|
+
}
|
|
5058
5161
|
function validateSemantics(expr, options) {
|
|
5059
5162
|
const errors = [];
|
|
5060
5163
|
if (getExprType(expr) === "select") {
|
|
@@ -5206,67 +5309,6 @@ function validate(sql, dialect = "generic", options = {}) {
|
|
|
5206
5309
|
errors: allErrors
|
|
5207
5310
|
};
|
|
5208
5311
|
}
|
|
5209
|
-
function lineage(column, sql, dialect = "generic", trimSelects = false) {
|
|
5210
|
-
const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
|
|
5211
|
-
return JSON.parse(resultJson);
|
|
5212
|
-
}
|
|
5213
|
-
function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
|
|
5214
|
-
const resultJson = lineage_sql_with_schema$1(
|
|
5215
|
-
sql,
|
|
5216
|
-
column,
|
|
5217
|
-
JSON.stringify(schema),
|
|
5218
|
-
dialect,
|
|
5219
|
-
trimSelects
|
|
5220
|
-
);
|
|
5221
|
-
return JSON.parse(resultJson);
|
|
5222
|
-
}
|
|
5223
|
-
function getSourceTables(column, sql, dialect = "generic") {
|
|
5224
|
-
const resultJson = source_tables$1(sql, column, dialect);
|
|
5225
|
-
return JSON.parse(resultJson);
|
|
5226
|
-
}
|
|
5227
|
-
function normalizeOptions(options) {
|
|
5228
|
-
return {
|
|
5229
|
-
dialect: "generic",
|
|
5230
|
-
datasetMappings: {},
|
|
5231
|
-
...options
|
|
5232
|
-
};
|
|
5233
|
-
}
|
|
5234
|
-
function openLineageColumnLineage(sql, options) {
|
|
5235
|
-
const resultJson = openlineage_column_lineage$1(
|
|
5236
|
-
sql,
|
|
5237
|
-
JSON.stringify(normalizeOptions(options))
|
|
5238
|
-
);
|
|
5239
|
-
return JSON.parse(resultJson);
|
|
5240
|
-
}
|
|
5241
|
-
function openLineageJobEvent(sql, options) {
|
|
5242
|
-
const resultJson = openlineage_job_event$1(
|
|
5243
|
-
sql,
|
|
5244
|
-
JSON.stringify(normalizeOptions(options))
|
|
5245
|
-
);
|
|
5246
|
-
return JSON.parse(resultJson);
|
|
5247
|
-
}
|
|
5248
|
-
function openLineageRunEvent(sql, options) {
|
|
5249
|
-
const resultJson = openlineage_run_event$1(
|
|
5250
|
-
sql,
|
|
5251
|
-
JSON.stringify(normalizeOptions(options))
|
|
5252
|
-
);
|
|
5253
|
-
return JSON.parse(resultJson);
|
|
5254
|
-
}
|
|
5255
|
-
function diff(source, target, dialect = "generic", options = {}) {
|
|
5256
|
-
const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
|
|
5257
|
-
const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
|
|
5258
|
-
return JSON.parse(resultJson);
|
|
5259
|
-
}
|
|
5260
|
-
function hasChanges(edits) {
|
|
5261
|
-
return edits.some((e) => e.type !== "keep");
|
|
5262
|
-
}
|
|
5263
|
-
function changesOnly(edits) {
|
|
5264
|
-
return edits.filter((e) => e.type !== "keep");
|
|
5265
|
-
}
|
|
5266
|
-
function plan(sql, dialect = "generic") {
|
|
5267
|
-
const resultJson = plan$2(sql, dialect);
|
|
5268
|
-
return JSON.parse(resultJson);
|
|
5269
|
-
}
|
|
5270
5312
|
var Dialect = /* @__PURE__ */ ((Dialect2) => {
|
|
5271
5313
|
Dialect2["Generic"] = "generic";
|
|
5272
5314
|
Dialect2["PostgreSQL"] = "postgresql";
|
|
@@ -5344,8 +5386,25 @@ async function init() {
|
|
|
5344
5386
|
function isInitialized() {
|
|
5345
5387
|
return !!__vite__wasmModule;
|
|
5346
5388
|
}
|
|
5347
|
-
function transpile(sql, read, write) {
|
|
5389
|
+
function transpile(sql, read, write, options) {
|
|
5348
5390
|
try {
|
|
5391
|
+
if (options && Object.keys(options).length > 0) {
|
|
5392
|
+
if (typeof wasm.transpile_with_options_value === "function") {
|
|
5393
|
+
return decodeWasmPayload(
|
|
5394
|
+
wasm.transpile_with_options_value(sql, read, write, options)
|
|
5395
|
+
);
|
|
5396
|
+
}
|
|
5397
|
+
if (typeof wasm.transpile_with_options === "function") {
|
|
5398
|
+
return JSON.parse(
|
|
5399
|
+
wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
|
|
5400
|
+
);
|
|
5401
|
+
}
|
|
5402
|
+
return {
|
|
5403
|
+
success: false,
|
|
5404
|
+
sql: void 0,
|
|
5405
|
+
error: "WASM transpile options are not available in this build"
|
|
5406
|
+
};
|
|
5407
|
+
}
|
|
5349
5408
|
if (typeof wasm.transpile_value === "function") {
|
|
5350
5409
|
return decodeWasmPayload(
|
|
5351
5410
|
wasm.transpile_value(sql, read, write)
|
|
@@ -5478,8 +5537,8 @@ class Polyglot {
|
|
|
5478
5537
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
5479
5538
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
5480
5539
|
*/
|
|
5481
|
-
transpile(sql, read, write) {
|
|
5482
|
-
return transpile(sql, read, write);
|
|
5540
|
+
transpile(sql, read, write, options) {
|
|
5541
|
+
return transpile(sql, read, write, options);
|
|
5483
5542
|
}
|
|
5484
5543
|
/**
|
|
5485
5544
|
* Parse SQL into an AST.
|
package/dist/index.d.cts
CHANGED
|
@@ -8961,6 +8961,8 @@ export declare interface LineageNode {
|
|
|
8961
8961
|
source: Expression;
|
|
8962
8962
|
downstream: LineageNode[];
|
|
8963
8963
|
source_name: string;
|
|
8964
|
+
source_kind: LineageSourceKind;
|
|
8965
|
+
source_alias?: string;
|
|
8964
8966
|
reference_node_name: string;
|
|
8965
8967
|
}
|
|
8966
8968
|
|
|
@@ -8971,6 +8973,8 @@ export declare interface LineageResult {
|
|
|
8971
8973
|
error?: string;
|
|
8972
8974
|
}
|
|
8973
8975
|
|
|
8976
|
+
export declare type LineageSourceKind = 'root' | 'table' | 'derived_table' | 'cte' | 'virtual' | 'unknown';
|
|
8977
|
+
|
|
8974
8978
|
/**
|
|
8975
8979
|
* Trace the lineage of a column through a SQL query using schema metadata.
|
|
8976
8980
|
*
|
|
@@ -10586,7 +10590,7 @@ export declare class Polyglot {
|
|
|
10586
10590
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
10587
10591
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
10588
10592
|
*/
|
|
10589
|
-
transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
|
|
10593
|
+
transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
|
|
10590
10594
|
/**
|
|
10591
10595
|
* Parse SQL into an AST.
|
|
10592
10596
|
*/
|
|
@@ -13615,11 +13619,17 @@ declare type TranslateCharacters = {
|
|
|
13615
13619
|
* // result.sql[0] = "SELECT COALESCE(a, b)"
|
|
13616
13620
|
* ```
|
|
13617
13621
|
*/
|
|
13618
|
-
export declare function transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
|
|
13622
|
+
export declare function transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
|
|
13623
|
+
|
|
13624
|
+
export declare interface TranspileOptions {
|
|
13625
|
+
/** Pretty-print the generated SQL */
|
|
13626
|
+
pretty?: boolean;
|
|
13627
|
+
/** How unsupported target-dialect constructs should be handled */
|
|
13628
|
+
unsupportedLevel?: UnsupportedLevel;
|
|
13629
|
+
/** Maximum number of unsupported diagnostics to include in raised errors */
|
|
13630
|
+
maxUnsupported?: number;
|
|
13631
|
+
}
|
|
13619
13632
|
|
|
13620
|
-
/**
|
|
13621
|
-
* Transpilation options
|
|
13622
|
-
*/
|
|
13623
13633
|
/**
|
|
13624
13634
|
* Result of a transpilation operation
|
|
13625
13635
|
*/
|
|
@@ -14167,6 +14177,11 @@ declare type UnpivotColumns = {
|
|
|
14167
14177
|
expressions: Array<Expression>;
|
|
14168
14178
|
};
|
|
14169
14179
|
|
|
14180
|
+
/**
|
|
14181
|
+
* Transpilation options
|
|
14182
|
+
*/
|
|
14183
|
+
export declare type UnsupportedLevel = 'ignore' | 'warn' | 'raise' | 'immediate';
|
|
14184
|
+
|
|
14170
14185
|
/**
|
|
14171
14186
|
* UPDATE statement
|
|
14172
14187
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -8961,6 +8961,8 @@ export declare interface LineageNode {
|
|
|
8961
8961
|
source: Expression;
|
|
8962
8962
|
downstream: LineageNode[];
|
|
8963
8963
|
source_name: string;
|
|
8964
|
+
source_kind: LineageSourceKind;
|
|
8965
|
+
source_alias?: string;
|
|
8964
8966
|
reference_node_name: string;
|
|
8965
8967
|
}
|
|
8966
8968
|
|
|
@@ -8971,6 +8973,8 @@ export declare interface LineageResult {
|
|
|
8971
8973
|
error?: string;
|
|
8972
8974
|
}
|
|
8973
8975
|
|
|
8976
|
+
export declare type LineageSourceKind = 'root' | 'table' | 'derived_table' | 'cte' | 'virtual' | 'unknown';
|
|
8977
|
+
|
|
8974
8978
|
/**
|
|
8975
8979
|
* Trace the lineage of a column through a SQL query using schema metadata.
|
|
8976
8980
|
*
|
|
@@ -10586,7 +10590,7 @@ export declare class Polyglot {
|
|
|
10586
10590
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
10587
10591
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
10588
10592
|
*/
|
|
10589
|
-
transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
|
|
10593
|
+
transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
|
|
10590
10594
|
/**
|
|
10591
10595
|
* Parse SQL into an AST.
|
|
10592
10596
|
*/
|
|
@@ -13615,11 +13619,17 @@ declare type TranslateCharacters = {
|
|
|
13615
13619
|
* // result.sql[0] = "SELECT COALESCE(a, b)"
|
|
13616
13620
|
* ```
|
|
13617
13621
|
*/
|
|
13618
|
-
export declare function transpile(sql: string, read: Dialect, write: Dialect): TranspileResult;
|
|
13622
|
+
export declare function transpile(sql: string, read: Dialect, write: Dialect, options?: TranspileOptions): TranspileResult;
|
|
13623
|
+
|
|
13624
|
+
export declare interface TranspileOptions {
|
|
13625
|
+
/** Pretty-print the generated SQL */
|
|
13626
|
+
pretty?: boolean;
|
|
13627
|
+
/** How unsupported target-dialect constructs should be handled */
|
|
13628
|
+
unsupportedLevel?: UnsupportedLevel;
|
|
13629
|
+
/** Maximum number of unsupported diagnostics to include in raised errors */
|
|
13630
|
+
maxUnsupported?: number;
|
|
13631
|
+
}
|
|
13619
13632
|
|
|
13620
|
-
/**
|
|
13621
|
-
* Transpilation options
|
|
13622
|
-
*/
|
|
13623
13633
|
/**
|
|
13624
13634
|
* Result of a transpilation operation
|
|
13625
13635
|
*/
|
|
@@ -14167,6 +14177,11 @@ declare type UnpivotColumns = {
|
|
|
14167
14177
|
expressions: Array<Expression>;
|
|
14168
14178
|
};
|
|
14169
14179
|
|
|
14180
|
+
/**
|
|
14181
|
+
* Transpilation options
|
|
14182
|
+
*/
|
|
14183
|
+
export declare type UnsupportedLevel = 'ignore' | 'warn' | 'raise' | 'immediate';
|
|
14184
|
+
|
|
14170
14185
|
/**
|
|
14171
14186
|
* UPDATE statement
|
|
14172
14187
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2694,6 +2694,58 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
|
|
|
2694
2694
|
return takeObject(ret);
|
|
2695
2695
|
}
|
|
2696
2696
|
|
|
2697
|
+
/**
|
|
2698
|
+
* Transpile SQL with explicit options encoded as a JSON string.
|
|
2699
|
+
* @param {string} sql
|
|
2700
|
+
* @param {string} read_dialect
|
|
2701
|
+
* @param {string} write_dialect
|
|
2702
|
+
* @param {string} options_json
|
|
2703
|
+
* @returns {string}
|
|
2704
|
+
*/
|
|
2705
|
+
function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
|
|
2706
|
+
let deferred5_0;
|
|
2707
|
+
let deferred5_1;
|
|
2708
|
+
try {
|
|
2709
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2710
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2711
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2712
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2713
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2714
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2715
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2716
|
+
const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2717
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2718
|
+
wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
2719
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2720
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2721
|
+
deferred5_0 = r0;
|
|
2722
|
+
deferred5_1 = r1;
|
|
2723
|
+
return getStringFromWasm0(r0, r1);
|
|
2724
|
+
} finally {
|
|
2725
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2726
|
+
wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
/**
|
|
2731
|
+
* Transpile SQL with explicit options and return a structured JS object.
|
|
2732
|
+
* @param {string} sql
|
|
2733
|
+
* @param {string} read_dialect
|
|
2734
|
+
* @param {string} write_dialect
|
|
2735
|
+
* @param {any} options
|
|
2736
|
+
* @returns {any}
|
|
2737
|
+
*/
|
|
2738
|
+
function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
|
|
2739
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2740
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2741
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2742
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2743
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2744
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2745
|
+
const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
|
|
2746
|
+
return takeObject(ret);
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2697
2749
|
/**
|
|
2698
2750
|
* Validate SQL syntax.
|
|
2699
2751
|
*
|
|
@@ -3667,6 +3719,8 @@ const tokenize$1 = __vite__wasmModule.tokenize;
|
|
|
3667
3719
|
const tokenize_value = __vite__wasmModule.tokenize_value;
|
|
3668
3720
|
const transpile$1 = __vite__wasmModule.transpile;
|
|
3669
3721
|
const transpile_value = __vite__wasmModule.transpile_value;
|
|
3722
|
+
const transpile_with_options = __vite__wasmModule.transpile_with_options;
|
|
3723
|
+
const transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
|
|
3670
3724
|
const validate$1 = __vite__wasmModule.validate;
|
|
3671
3725
|
const validate_with_options = __vite__wasmModule.validate_with_options;
|
|
3672
3726
|
const validate_with_schema = __vite__wasmModule.validate_with_schema;
|
|
@@ -3862,6 +3916,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3862
3916
|
tokenize_value,
|
|
3863
3917
|
transpile: transpile$1,
|
|
3864
3918
|
transpile_value,
|
|
3919
|
+
transpile_with_options,
|
|
3920
|
+
transpile_with_options_value,
|
|
3865
3921
|
validate: validate$1,
|
|
3866
3922
|
validate_with_options,
|
|
3867
3923
|
validate_with_schema,
|
|
@@ -4051,6 +4107,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4051
4107
|
tokenize_value: tokenize_value$1,
|
|
4052
4108
|
transpile: transpile$2,
|
|
4053
4109
|
transpile_value: transpile_value$1,
|
|
4110
|
+
transpile_with_options: transpile_with_options$1,
|
|
4111
|
+
transpile_with_options_value: transpile_with_options_value$1,
|
|
4054
4112
|
validate: validate$2,
|
|
4055
4113
|
validate_with_options: validate_with_options$1,
|
|
4056
4114
|
validate_with_schema: validate_with_schema$1,
|
|
@@ -5523,6 +5581,71 @@ function except(left, right) {
|
|
|
5523
5581
|
return left.except(right);
|
|
5524
5582
|
}
|
|
5525
5583
|
|
|
5584
|
+
function diff(source, target, dialect = "generic", options = {}) {
|
|
5585
|
+
const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
|
|
5586
|
+
const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
|
|
5587
|
+
return JSON.parse(resultJson);
|
|
5588
|
+
}
|
|
5589
|
+
function hasChanges(edits) {
|
|
5590
|
+
return edits.some((e) => e.type !== "keep");
|
|
5591
|
+
}
|
|
5592
|
+
function changesOnly(edits) {
|
|
5593
|
+
return edits.filter((e) => e.type !== "keep");
|
|
5594
|
+
}
|
|
5595
|
+
|
|
5596
|
+
function lineage(column, sql, dialect = "generic", trimSelects = false) {
|
|
5597
|
+
const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
|
|
5598
|
+
return JSON.parse(resultJson);
|
|
5599
|
+
}
|
|
5600
|
+
function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
|
|
5601
|
+
const resultJson = lineage_sql_with_schema$1(
|
|
5602
|
+
sql,
|
|
5603
|
+
column,
|
|
5604
|
+
JSON.stringify(schema),
|
|
5605
|
+
dialect,
|
|
5606
|
+
trimSelects
|
|
5607
|
+
);
|
|
5608
|
+
return JSON.parse(resultJson);
|
|
5609
|
+
}
|
|
5610
|
+
function getSourceTables(column, sql, dialect = "generic") {
|
|
5611
|
+
const resultJson = source_tables$1(sql, column, dialect);
|
|
5612
|
+
return JSON.parse(resultJson);
|
|
5613
|
+
}
|
|
5614
|
+
|
|
5615
|
+
function normalizeOptions(options) {
|
|
5616
|
+
return {
|
|
5617
|
+
dialect: "generic",
|
|
5618
|
+
datasetMappings: {},
|
|
5619
|
+
...options
|
|
5620
|
+
};
|
|
5621
|
+
}
|
|
5622
|
+
function openLineageColumnLineage(sql, options) {
|
|
5623
|
+
const resultJson = openlineage_column_lineage$1(
|
|
5624
|
+
sql,
|
|
5625
|
+
JSON.stringify(normalizeOptions(options))
|
|
5626
|
+
);
|
|
5627
|
+
return JSON.parse(resultJson);
|
|
5628
|
+
}
|
|
5629
|
+
function openLineageJobEvent(sql, options) {
|
|
5630
|
+
const resultJson = openlineage_job_event$1(
|
|
5631
|
+
sql,
|
|
5632
|
+
JSON.stringify(normalizeOptions(options))
|
|
5633
|
+
);
|
|
5634
|
+
return JSON.parse(resultJson);
|
|
5635
|
+
}
|
|
5636
|
+
function openLineageRunEvent(sql, options) {
|
|
5637
|
+
const resultJson = openlineage_run_event$1(
|
|
5638
|
+
sql,
|
|
5639
|
+
JSON.stringify(normalizeOptions(options))
|
|
5640
|
+
);
|
|
5641
|
+
return JSON.parse(resultJson);
|
|
5642
|
+
}
|
|
5643
|
+
|
|
5644
|
+
function plan(sql, dialect = "generic") {
|
|
5645
|
+
const resultJson = plan$2(sql, dialect);
|
|
5646
|
+
return JSON.parse(resultJson);
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5526
5649
|
function validateSemantics(expr, options) {
|
|
5527
5650
|
const errors = [];
|
|
5528
5651
|
if (getExprType(expr) === "select") {
|
|
@@ -5678,71 +5801,6 @@ function validate(sql, dialect = "generic", options = {}) {
|
|
|
5678
5801
|
};
|
|
5679
5802
|
}
|
|
5680
5803
|
|
|
5681
|
-
function lineage(column, sql, dialect = "generic", trimSelects = false) {
|
|
5682
|
-
const resultJson = lineage_sql$1(sql, column, dialect, trimSelects);
|
|
5683
|
-
return JSON.parse(resultJson);
|
|
5684
|
-
}
|
|
5685
|
-
function lineageWithSchema(column, sql, schema, dialect = "generic", trimSelects = false) {
|
|
5686
|
-
const resultJson = lineage_sql_with_schema$1(
|
|
5687
|
-
sql,
|
|
5688
|
-
column,
|
|
5689
|
-
JSON.stringify(schema),
|
|
5690
|
-
dialect,
|
|
5691
|
-
trimSelects
|
|
5692
|
-
);
|
|
5693
|
-
return JSON.parse(resultJson);
|
|
5694
|
-
}
|
|
5695
|
-
function getSourceTables(column, sql, dialect = "generic") {
|
|
5696
|
-
const resultJson = source_tables$1(sql, column, dialect);
|
|
5697
|
-
return JSON.parse(resultJson);
|
|
5698
|
-
}
|
|
5699
|
-
|
|
5700
|
-
function normalizeOptions(options) {
|
|
5701
|
-
return {
|
|
5702
|
-
dialect: "generic",
|
|
5703
|
-
datasetMappings: {},
|
|
5704
|
-
...options
|
|
5705
|
-
};
|
|
5706
|
-
}
|
|
5707
|
-
function openLineageColumnLineage(sql, options) {
|
|
5708
|
-
const resultJson = openlineage_column_lineage$1(
|
|
5709
|
-
sql,
|
|
5710
|
-
JSON.stringify(normalizeOptions(options))
|
|
5711
|
-
);
|
|
5712
|
-
return JSON.parse(resultJson);
|
|
5713
|
-
}
|
|
5714
|
-
function openLineageJobEvent(sql, options) {
|
|
5715
|
-
const resultJson = openlineage_job_event$1(
|
|
5716
|
-
sql,
|
|
5717
|
-
JSON.stringify(normalizeOptions(options))
|
|
5718
|
-
);
|
|
5719
|
-
return JSON.parse(resultJson);
|
|
5720
|
-
}
|
|
5721
|
-
function openLineageRunEvent(sql, options) {
|
|
5722
|
-
const resultJson = openlineage_run_event$1(
|
|
5723
|
-
sql,
|
|
5724
|
-
JSON.stringify(normalizeOptions(options))
|
|
5725
|
-
);
|
|
5726
|
-
return JSON.parse(resultJson);
|
|
5727
|
-
}
|
|
5728
|
-
|
|
5729
|
-
function diff(source, target, dialect = "generic", options = {}) {
|
|
5730
|
-
const { deltaOnly = false, f = 0.6, t = 0.6 } = options;
|
|
5731
|
-
const resultJson = diff_sql$1(source, target, dialect, deltaOnly, f, t);
|
|
5732
|
-
return JSON.parse(resultJson);
|
|
5733
|
-
}
|
|
5734
|
-
function hasChanges(edits) {
|
|
5735
|
-
return edits.some((e) => e.type !== "keep");
|
|
5736
|
-
}
|
|
5737
|
-
function changesOnly(edits) {
|
|
5738
|
-
return edits.filter((e) => e.type !== "keep");
|
|
5739
|
-
}
|
|
5740
|
-
|
|
5741
|
-
function plan(sql, dialect = "generic") {
|
|
5742
|
-
const resultJson = plan$2(sql, dialect);
|
|
5743
|
-
return JSON.parse(resultJson);
|
|
5744
|
-
}
|
|
5745
|
-
|
|
5746
5804
|
var Dialect = /* @__PURE__ */ ((Dialect2) => {
|
|
5747
5805
|
Dialect2["Generic"] = "generic";
|
|
5748
5806
|
Dialect2["PostgreSQL"] = "postgresql";
|
|
@@ -5820,8 +5878,25 @@ async function init() {
|
|
|
5820
5878
|
function isInitialized() {
|
|
5821
5879
|
return true;
|
|
5822
5880
|
}
|
|
5823
|
-
function transpile(sql, read, write) {
|
|
5881
|
+
function transpile(sql, read, write, options) {
|
|
5824
5882
|
try {
|
|
5883
|
+
if (options && Object.keys(options).length > 0) {
|
|
5884
|
+
if (typeof wasm.transpile_with_options_value === "function") {
|
|
5885
|
+
return decodeWasmPayload(
|
|
5886
|
+
wasm.transpile_with_options_value(sql, read, write, options)
|
|
5887
|
+
);
|
|
5888
|
+
}
|
|
5889
|
+
if (typeof wasm.transpile_with_options === "function") {
|
|
5890
|
+
return JSON.parse(
|
|
5891
|
+
wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
|
|
5892
|
+
);
|
|
5893
|
+
}
|
|
5894
|
+
return {
|
|
5895
|
+
success: false,
|
|
5896
|
+
sql: void 0,
|
|
5897
|
+
error: "WASM transpile options are not available in this build"
|
|
5898
|
+
};
|
|
5899
|
+
}
|
|
5825
5900
|
if (typeof wasm.transpile_value === "function") {
|
|
5826
5901
|
return decodeWasmPayload(
|
|
5827
5902
|
wasm.transpile_value(sql, read, write)
|
|
@@ -5954,8 +6029,8 @@ class Polyglot {
|
|
|
5954
6029
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
5955
6030
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
5956
6031
|
*/
|
|
5957
|
-
transpile(sql, read, write) {
|
|
5958
|
-
return transpile(sql, read, write);
|
|
6032
|
+
transpile(sql, read, write, options) {
|
|
6033
|
+
return transpile(sql, read, write, options);
|
|
5959
6034
|
}
|
|
5960
6035
|
/**
|
|
5961
6036
|
* Parse SQL into an AST.
|