@polyglot-sql/sdk 0.4.4 → 0.5.1
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 +63 -1
- package/dist/cdn/polyglot.esm.js +1849 -1670
- package/dist/index.cjs +272 -3
- package/dist/index.d.cts +172 -6
- package/dist/index.d.ts +172 -6
- package/dist/index.js +322 -4
- package/dist/index.node.js +264 -3
- package/dist/manual.js +306 -4
- package/dist/polyglot_sql.wasm +0 -0
- package/package.json +1 -1
package/dist/index.node.js
CHANGED
|
@@ -1542,6 +1542,32 @@ class WasmWindowDefBuilder {
|
|
|
1542
1542
|
}
|
|
1543
1543
|
}
|
|
1544
1544
|
if (Symbol.dispose) WasmWindowDefBuilder.prototype[Symbol.dispose] = WasmWindowDefBuilder.prototype.free;
|
|
1545
|
+
function analyze_query$1(sql, options_json) {
|
|
1546
|
+
let deferred3_0;
|
|
1547
|
+
let deferred3_1;
|
|
1548
|
+
try {
|
|
1549
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1550
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1551
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1552
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1553
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1554
|
+
wasm$3.analyze_query(retptr, ptr0, len0, ptr1, len1);
|
|
1555
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1556
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1557
|
+
deferred3_0 = r0;
|
|
1558
|
+
deferred3_1 = r1;
|
|
1559
|
+
return getStringFromWasm0(r0, r1);
|
|
1560
|
+
} finally {
|
|
1561
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1562
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function analyze_query_value$1(sql, options) {
|
|
1566
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1567
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1568
|
+
const ret = wasm$3.analyze_query_value(ptr0, len0, addHeapObject(options));
|
|
1569
|
+
return takeObject(ret);
|
|
1570
|
+
}
|
|
1545
1571
|
function annotate_types$1(sql, dialect, schema_json) {
|
|
1546
1572
|
let deferred4_0;
|
|
1547
1573
|
let deferred4_1;
|
|
@@ -1994,6 +2020,32 @@ function generate$2(ast_json, dialect) {
|
|
|
1994
2020
|
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1995
2021
|
}
|
|
1996
2022
|
}
|
|
2023
|
+
function generate_data_type$1(data_type_json, dialect) {
|
|
2024
|
+
let deferred3_0;
|
|
2025
|
+
let deferred3_1;
|
|
2026
|
+
try {
|
|
2027
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2028
|
+
const ptr0 = passStringToWasm0(data_type_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2029
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2030
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2031
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2032
|
+
wasm$3.generate_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2033
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2034
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2035
|
+
deferred3_0 = r0;
|
|
2036
|
+
deferred3_1 = r1;
|
|
2037
|
+
return getStringFromWasm0(r0, r1);
|
|
2038
|
+
} finally {
|
|
2039
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2040
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
function generate_data_type_value$1(data_type, dialect) {
|
|
2044
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2045
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2046
|
+
const ret = wasm$3.generate_data_type_value(addHeapObject(data_type), ptr0, len0);
|
|
2047
|
+
return takeObject(ret);
|
|
2048
|
+
}
|
|
1997
2049
|
function generate_value$1(ast, dialect) {
|
|
1998
2050
|
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1999
2051
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -2146,6 +2198,34 @@ function parse$2(sql, dialect) {
|
|
|
2146
2198
|
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2147
2199
|
}
|
|
2148
2200
|
}
|
|
2201
|
+
function parse_data_type$1(sql, dialect) {
|
|
2202
|
+
let deferred3_0;
|
|
2203
|
+
let deferred3_1;
|
|
2204
|
+
try {
|
|
2205
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2206
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2207
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2208
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2209
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2210
|
+
wasm$3.parse_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2211
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2212
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2213
|
+
deferred3_0 = r0;
|
|
2214
|
+
deferred3_1 = r1;
|
|
2215
|
+
return getStringFromWasm0(r0, r1);
|
|
2216
|
+
} finally {
|
|
2217
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2218
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
function parse_data_type_value$1(sql, dialect) {
|
|
2222
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2223
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2224
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2225
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2226
|
+
const ret = wasm$3.parse_data_type_value(ptr0, len0, ptr1, len1);
|
|
2227
|
+
return takeObject(ret);
|
|
2228
|
+
}
|
|
2149
2229
|
function parse_value$1(sql, dialect) {
|
|
2150
2230
|
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2151
2231
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -2256,6 +2336,40 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
|
|
|
2256
2336
|
const ret = wasm$3.transpile_value(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2257
2337
|
return takeObject(ret);
|
|
2258
2338
|
}
|
|
2339
|
+
function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
|
|
2340
|
+
let deferred5_0;
|
|
2341
|
+
let deferred5_1;
|
|
2342
|
+
try {
|
|
2343
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2344
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2345
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2346
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2347
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2348
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2349
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2350
|
+
const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2351
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2352
|
+
wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
2353
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2354
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2355
|
+
deferred5_0 = r0;
|
|
2356
|
+
deferred5_1 = r1;
|
|
2357
|
+
return getStringFromWasm0(r0, r1);
|
|
2358
|
+
} finally {
|
|
2359
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2360
|
+
wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
|
|
2364
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2365
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2366
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2367
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2368
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2369
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2370
|
+
const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
|
|
2371
|
+
return takeObject(ret);
|
|
2372
|
+
}
|
|
2259
2373
|
function validate$2(sql, dialect) {
|
|
2260
2374
|
let deferred3_0;
|
|
2261
2375
|
let deferred3_1;
|
|
@@ -2999,6 +3113,8 @@ const __wbg_wasmselectbuilder_free = __vite__wasmModule.__wbg_wasmselectbuilder_
|
|
|
2999
3113
|
const __wbg_wasmsetopbuilder_free = __vite__wasmModule.__wbg_wasmsetopbuilder_free;
|
|
3000
3114
|
const __wbg_wasmupdatebuilder_free = __vite__wasmModule.__wbg_wasmupdatebuilder_free;
|
|
3001
3115
|
const __wbg_wasmwindowdefbuilder_free = __vite__wasmModule.__wbg_wasmwindowdefbuilder_free;
|
|
3116
|
+
const analyze_query = __vite__wasmModule.analyze_query;
|
|
3117
|
+
const analyze_query_value = __vite__wasmModule.analyze_query_value;
|
|
3002
3118
|
const annotate_types = __vite__wasmModule.annotate_types;
|
|
3003
3119
|
const annotate_types_value = __vite__wasmModule.annotate_types_value;
|
|
3004
3120
|
const ast_add_where = __vite__wasmModule.ast_add_where;
|
|
@@ -3024,6 +3140,8 @@ const format_sql_value = __vite__wasmModule.format_sql_value;
|
|
|
3024
3140
|
const format_sql_with_options = __vite__wasmModule.format_sql_with_options;
|
|
3025
3141
|
const format_sql_with_options_value = __vite__wasmModule.format_sql_with_options_value;
|
|
3026
3142
|
const generate$1 = __vite__wasmModule.generate;
|
|
3143
|
+
const generate_data_type = __vite__wasmModule.generate_data_type;
|
|
3144
|
+
const generate_data_type_value = __vite__wasmModule.generate_data_type_value;
|
|
3027
3145
|
const generate_value = __vite__wasmModule.generate_value;
|
|
3028
3146
|
const get_dialects = __vite__wasmModule.get_dialects;
|
|
3029
3147
|
const get_dialects_value = __vite__wasmModule.get_dialects_value;
|
|
@@ -3033,6 +3151,8 @@ const openlineage_column_lineage = __vite__wasmModule.openlineage_column_lineage
|
|
|
3033
3151
|
const openlineage_job_event = __vite__wasmModule.openlineage_job_event;
|
|
3034
3152
|
const openlineage_run_event = __vite__wasmModule.openlineage_run_event;
|
|
3035
3153
|
const parse$1 = __vite__wasmModule.parse;
|
|
3154
|
+
const parse_data_type = __vite__wasmModule.parse_data_type;
|
|
3155
|
+
const parse_data_type_value = __vite__wasmModule.parse_data_type_value;
|
|
3036
3156
|
const parse_value = __vite__wasmModule.parse_value;
|
|
3037
3157
|
const plan$1 = __vite__wasmModule.plan;
|
|
3038
3158
|
const source_tables = __vite__wasmModule.source_tables;
|
|
@@ -3040,6 +3160,8 @@ const tokenize$1 = __vite__wasmModule.tokenize;
|
|
|
3040
3160
|
const tokenize_value = __vite__wasmModule.tokenize_value;
|
|
3041
3161
|
const transpile$1 = __vite__wasmModule.transpile;
|
|
3042
3162
|
const transpile_value = __vite__wasmModule.transpile_value;
|
|
3163
|
+
const transpile_with_options = __vite__wasmModule.transpile_with_options;
|
|
3164
|
+
const transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
|
|
3043
3165
|
const validate$1 = __vite__wasmModule.validate;
|
|
3044
3166
|
const validate_with_options = __vite__wasmModule.validate_with_options;
|
|
3045
3167
|
const validate_with_schema = __vite__wasmModule.validate_with_schema;
|
|
@@ -3192,6 +3314,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3192
3314
|
__wbindgen_export2,
|
|
3193
3315
|
__wbindgen_export3,
|
|
3194
3316
|
__wbindgen_export4,
|
|
3317
|
+
analyze_query,
|
|
3318
|
+
analyze_query_value,
|
|
3195
3319
|
annotate_types,
|
|
3196
3320
|
annotate_types_value,
|
|
3197
3321
|
ast_add_where,
|
|
@@ -3217,6 +3341,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3217
3341
|
format_sql_with_options,
|
|
3218
3342
|
format_sql_with_options_value,
|
|
3219
3343
|
generate: generate$1,
|
|
3344
|
+
generate_data_type,
|
|
3345
|
+
generate_data_type_value,
|
|
3220
3346
|
generate_value,
|
|
3221
3347
|
get_dialects,
|
|
3222
3348
|
get_dialects_value,
|
|
@@ -3227,6 +3353,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3227
3353
|
openlineage_job_event,
|
|
3228
3354
|
openlineage_run_event,
|
|
3229
3355
|
parse: parse$1,
|
|
3356
|
+
parse_data_type,
|
|
3357
|
+
parse_data_type_value,
|
|
3230
3358
|
parse_value,
|
|
3231
3359
|
plan: plan$1,
|
|
3232
3360
|
source_tables,
|
|
@@ -3234,6 +3362,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3234
3362
|
tokenize_value,
|
|
3235
3363
|
transpile: transpile$1,
|
|
3236
3364
|
transpile_value,
|
|
3365
|
+
transpile_with_options,
|
|
3366
|
+
transpile_with_options_value,
|
|
3237
3367
|
validate: validate$1,
|
|
3238
3368
|
validate_with_options,
|
|
3239
3369
|
validate_with_schema,
|
|
@@ -3378,6 +3508,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3378
3508
|
WasmSetOpBuilder,
|
|
3379
3509
|
WasmUpdateBuilder,
|
|
3380
3510
|
WasmWindowDefBuilder,
|
|
3511
|
+
analyze_query: analyze_query$1,
|
|
3512
|
+
analyze_query_value: analyze_query_value$1,
|
|
3381
3513
|
annotate_types: annotate_types$1,
|
|
3382
3514
|
annotate_types_value: annotate_types_value$1,
|
|
3383
3515
|
ast_add_where: ast_add_where$1,
|
|
@@ -3403,6 +3535,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3403
3535
|
format_sql_with_options: format_sql_with_options$1,
|
|
3404
3536
|
format_sql_with_options_value: format_sql_with_options_value$1,
|
|
3405
3537
|
generate: generate$2,
|
|
3538
|
+
generate_data_type: generate_data_type$1,
|
|
3539
|
+
generate_data_type_value: generate_data_type_value$1,
|
|
3406
3540
|
generate_value: generate_value$1,
|
|
3407
3541
|
get_dialects: get_dialects$1,
|
|
3408
3542
|
get_dialects_value: get_dialects_value$1,
|
|
@@ -3412,6 +3546,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3412
3546
|
openlineage_job_event: openlineage_job_event$1,
|
|
3413
3547
|
openlineage_run_event: openlineage_run_event$1,
|
|
3414
3548
|
parse: parse$2,
|
|
3549
|
+
parse_data_type: parse_data_type$1,
|
|
3550
|
+
parse_data_type_value: parse_data_type_value$1,
|
|
3415
3551
|
parse_value: parse_value$1,
|
|
3416
3552
|
plan: plan$2,
|
|
3417
3553
|
source_tables: source_tables$1,
|
|
@@ -3419,6 +3555,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3419
3555
|
tokenize_value: tokenize_value$1,
|
|
3420
3556
|
transpile: transpile$2,
|
|
3421
3557
|
transpile_value: transpile_value$1,
|
|
3558
|
+
transpile_with_options: transpile_with_options$1,
|
|
3559
|
+
transpile_with_options_value: transpile_with_options_value$1,
|
|
3422
3560
|
validate: validate$2,
|
|
3423
3561
|
validate_with_options: validate_with_options$1,
|
|
3424
3562
|
validate_with_schema: validate_with_schema$1,
|
|
@@ -5161,20 +5299,62 @@ function parseFailure(context, error) {
|
|
|
5161
5299
|
errorColumn: void 0
|
|
5162
5300
|
};
|
|
5163
5301
|
}
|
|
5302
|
+
function dataTypeFailure(context, error) {
|
|
5303
|
+
return {
|
|
5304
|
+
success: false,
|
|
5305
|
+
dataType: void 0,
|
|
5306
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
5307
|
+
errorLine: void 0,
|
|
5308
|
+
errorColumn: void 0
|
|
5309
|
+
};
|
|
5310
|
+
}
|
|
5311
|
+
function generateDataTypeFailure(context, error) {
|
|
5312
|
+
return {
|
|
5313
|
+
success: false,
|
|
5314
|
+
sql: void 0,
|
|
5315
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
5316
|
+
errorLine: void 0,
|
|
5317
|
+
errorColumn: void 0
|
|
5318
|
+
};
|
|
5319
|
+
}
|
|
5164
5320
|
function decodeWasmPayload(payload) {
|
|
5165
5321
|
if (typeof payload === "string") {
|
|
5166
5322
|
return JSON.parse(payload);
|
|
5167
5323
|
}
|
|
5168
5324
|
return payload;
|
|
5169
5325
|
}
|
|
5326
|
+
function queryAnalysisFailure(context, error) {
|
|
5327
|
+
return {
|
|
5328
|
+
success: false,
|
|
5329
|
+
analysis: void 0,
|
|
5330
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`
|
|
5331
|
+
};
|
|
5332
|
+
}
|
|
5170
5333
|
async function init() {
|
|
5171
5334
|
return Promise.resolve();
|
|
5172
5335
|
}
|
|
5173
5336
|
function isInitialized() {
|
|
5174
5337
|
return true;
|
|
5175
5338
|
}
|
|
5176
|
-
function transpile(sql, read, write) {
|
|
5339
|
+
function transpile(sql, read, write, options) {
|
|
5177
5340
|
try {
|
|
5341
|
+
if (options && Object.keys(options).length > 0) {
|
|
5342
|
+
if (typeof wasm.transpile_with_options_value === "function") {
|
|
5343
|
+
return decodeWasmPayload(
|
|
5344
|
+
wasm.transpile_with_options_value(sql, read, write, options)
|
|
5345
|
+
);
|
|
5346
|
+
}
|
|
5347
|
+
if (typeof wasm.transpile_with_options === "function") {
|
|
5348
|
+
return JSON.parse(
|
|
5349
|
+
wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
|
|
5350
|
+
);
|
|
5351
|
+
}
|
|
5352
|
+
return {
|
|
5353
|
+
success: false,
|
|
5354
|
+
sql: void 0,
|
|
5355
|
+
error: "WASM transpile options are not available in this build"
|
|
5356
|
+
};
|
|
5357
|
+
}
|
|
5178
5358
|
if (typeof wasm.transpile_value === "function") {
|
|
5179
5359
|
return decodeWasmPayload(
|
|
5180
5360
|
wasm.transpile_value(sql, read, write)
|
|
@@ -5199,6 +5379,24 @@ function parse(sql, dialect = "generic") {
|
|
|
5199
5379
|
return parseFailure("parse", error);
|
|
5200
5380
|
}
|
|
5201
5381
|
}
|
|
5382
|
+
function parseDataType(sql, dialect = "generic") {
|
|
5383
|
+
try {
|
|
5384
|
+
if (typeof wasm.parse_data_type_value === "function") {
|
|
5385
|
+
return decodeWasmPayload(
|
|
5386
|
+
wasm.parse_data_type_value(sql, dialect)
|
|
5387
|
+
);
|
|
5388
|
+
}
|
|
5389
|
+
const result = JSON.parse(
|
|
5390
|
+
wasm.parse_data_type(sql, dialect)
|
|
5391
|
+
);
|
|
5392
|
+
if (result.success && typeof result.dataType === "string") {
|
|
5393
|
+
result.dataType = JSON.parse(result.dataType);
|
|
5394
|
+
}
|
|
5395
|
+
return result;
|
|
5396
|
+
} catch (error) {
|
|
5397
|
+
return dataTypeFailure("parseDataType", error);
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5202
5400
|
function tokenize(sql, dialect = "generic") {
|
|
5203
5401
|
try {
|
|
5204
5402
|
if (typeof wasm.tokenize_value === "function") {
|
|
@@ -5228,6 +5426,21 @@ function generate(ast2, dialect = "generic") {
|
|
|
5228
5426
|
return transpileFailure("generate", error);
|
|
5229
5427
|
}
|
|
5230
5428
|
}
|
|
5429
|
+
function generateDataType(dataType, dialect = "generic") {
|
|
5430
|
+
try {
|
|
5431
|
+
if (typeof wasm.generate_data_type_value === "function") {
|
|
5432
|
+
return decodeWasmPayload(
|
|
5433
|
+
wasm.generate_data_type_value(dataType, dialect)
|
|
5434
|
+
);
|
|
5435
|
+
}
|
|
5436
|
+
const dataTypeJson = JSON.stringify(dataType);
|
|
5437
|
+
return JSON.parse(
|
|
5438
|
+
wasm.generate_data_type(dataTypeJson, dialect)
|
|
5439
|
+
);
|
|
5440
|
+
} catch (error) {
|
|
5441
|
+
return generateDataTypeFailure("generateDataType", error);
|
|
5442
|
+
}
|
|
5443
|
+
}
|
|
5231
5444
|
function format(sql, dialect = "generic") {
|
|
5232
5445
|
return formatWithOptions(sql, dialect, {});
|
|
5233
5446
|
}
|
|
@@ -5262,6 +5475,30 @@ function getDialects() {
|
|
|
5262
5475
|
function getVersion() {
|
|
5263
5476
|
return wasm.version();
|
|
5264
5477
|
}
|
|
5478
|
+
function analyzeQuery(sql, options = {}) {
|
|
5479
|
+
try {
|
|
5480
|
+
const normalized = {
|
|
5481
|
+
dialect: "generic",
|
|
5482
|
+
...options
|
|
5483
|
+
};
|
|
5484
|
+
if (typeof wasm.analyze_query_value === "function") {
|
|
5485
|
+
return decodeWasmPayload(
|
|
5486
|
+
wasm.analyze_query_value(sql, normalized)
|
|
5487
|
+
);
|
|
5488
|
+
}
|
|
5489
|
+
if (typeof wasm.analyze_query === "function") {
|
|
5490
|
+
return JSON.parse(
|
|
5491
|
+
wasm.analyze_query(sql, JSON.stringify(normalized))
|
|
5492
|
+
);
|
|
5493
|
+
}
|
|
5494
|
+
return {
|
|
5495
|
+
success: false,
|
|
5496
|
+
error: "analyze_query not available in this WASM build"
|
|
5497
|
+
};
|
|
5498
|
+
} catch (error) {
|
|
5499
|
+
return queryAnalysisFailure("analyzeQuery", error);
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5265
5502
|
function annotateTypes(sql, dialect = "generic", schema) {
|
|
5266
5503
|
try {
|
|
5267
5504
|
const schemaJson = schema ? JSON.stringify(schema) : "";
|
|
@@ -5307,8 +5544,8 @@ class Polyglot {
|
|
|
5307
5544
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
5308
5545
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
5309
5546
|
*/
|
|
5310
|
-
transpile(sql, read, write) {
|
|
5311
|
-
return transpile(sql, read, write);
|
|
5547
|
+
transpile(sql, read, write, options) {
|
|
5548
|
+
return transpile(sql, read, write, options);
|
|
5312
5549
|
}
|
|
5313
5550
|
/**
|
|
5314
5551
|
* Parse SQL into an AST.
|
|
@@ -5316,6 +5553,12 @@ class Polyglot {
|
|
|
5316
5553
|
parse(sql, dialect = "generic") {
|
|
5317
5554
|
return parse(sql, dialect);
|
|
5318
5555
|
}
|
|
5556
|
+
/**
|
|
5557
|
+
* Parse a standalone SQL data type.
|
|
5558
|
+
*/
|
|
5559
|
+
parseDataType(sql, dialect = "generic") {
|
|
5560
|
+
return parseDataType(sql, dialect);
|
|
5561
|
+
}
|
|
5319
5562
|
/**
|
|
5320
5563
|
* Tokenize SQL into a token stream.
|
|
5321
5564
|
*/
|
|
@@ -5328,6 +5571,12 @@ class Polyglot {
|
|
|
5328
5571
|
generate(ast2, dialect = "generic") {
|
|
5329
5572
|
return generate(ast2, dialect);
|
|
5330
5573
|
}
|
|
5574
|
+
/**
|
|
5575
|
+
* Generate SQL from a standalone DataType AST node.
|
|
5576
|
+
*/
|
|
5577
|
+
generateDataType(dataType, dialect = "generic") {
|
|
5578
|
+
return generateDataType(dataType, dialect);
|
|
5579
|
+
}
|
|
5331
5580
|
/**
|
|
5332
5581
|
* Format SQL.
|
|
5333
5582
|
*/
|
|
@@ -5359,16 +5608,25 @@ class Polyglot {
|
|
|
5359
5608
|
annotateTypes(sql, dialect = "generic", schema) {
|
|
5360
5609
|
return annotateTypes(sql, dialect, schema);
|
|
5361
5610
|
}
|
|
5611
|
+
/**
|
|
5612
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
5613
|
+
*/
|
|
5614
|
+
analyzeQuery(sql, options = {}) {
|
|
5615
|
+
return analyzeQuery(sql, options);
|
|
5616
|
+
}
|
|
5362
5617
|
}
|
|
5363
5618
|
const index = {
|
|
5364
5619
|
init,
|
|
5365
5620
|
isInitialized,
|
|
5366
5621
|
transpile,
|
|
5367
5622
|
parse,
|
|
5623
|
+
parseDataType,
|
|
5368
5624
|
tokenize,
|
|
5369
5625
|
generate,
|
|
5626
|
+
generateDataType,
|
|
5370
5627
|
format,
|
|
5371
5628
|
annotateTypes,
|
|
5629
|
+
analyzeQuery,
|
|
5372
5630
|
getDialects,
|
|
5373
5631
|
getVersion,
|
|
5374
5632
|
lineage,
|
|
@@ -5399,6 +5657,7 @@ export {
|
|
|
5399
5657
|
WindowDefBuilder,
|
|
5400
5658
|
abs,
|
|
5401
5659
|
alias,
|
|
5660
|
+
analyzeQuery,
|
|
5402
5661
|
and,
|
|
5403
5662
|
annotateTypes,
|
|
5404
5663
|
index$1 as ast,
|
|
@@ -5432,6 +5691,7 @@ export {
|
|
|
5432
5691
|
formatWithOptions,
|
|
5433
5692
|
func,
|
|
5434
5693
|
generate,
|
|
5694
|
+
generateDataType,
|
|
5435
5695
|
getColumns,
|
|
5436
5696
|
getDialects,
|
|
5437
5697
|
getInferredType,
|
|
@@ -5468,6 +5728,7 @@ export {
|
|
|
5468
5728
|
openLineageRunEvent,
|
|
5469
5729
|
or,
|
|
5470
5730
|
parse,
|
|
5731
|
+
parseDataType,
|
|
5471
5732
|
plan,
|
|
5472
5733
|
power,
|
|
5473
5734
|
rank,
|