@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.js
CHANGED
|
@@ -1592,6 +1592,46 @@ class WasmWindowDefBuilder {
|
|
|
1592
1592
|
}
|
|
1593
1593
|
if (Symbol.dispose) WasmWindowDefBuilder.prototype[Symbol.dispose] = WasmWindowDefBuilder.prototype.free;
|
|
1594
1594
|
|
|
1595
|
+
/**
|
|
1596
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
1597
|
+
* @param {string} sql
|
|
1598
|
+
* @param {string} options_json
|
|
1599
|
+
* @returns {string}
|
|
1600
|
+
*/
|
|
1601
|
+
function analyze_query$1(sql, options_json) {
|
|
1602
|
+
let deferred3_0;
|
|
1603
|
+
let deferred3_1;
|
|
1604
|
+
try {
|
|
1605
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1606
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1607
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1608
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1609
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1610
|
+
wasm$3.analyze_query(retptr, ptr0, len0, ptr1, len1);
|
|
1611
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1612
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1613
|
+
deferred3_0 = r0;
|
|
1614
|
+
deferred3_1 = r1;
|
|
1615
|
+
return getStringFromWasm0(r0, r1);
|
|
1616
|
+
} finally {
|
|
1617
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1618
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* Return compact query analysis facts as a structured JS value.
|
|
1624
|
+
* @param {string} sql
|
|
1625
|
+
* @param {any} options
|
|
1626
|
+
* @returns {any}
|
|
1627
|
+
*/
|
|
1628
|
+
function analyze_query_value$1(sql, options) {
|
|
1629
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1630
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1631
|
+
const ret = wasm$3.analyze_query_value(ptr0, len0, addHeapObject(options));
|
|
1632
|
+
return takeObject(ret);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1595
1635
|
/**
|
|
1596
1636
|
* Annotate types on a parsed SQL AST in-place.
|
|
1597
1637
|
*
|
|
@@ -2257,6 +2297,46 @@ function generate$2(ast_json, dialect) {
|
|
|
2257
2297
|
}
|
|
2258
2298
|
}
|
|
2259
2299
|
|
|
2300
|
+
/**
|
|
2301
|
+
* Generate SQL from a standalone DataType JSON object.
|
|
2302
|
+
* @param {string} data_type_json
|
|
2303
|
+
* @param {string} dialect
|
|
2304
|
+
* @returns {string}
|
|
2305
|
+
*/
|
|
2306
|
+
function generate_data_type$1(data_type_json, dialect) {
|
|
2307
|
+
let deferred3_0;
|
|
2308
|
+
let deferred3_1;
|
|
2309
|
+
try {
|
|
2310
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2311
|
+
const ptr0 = passStringToWasm0(data_type_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2312
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2313
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2314
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2315
|
+
wasm$3.generate_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2316
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2317
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2318
|
+
deferred3_0 = r0;
|
|
2319
|
+
deferred3_1 = r1;
|
|
2320
|
+
return getStringFromWasm0(r0, r1);
|
|
2321
|
+
} finally {
|
|
2322
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2323
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Generate SQL from a standalone DataType represented as a structured JS value.
|
|
2329
|
+
* @param {any} data_type
|
|
2330
|
+
* @param {string} dialect
|
|
2331
|
+
* @returns {any}
|
|
2332
|
+
*/
|
|
2333
|
+
function generate_data_type_value$1(data_type, dialect) {
|
|
2334
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2336
|
+
const ret = wasm$3.generate_data_type_value(addHeapObject(data_type), ptr0, len0);
|
|
2337
|
+
return takeObject(ret);
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2260
2340
|
/**
|
|
2261
2341
|
* Generate SQL from an AST represented as a structured JS value.
|
|
2262
2342
|
* @param {any} ast
|
|
@@ -2502,6 +2582,48 @@ function parse$2(sql, dialect) {
|
|
|
2502
2582
|
}
|
|
2503
2583
|
}
|
|
2504
2584
|
|
|
2585
|
+
/**
|
|
2586
|
+
* Parse a standalone SQL data type and return a JSON string payload.
|
|
2587
|
+
* @param {string} sql
|
|
2588
|
+
* @param {string} dialect
|
|
2589
|
+
* @returns {string}
|
|
2590
|
+
*/
|
|
2591
|
+
function parse_data_type$1(sql, dialect) {
|
|
2592
|
+
let deferred3_0;
|
|
2593
|
+
let deferred3_1;
|
|
2594
|
+
try {
|
|
2595
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2596
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2597
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2598
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2599
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2600
|
+
wasm$3.parse_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2601
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2602
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2603
|
+
deferred3_0 = r0;
|
|
2604
|
+
deferred3_1 = r1;
|
|
2605
|
+
return getStringFromWasm0(r0, r1);
|
|
2606
|
+
} finally {
|
|
2607
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2608
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
/**
|
|
2613
|
+
* Parse a standalone SQL data type and return a structured JS value payload.
|
|
2614
|
+
* @param {string} sql
|
|
2615
|
+
* @param {string} dialect
|
|
2616
|
+
* @returns {any}
|
|
2617
|
+
*/
|
|
2618
|
+
function parse_data_type_value$1(sql, dialect) {
|
|
2619
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2620
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2621
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2622
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2623
|
+
const ret = wasm$3.parse_data_type_value(ptr0, len0, ptr1, len1);
|
|
2624
|
+
return takeObject(ret);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2505
2627
|
/**
|
|
2506
2628
|
* Parse SQL and return a structured JS object with AST values.
|
|
2507
2629
|
* @param {string} sql
|
|
@@ -2694,6 +2816,58 @@ function transpile_value$1(sql, read_dialect, write_dialect) {
|
|
|
2694
2816
|
return takeObject(ret);
|
|
2695
2817
|
}
|
|
2696
2818
|
|
|
2819
|
+
/**
|
|
2820
|
+
* Transpile SQL with explicit options encoded as a JSON string.
|
|
2821
|
+
* @param {string} sql
|
|
2822
|
+
* @param {string} read_dialect
|
|
2823
|
+
* @param {string} write_dialect
|
|
2824
|
+
* @param {string} options_json
|
|
2825
|
+
* @returns {string}
|
|
2826
|
+
*/
|
|
2827
|
+
function transpile_with_options$1(sql, read_dialect, write_dialect, options_json) {
|
|
2828
|
+
let deferred5_0;
|
|
2829
|
+
let deferred5_1;
|
|
2830
|
+
try {
|
|
2831
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2832
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2833
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2834
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2835
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2836
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2837
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2838
|
+
const ptr3 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2839
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2840
|
+
wasm$3.transpile_with_options(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
2841
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2842
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2843
|
+
deferred5_0 = r0;
|
|
2844
|
+
deferred5_1 = r1;
|
|
2845
|
+
return getStringFromWasm0(r0, r1);
|
|
2846
|
+
} finally {
|
|
2847
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2848
|
+
wasm$3.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
/**
|
|
2853
|
+
* Transpile SQL with explicit options and return a structured JS object.
|
|
2854
|
+
* @param {string} sql
|
|
2855
|
+
* @param {string} read_dialect
|
|
2856
|
+
* @param {string} write_dialect
|
|
2857
|
+
* @param {any} options
|
|
2858
|
+
* @returns {any}
|
|
2859
|
+
*/
|
|
2860
|
+
function transpile_with_options_value$1(sql, read_dialect, write_dialect, options) {
|
|
2861
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2862
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2863
|
+
const ptr1 = passStringToWasm0(read_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2864
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2865
|
+
const ptr2 = passStringToWasm0(write_dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2866
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2867
|
+
const ret = wasm$3.transpile_with_options_value(ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(options));
|
|
2868
|
+
return takeObject(ret);
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2697
2871
|
/**
|
|
2698
2872
|
* Validate SQL syntax.
|
|
2699
2873
|
*
|
|
@@ -3626,6 +3800,8 @@ const __wbg_wasmselectbuilder_free = __vite__wasmModule.__wbg_wasmselectbuilder_
|
|
|
3626
3800
|
const __wbg_wasmsetopbuilder_free = __vite__wasmModule.__wbg_wasmsetopbuilder_free;
|
|
3627
3801
|
const __wbg_wasmupdatebuilder_free = __vite__wasmModule.__wbg_wasmupdatebuilder_free;
|
|
3628
3802
|
const __wbg_wasmwindowdefbuilder_free = __vite__wasmModule.__wbg_wasmwindowdefbuilder_free;
|
|
3803
|
+
const analyze_query = __vite__wasmModule.analyze_query;
|
|
3804
|
+
const analyze_query_value = __vite__wasmModule.analyze_query_value;
|
|
3629
3805
|
const annotate_types = __vite__wasmModule.annotate_types;
|
|
3630
3806
|
const annotate_types_value = __vite__wasmModule.annotate_types_value;
|
|
3631
3807
|
const ast_add_where = __vite__wasmModule.ast_add_where;
|
|
@@ -3651,6 +3827,8 @@ const format_sql_value = __vite__wasmModule.format_sql_value;
|
|
|
3651
3827
|
const format_sql_with_options = __vite__wasmModule.format_sql_with_options;
|
|
3652
3828
|
const format_sql_with_options_value = __vite__wasmModule.format_sql_with_options_value;
|
|
3653
3829
|
const generate$1 = __vite__wasmModule.generate;
|
|
3830
|
+
const generate_data_type = __vite__wasmModule.generate_data_type;
|
|
3831
|
+
const generate_data_type_value = __vite__wasmModule.generate_data_type_value;
|
|
3654
3832
|
const generate_value = __vite__wasmModule.generate_value;
|
|
3655
3833
|
const get_dialects = __vite__wasmModule.get_dialects;
|
|
3656
3834
|
const get_dialects_value = __vite__wasmModule.get_dialects_value;
|
|
@@ -3660,6 +3838,8 @@ const openlineage_column_lineage = __vite__wasmModule.openlineage_column_lineage
|
|
|
3660
3838
|
const openlineage_job_event = __vite__wasmModule.openlineage_job_event;
|
|
3661
3839
|
const openlineage_run_event = __vite__wasmModule.openlineage_run_event;
|
|
3662
3840
|
const parse$1 = __vite__wasmModule.parse;
|
|
3841
|
+
const parse_data_type = __vite__wasmModule.parse_data_type;
|
|
3842
|
+
const parse_data_type_value = __vite__wasmModule.parse_data_type_value;
|
|
3663
3843
|
const parse_value = __vite__wasmModule.parse_value;
|
|
3664
3844
|
const plan$1 = __vite__wasmModule.plan;
|
|
3665
3845
|
const source_tables = __vite__wasmModule.source_tables;
|
|
@@ -3667,6 +3847,8 @@ const tokenize$1 = __vite__wasmModule.tokenize;
|
|
|
3667
3847
|
const tokenize_value = __vite__wasmModule.tokenize_value;
|
|
3668
3848
|
const transpile$1 = __vite__wasmModule.transpile;
|
|
3669
3849
|
const transpile_value = __vite__wasmModule.transpile_value;
|
|
3850
|
+
const transpile_with_options = __vite__wasmModule.transpile_with_options;
|
|
3851
|
+
const transpile_with_options_value = __vite__wasmModule.transpile_with_options_value;
|
|
3670
3852
|
const validate$1 = __vite__wasmModule.validate;
|
|
3671
3853
|
const validate_with_options = __vite__wasmModule.validate_with_options;
|
|
3672
3854
|
const validate_with_schema = __vite__wasmModule.validate_with_schema;
|
|
@@ -3820,6 +4002,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3820
4002
|
__wbindgen_export2,
|
|
3821
4003
|
__wbindgen_export3,
|
|
3822
4004
|
__wbindgen_export4,
|
|
4005
|
+
analyze_query,
|
|
4006
|
+
analyze_query_value,
|
|
3823
4007
|
annotate_types,
|
|
3824
4008
|
annotate_types_value,
|
|
3825
4009
|
ast_add_where,
|
|
@@ -3845,6 +4029,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3845
4029
|
format_sql_with_options,
|
|
3846
4030
|
format_sql_with_options_value,
|
|
3847
4031
|
generate: generate$1,
|
|
4032
|
+
generate_data_type,
|
|
4033
|
+
generate_data_type_value,
|
|
3848
4034
|
generate_value,
|
|
3849
4035
|
get_dialects,
|
|
3850
4036
|
get_dialects_value,
|
|
@@ -3855,6 +4041,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3855
4041
|
openlineage_job_event,
|
|
3856
4042
|
openlineage_run_event,
|
|
3857
4043
|
parse: parse$1,
|
|
4044
|
+
parse_data_type,
|
|
4045
|
+
parse_data_type_value,
|
|
3858
4046
|
parse_value,
|
|
3859
4047
|
plan: plan$1,
|
|
3860
4048
|
source_tables,
|
|
@@ -3862,6 +4050,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
3862
4050
|
tokenize_value,
|
|
3863
4051
|
transpile: transpile$1,
|
|
3864
4052
|
transpile_value,
|
|
4053
|
+
transpile_with_options,
|
|
4054
|
+
transpile_with_options_value,
|
|
3865
4055
|
validate: validate$1,
|
|
3866
4056
|
validate_with_options,
|
|
3867
4057
|
validate_with_schema,
|
|
@@ -4010,6 +4200,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4010
4200
|
WasmSetOpBuilder,
|
|
4011
4201
|
WasmUpdateBuilder,
|
|
4012
4202
|
WasmWindowDefBuilder,
|
|
4203
|
+
analyze_query: analyze_query$1,
|
|
4204
|
+
analyze_query_value: analyze_query_value$1,
|
|
4013
4205
|
annotate_types: annotate_types$1,
|
|
4014
4206
|
annotate_types_value: annotate_types_value$1,
|
|
4015
4207
|
ast_add_where: ast_add_where$1,
|
|
@@ -4035,6 +4227,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4035
4227
|
format_sql_with_options: format_sql_with_options$1,
|
|
4036
4228
|
format_sql_with_options_value: format_sql_with_options_value$1,
|
|
4037
4229
|
generate: generate$2,
|
|
4230
|
+
generate_data_type: generate_data_type$1,
|
|
4231
|
+
generate_data_type_value: generate_data_type_value$1,
|
|
4038
4232
|
generate_value: generate_value$1,
|
|
4039
4233
|
get_dialects: get_dialects$1,
|
|
4040
4234
|
get_dialects_value: get_dialects_value$1,
|
|
@@ -4044,6 +4238,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4044
4238
|
openlineage_job_event: openlineage_job_event$1,
|
|
4045
4239
|
openlineage_run_event: openlineage_run_event$1,
|
|
4046
4240
|
parse: parse$2,
|
|
4241
|
+
parse_data_type: parse_data_type$1,
|
|
4242
|
+
parse_data_type_value: parse_data_type_value$1,
|
|
4047
4243
|
parse_value: parse_value$1,
|
|
4048
4244
|
plan: plan$2,
|
|
4049
4245
|
source_tables: source_tables$1,
|
|
@@ -4051,6 +4247,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
|
|
|
4051
4247
|
tokenize_value: tokenize_value$1,
|
|
4052
4248
|
transpile: transpile$2,
|
|
4053
4249
|
transpile_value: transpile_value$1,
|
|
4250
|
+
transpile_with_options: transpile_with_options$1,
|
|
4251
|
+
transpile_with_options_value: transpile_with_options_value$1,
|
|
4054
4252
|
validate: validate$2,
|
|
4055
4253
|
validate_with_options: validate_with_options$1,
|
|
4056
4254
|
validate_with_schema: validate_with_schema$1,
|
|
@@ -5808,20 +6006,62 @@ function parseFailure(context, error) {
|
|
|
5808
6006
|
errorColumn: void 0
|
|
5809
6007
|
};
|
|
5810
6008
|
}
|
|
6009
|
+
function dataTypeFailure(context, error) {
|
|
6010
|
+
return {
|
|
6011
|
+
success: false,
|
|
6012
|
+
dataType: void 0,
|
|
6013
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
6014
|
+
errorLine: void 0,
|
|
6015
|
+
errorColumn: void 0
|
|
6016
|
+
};
|
|
6017
|
+
}
|
|
6018
|
+
function generateDataTypeFailure(context, error) {
|
|
6019
|
+
return {
|
|
6020
|
+
success: false,
|
|
6021
|
+
sql: void 0,
|
|
6022
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
6023
|
+
errorLine: void 0,
|
|
6024
|
+
errorColumn: void 0
|
|
6025
|
+
};
|
|
6026
|
+
}
|
|
5811
6027
|
function decodeWasmPayload(payload) {
|
|
5812
6028
|
if (typeof payload === "string") {
|
|
5813
6029
|
return JSON.parse(payload);
|
|
5814
6030
|
}
|
|
5815
6031
|
return payload;
|
|
5816
6032
|
}
|
|
6033
|
+
function queryAnalysisFailure(context, error) {
|
|
6034
|
+
return {
|
|
6035
|
+
success: false,
|
|
6036
|
+
analysis: void 0,
|
|
6037
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`
|
|
6038
|
+
};
|
|
6039
|
+
}
|
|
5817
6040
|
async function init() {
|
|
5818
6041
|
return Promise.resolve();
|
|
5819
6042
|
}
|
|
5820
6043
|
function isInitialized() {
|
|
5821
6044
|
return true;
|
|
5822
6045
|
}
|
|
5823
|
-
function transpile(sql, read, write) {
|
|
6046
|
+
function transpile(sql, read, write, options) {
|
|
5824
6047
|
try {
|
|
6048
|
+
if (options && Object.keys(options).length > 0) {
|
|
6049
|
+
if (typeof wasm.transpile_with_options_value === "function") {
|
|
6050
|
+
return decodeWasmPayload(
|
|
6051
|
+
wasm.transpile_with_options_value(sql, read, write, options)
|
|
6052
|
+
);
|
|
6053
|
+
}
|
|
6054
|
+
if (typeof wasm.transpile_with_options === "function") {
|
|
6055
|
+
return JSON.parse(
|
|
6056
|
+
wasm.transpile_with_options(sql, read, write, JSON.stringify(options))
|
|
6057
|
+
);
|
|
6058
|
+
}
|
|
6059
|
+
return {
|
|
6060
|
+
success: false,
|
|
6061
|
+
sql: void 0,
|
|
6062
|
+
error: "WASM transpile options are not available in this build"
|
|
6063
|
+
};
|
|
6064
|
+
}
|
|
5825
6065
|
if (typeof wasm.transpile_value === "function") {
|
|
5826
6066
|
return decodeWasmPayload(
|
|
5827
6067
|
wasm.transpile_value(sql, read, write)
|
|
@@ -5846,6 +6086,24 @@ function parse(sql, dialect = "generic" /* Generic */) {
|
|
|
5846
6086
|
return parseFailure("parse", error);
|
|
5847
6087
|
}
|
|
5848
6088
|
}
|
|
6089
|
+
function parseDataType(sql, dialect = "generic" /* Generic */) {
|
|
6090
|
+
try {
|
|
6091
|
+
if (typeof wasm.parse_data_type_value === "function") {
|
|
6092
|
+
return decodeWasmPayload(
|
|
6093
|
+
wasm.parse_data_type_value(sql, dialect)
|
|
6094
|
+
);
|
|
6095
|
+
}
|
|
6096
|
+
const result = JSON.parse(
|
|
6097
|
+
wasm.parse_data_type(sql, dialect)
|
|
6098
|
+
);
|
|
6099
|
+
if (result.success && typeof result.dataType === "string") {
|
|
6100
|
+
result.dataType = JSON.parse(result.dataType);
|
|
6101
|
+
}
|
|
6102
|
+
return result;
|
|
6103
|
+
} catch (error) {
|
|
6104
|
+
return dataTypeFailure("parseDataType", error);
|
|
6105
|
+
}
|
|
6106
|
+
}
|
|
5849
6107
|
function tokenize(sql, dialect = "generic" /* Generic */) {
|
|
5850
6108
|
try {
|
|
5851
6109
|
if (typeof wasm.tokenize_value === "function") {
|
|
@@ -5875,6 +6133,21 @@ function generate(ast2, dialect = "generic" /* Generic */) {
|
|
|
5875
6133
|
return transpileFailure("generate", error);
|
|
5876
6134
|
}
|
|
5877
6135
|
}
|
|
6136
|
+
function generateDataType(dataType, dialect = "generic" /* Generic */) {
|
|
6137
|
+
try {
|
|
6138
|
+
if (typeof wasm.generate_data_type_value === "function") {
|
|
6139
|
+
return decodeWasmPayload(
|
|
6140
|
+
wasm.generate_data_type_value(dataType, dialect)
|
|
6141
|
+
);
|
|
6142
|
+
}
|
|
6143
|
+
const dataTypeJson = JSON.stringify(dataType);
|
|
6144
|
+
return JSON.parse(
|
|
6145
|
+
wasm.generate_data_type(dataTypeJson, dialect)
|
|
6146
|
+
);
|
|
6147
|
+
} catch (error) {
|
|
6148
|
+
return generateDataTypeFailure("generateDataType", error);
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
5878
6151
|
function format(sql, dialect = "generic" /* Generic */) {
|
|
5879
6152
|
return formatWithOptions(sql, dialect, {});
|
|
5880
6153
|
}
|
|
@@ -5909,6 +6182,30 @@ function getDialects() {
|
|
|
5909
6182
|
function getVersion() {
|
|
5910
6183
|
return wasm.version();
|
|
5911
6184
|
}
|
|
6185
|
+
function analyzeQuery(sql, options = {}) {
|
|
6186
|
+
try {
|
|
6187
|
+
const normalized = {
|
|
6188
|
+
dialect: "generic" /* Generic */,
|
|
6189
|
+
...options
|
|
6190
|
+
};
|
|
6191
|
+
if (typeof wasm.analyze_query_value === "function") {
|
|
6192
|
+
return decodeWasmPayload(
|
|
6193
|
+
wasm.analyze_query_value(sql, normalized)
|
|
6194
|
+
);
|
|
6195
|
+
}
|
|
6196
|
+
if (typeof wasm.analyze_query === "function") {
|
|
6197
|
+
return JSON.parse(
|
|
6198
|
+
wasm.analyze_query(sql, JSON.stringify(normalized))
|
|
6199
|
+
);
|
|
6200
|
+
}
|
|
6201
|
+
return {
|
|
6202
|
+
success: false,
|
|
6203
|
+
error: "analyze_query not available in this WASM build"
|
|
6204
|
+
};
|
|
6205
|
+
} catch (error) {
|
|
6206
|
+
return queryAnalysisFailure("analyzeQuery", error);
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
5912
6209
|
function annotateTypes(sql, dialect = "generic" /* Generic */, schema) {
|
|
5913
6210
|
try {
|
|
5914
6211
|
const schemaJson = schema ? JSON.stringify(schema) : "";
|
|
@@ -5954,8 +6251,8 @@ class Polyglot {
|
|
|
5954
6251
|
* Per-dialect builds only support same-dialect and to/from Generic transpilation.
|
|
5955
6252
|
* Use {@link Polyglot.getDialects} to check available dialects.
|
|
5956
6253
|
*/
|
|
5957
|
-
transpile(sql, read, write) {
|
|
5958
|
-
return transpile(sql, read, write);
|
|
6254
|
+
transpile(sql, read, write, options) {
|
|
6255
|
+
return transpile(sql, read, write, options);
|
|
5959
6256
|
}
|
|
5960
6257
|
/**
|
|
5961
6258
|
* Parse SQL into an AST.
|
|
@@ -5963,6 +6260,12 @@ class Polyglot {
|
|
|
5963
6260
|
parse(sql, dialect = "generic" /* Generic */) {
|
|
5964
6261
|
return parse(sql, dialect);
|
|
5965
6262
|
}
|
|
6263
|
+
/**
|
|
6264
|
+
* Parse a standalone SQL data type.
|
|
6265
|
+
*/
|
|
6266
|
+
parseDataType(sql, dialect = "generic" /* Generic */) {
|
|
6267
|
+
return parseDataType(sql, dialect);
|
|
6268
|
+
}
|
|
5966
6269
|
/**
|
|
5967
6270
|
* Tokenize SQL into a token stream.
|
|
5968
6271
|
*/
|
|
@@ -5975,6 +6278,12 @@ class Polyglot {
|
|
|
5975
6278
|
generate(ast2, dialect = "generic" /* Generic */) {
|
|
5976
6279
|
return generate(ast2, dialect);
|
|
5977
6280
|
}
|
|
6281
|
+
/**
|
|
6282
|
+
* Generate SQL from a standalone DataType AST node.
|
|
6283
|
+
*/
|
|
6284
|
+
generateDataType(dataType, dialect = "generic" /* Generic */) {
|
|
6285
|
+
return generateDataType(dataType, dialect);
|
|
6286
|
+
}
|
|
5978
6287
|
/**
|
|
5979
6288
|
* Format SQL.
|
|
5980
6289
|
*/
|
|
@@ -6006,16 +6315,25 @@ class Polyglot {
|
|
|
6006
6315
|
annotateTypes(sql, dialect = "generic" /* Generic */, schema) {
|
|
6007
6316
|
return annotateTypes(sql, dialect, schema);
|
|
6008
6317
|
}
|
|
6318
|
+
/**
|
|
6319
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
6320
|
+
*/
|
|
6321
|
+
analyzeQuery(sql, options = {}) {
|
|
6322
|
+
return analyzeQuery(sql, options);
|
|
6323
|
+
}
|
|
6009
6324
|
}
|
|
6010
6325
|
const index = {
|
|
6011
6326
|
init,
|
|
6012
6327
|
isInitialized,
|
|
6013
6328
|
transpile,
|
|
6014
6329
|
parse,
|
|
6330
|
+
parseDataType,
|
|
6015
6331
|
tokenize,
|
|
6016
6332
|
generate,
|
|
6333
|
+
generateDataType,
|
|
6017
6334
|
format,
|
|
6018
6335
|
annotateTypes,
|
|
6336
|
+
analyzeQuery,
|
|
6019
6337
|
getDialects,
|
|
6020
6338
|
getVersion,
|
|
6021
6339
|
lineage: lineage,
|
|
@@ -6032,4 +6350,4 @@ const index = {
|
|
|
6032
6350
|
Polyglot
|
|
6033
6351
|
};
|
|
6034
6352
|
|
|
6035
|
-
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 };
|
|
6353
|
+
export { CaseBuilder, DeleteBuilder, Dialect, Expr, InsertBuilder, MergeBuilder, Polyglot, SelectBuilder, SetOpBuilder, UpdateBuilder, ValidationSeverity, WindowDefBuilder, abs, alias, analyzeQuery, 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, generateDataType, 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, parseDataType, 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 };
|