@polyglot-sql/sdk 0.5.0 → 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 +46 -0
- package/dist/cdn/polyglot.esm.js +1676 -1524
- package/dist/index.cjs +210 -0
- package/dist/index.d.cts +156 -1
- package/dist/index.d.ts +156 -1
- package/dist/index.js +244 -1
- package/dist/index.node.js +204 -0
- package/dist/manual.js +232 -1
- package/dist/polyglot_sql.wasm +0 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1513,6 +1513,32 @@ class WasmWindowDefBuilder {
|
|
|
1513
1513
|
}
|
|
1514
1514
|
}
|
|
1515
1515
|
if (Symbol.dispose) WasmWindowDefBuilder.prototype[Symbol.dispose] = WasmWindowDefBuilder.prototype.free;
|
|
1516
|
+
function analyze_query$1(sql, options_json) {
|
|
1517
|
+
let deferred3_0;
|
|
1518
|
+
let deferred3_1;
|
|
1519
|
+
try {
|
|
1520
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1521
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1522
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1523
|
+
const ptr1 = passStringToWasm0(options_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1524
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1525
|
+
wasm$3.analyze_query(retptr, ptr0, len0, ptr1, len1);
|
|
1526
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1527
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1528
|
+
deferred3_0 = r0;
|
|
1529
|
+
deferred3_1 = r1;
|
|
1530
|
+
return getStringFromWasm0(r0, r1);
|
|
1531
|
+
} finally {
|
|
1532
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
1533
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
function analyze_query_value$1(sql, options) {
|
|
1537
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1538
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1539
|
+
const ret = wasm$3.analyze_query_value(ptr0, len0, addHeapObject(options));
|
|
1540
|
+
return takeObject(ret);
|
|
1541
|
+
}
|
|
1516
1542
|
function annotate_types$1(sql, dialect, schema_json) {
|
|
1517
1543
|
let deferred4_0;
|
|
1518
1544
|
let deferred4_1;
|
|
@@ -1965,6 +1991,32 @@ function generate$2(ast_json, dialect) {
|
|
|
1965
1991
|
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
1966
1992
|
}
|
|
1967
1993
|
}
|
|
1994
|
+
function generate_data_type$1(data_type_json, dialect) {
|
|
1995
|
+
let deferred3_0;
|
|
1996
|
+
let deferred3_1;
|
|
1997
|
+
try {
|
|
1998
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
1999
|
+
const ptr0 = passStringToWasm0(data_type_json, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2000
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2001
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2002
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2003
|
+
wasm$3.generate_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2004
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2005
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2006
|
+
deferred3_0 = r0;
|
|
2007
|
+
deferred3_1 = r1;
|
|
2008
|
+
return getStringFromWasm0(r0, r1);
|
|
2009
|
+
} finally {
|
|
2010
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2011
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
function generate_data_type_value$1(data_type, dialect) {
|
|
2015
|
+
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2016
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2017
|
+
const ret = wasm$3.generate_data_type_value(addHeapObject(data_type), ptr0, len0);
|
|
2018
|
+
return takeObject(ret);
|
|
2019
|
+
}
|
|
1968
2020
|
function generate_value$1(ast, dialect) {
|
|
1969
2021
|
const ptr0 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
1970
2022
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -2117,6 +2169,34 @@ function parse$2(sql, dialect) {
|
|
|
2117
2169
|
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2118
2170
|
}
|
|
2119
2171
|
}
|
|
2172
|
+
function parse_data_type$1(sql, dialect) {
|
|
2173
|
+
let deferred3_0;
|
|
2174
|
+
let deferred3_1;
|
|
2175
|
+
try {
|
|
2176
|
+
const retptr = wasm$3.__wbindgen_add_to_stack_pointer(-16);
|
|
2177
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2178
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2179
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2180
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2181
|
+
wasm$3.parse_data_type(retptr, ptr0, len0, ptr1, len1);
|
|
2182
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
2183
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
2184
|
+
deferred3_0 = r0;
|
|
2185
|
+
deferred3_1 = r1;
|
|
2186
|
+
return getStringFromWasm0(r0, r1);
|
|
2187
|
+
} finally {
|
|
2188
|
+
wasm$3.__wbindgen_add_to_stack_pointer(16);
|
|
2189
|
+
wasm$3.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
function parse_data_type_value$1(sql, dialect) {
|
|
2193
|
+
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2195
|
+
const ptr1 = passStringToWasm0(dialect, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2196
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2197
|
+
const ret = wasm$3.parse_data_type_value(ptr0, len0, ptr1, len1);
|
|
2198
|
+
return takeObject(ret);
|
|
2199
|
+
}
|
|
2120
2200
|
function parse_value$1(sql, dialect) {
|
|
2121
2201
|
const ptr0 = passStringToWasm0(sql, wasm$3.__wbindgen_export, wasm$3.__wbindgen_export2);
|
|
2122
2202
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -3014,6 +3094,8 @@ async function __polyglot_init_wasm() {
|
|
|
3014
3094
|
__wbg_wasmsetopbuilder_free = __vite__wasmModule.__wbg_wasmsetopbuilder_free;
|
|
3015
3095
|
__wbg_wasmupdatebuilder_free = __vite__wasmModule.__wbg_wasmupdatebuilder_free;
|
|
3016
3096
|
__wbg_wasmwindowdefbuilder_free = __vite__wasmModule.__wbg_wasmwindowdefbuilder_free;
|
|
3097
|
+
analyze_query = __vite__wasmModule.analyze_query;
|
|
3098
|
+
analyze_query_value = __vite__wasmModule.analyze_query_value;
|
|
3017
3099
|
annotate_types = __vite__wasmModule.annotate_types;
|
|
3018
3100
|
annotate_types_value = __vite__wasmModule.annotate_types_value;
|
|
3019
3101
|
ast_add_where = __vite__wasmModule.ast_add_where;
|
|
@@ -3039,6 +3121,8 @@ async function __polyglot_init_wasm() {
|
|
|
3039
3121
|
format_sql_with_options = __vite__wasmModule.format_sql_with_options;
|
|
3040
3122
|
format_sql_with_options_value = __vite__wasmModule.format_sql_with_options_value;
|
|
3041
3123
|
generate$1 = __vite__wasmModule.generate;
|
|
3124
|
+
generate_data_type = __vite__wasmModule.generate_data_type;
|
|
3125
|
+
generate_data_type_value = __vite__wasmModule.generate_data_type_value;
|
|
3042
3126
|
generate_value = __vite__wasmModule.generate_value;
|
|
3043
3127
|
get_dialects = __vite__wasmModule.get_dialects;
|
|
3044
3128
|
get_dialects_value = __vite__wasmModule.get_dialects_value;
|
|
@@ -3048,6 +3132,8 @@ async function __polyglot_init_wasm() {
|
|
|
3048
3132
|
openlineage_job_event = __vite__wasmModule.openlineage_job_event;
|
|
3049
3133
|
openlineage_run_event = __vite__wasmModule.openlineage_run_event;
|
|
3050
3134
|
parse$1 = __vite__wasmModule.parse;
|
|
3135
|
+
parse_data_type = __vite__wasmModule.parse_data_type;
|
|
3136
|
+
parse_data_type_value = __vite__wasmModule.parse_data_type_value;
|
|
3051
3137
|
parse_value = __vite__wasmModule.parse_value;
|
|
3052
3138
|
plan$1 = __vite__wasmModule.plan;
|
|
3053
3139
|
source_tables = __vite__wasmModule.source_tables;
|
|
@@ -3207,6 +3293,8 @@ let __wbg_wasmselectbuilder_free;
|
|
|
3207
3293
|
let __wbg_wasmsetopbuilder_free;
|
|
3208
3294
|
let __wbg_wasmupdatebuilder_free;
|
|
3209
3295
|
let __wbg_wasmwindowdefbuilder_free;
|
|
3296
|
+
let analyze_query;
|
|
3297
|
+
let analyze_query_value;
|
|
3210
3298
|
let annotate_types;
|
|
3211
3299
|
let annotate_types_value;
|
|
3212
3300
|
let ast_add_where;
|
|
@@ -3232,6 +3320,8 @@ let format_sql_value;
|
|
|
3232
3320
|
let format_sql_with_options;
|
|
3233
3321
|
let format_sql_with_options_value;
|
|
3234
3322
|
let generate$1;
|
|
3323
|
+
let generate_data_type;
|
|
3324
|
+
let generate_data_type_value;
|
|
3235
3325
|
let generate_value;
|
|
3236
3326
|
let get_dialects;
|
|
3237
3327
|
let get_dialects_value;
|
|
@@ -3241,6 +3331,8 @@ let openlineage_column_lineage;
|
|
|
3241
3331
|
let openlineage_job_event;
|
|
3242
3332
|
let openlineage_run_event;
|
|
3243
3333
|
let parse$1;
|
|
3334
|
+
let parse_data_type;
|
|
3335
|
+
let parse_data_type_value;
|
|
3244
3336
|
let parse_value;
|
|
3245
3337
|
let plan$1;
|
|
3246
3338
|
let source_tables;
|
|
@@ -3402,6 +3494,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3402
3494
|
__wbindgen_export2,
|
|
3403
3495
|
__wbindgen_export3,
|
|
3404
3496
|
__wbindgen_export4,
|
|
3497
|
+
analyze_query,
|
|
3498
|
+
analyze_query_value,
|
|
3405
3499
|
annotate_types,
|
|
3406
3500
|
annotate_types_value,
|
|
3407
3501
|
ast_add_where,
|
|
@@ -3427,6 +3521,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3427
3521
|
format_sql_with_options,
|
|
3428
3522
|
format_sql_with_options_value,
|
|
3429
3523
|
generate: generate$1,
|
|
3524
|
+
generate_data_type,
|
|
3525
|
+
generate_data_type_value,
|
|
3430
3526
|
generate_value,
|
|
3431
3527
|
get_dialects,
|
|
3432
3528
|
get_dialects_value,
|
|
@@ -3437,6 +3533,8 @@ const wasm$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
3437
3533
|
openlineage_job_event,
|
|
3438
3534
|
openlineage_run_event,
|
|
3439
3535
|
parse: parse$1,
|
|
3536
|
+
parse_data_type,
|
|
3537
|
+
parse_data_type_value,
|
|
3440
3538
|
parse_value,
|
|
3441
3539
|
plan: plan$1,
|
|
3442
3540
|
source_tables,
|
|
@@ -3589,6 +3687,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3589
3687
|
WasmSetOpBuilder,
|
|
3590
3688
|
WasmUpdateBuilder,
|
|
3591
3689
|
WasmWindowDefBuilder,
|
|
3690
|
+
analyze_query: analyze_query$1,
|
|
3691
|
+
analyze_query_value: analyze_query_value$1,
|
|
3592
3692
|
annotate_types: annotate_types$1,
|
|
3593
3693
|
annotate_types_value: annotate_types_value$1,
|
|
3594
3694
|
ast_add_where: ast_add_where$1,
|
|
@@ -3614,6 +3714,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3614
3714
|
format_sql_with_options: format_sql_with_options$1,
|
|
3615
3715
|
format_sql_with_options_value: format_sql_with_options_value$1,
|
|
3616
3716
|
generate: generate$2,
|
|
3717
|
+
generate_data_type: generate_data_type$1,
|
|
3718
|
+
generate_data_type_value: generate_data_type_value$1,
|
|
3617
3719
|
generate_value: generate_value$1,
|
|
3618
3720
|
get_dialects: get_dialects$1,
|
|
3619
3721
|
get_dialects_value: get_dialects_value$1,
|
|
@@ -3623,6 +3725,8 @@ const wasmModule = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
3623
3725
|
openlineage_job_event: openlineage_job_event$1,
|
|
3624
3726
|
openlineage_run_event: openlineage_run_event$1,
|
|
3625
3727
|
parse: parse$2,
|
|
3728
|
+
parse_data_type: parse_data_type$1,
|
|
3729
|
+
parse_data_type_value: parse_data_type_value$1,
|
|
3626
3730
|
parse_value: parse_value$1,
|
|
3627
3731
|
plan: plan$2,
|
|
3628
3732
|
source_tables: source_tables$1,
|
|
@@ -5374,12 +5478,37 @@ function parseFailure(context, error) {
|
|
|
5374
5478
|
errorColumn: void 0
|
|
5375
5479
|
};
|
|
5376
5480
|
}
|
|
5481
|
+
function dataTypeFailure(context, error) {
|
|
5482
|
+
return {
|
|
5483
|
+
success: false,
|
|
5484
|
+
dataType: void 0,
|
|
5485
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
5486
|
+
errorLine: void 0,
|
|
5487
|
+
errorColumn: void 0
|
|
5488
|
+
};
|
|
5489
|
+
}
|
|
5490
|
+
function generateDataTypeFailure(context, error) {
|
|
5491
|
+
return {
|
|
5492
|
+
success: false,
|
|
5493
|
+
sql: void 0,
|
|
5494
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`,
|
|
5495
|
+
errorLine: void 0,
|
|
5496
|
+
errorColumn: void 0
|
|
5497
|
+
};
|
|
5498
|
+
}
|
|
5377
5499
|
function decodeWasmPayload(payload) {
|
|
5378
5500
|
if (typeof payload === "string") {
|
|
5379
5501
|
return JSON.parse(payload);
|
|
5380
5502
|
}
|
|
5381
5503
|
return payload;
|
|
5382
5504
|
}
|
|
5505
|
+
function queryAnalysisFailure(context, error) {
|
|
5506
|
+
return {
|
|
5507
|
+
success: false,
|
|
5508
|
+
analysis: void 0,
|
|
5509
|
+
error: `WASM ${context} failed: ${errorMessage(error)}`
|
|
5510
|
+
};
|
|
5511
|
+
}
|
|
5383
5512
|
async function init() {
|
|
5384
5513
|
await __polyglot_init_wasm();
|
|
5385
5514
|
}
|
|
@@ -5429,6 +5558,24 @@ function parse(sql, dialect = "generic") {
|
|
|
5429
5558
|
return parseFailure("parse", error);
|
|
5430
5559
|
}
|
|
5431
5560
|
}
|
|
5561
|
+
function parseDataType(sql, dialect = "generic") {
|
|
5562
|
+
try {
|
|
5563
|
+
if (typeof wasm.parse_data_type_value === "function") {
|
|
5564
|
+
return decodeWasmPayload(
|
|
5565
|
+
wasm.parse_data_type_value(sql, dialect)
|
|
5566
|
+
);
|
|
5567
|
+
}
|
|
5568
|
+
const result = JSON.parse(
|
|
5569
|
+
wasm.parse_data_type(sql, dialect)
|
|
5570
|
+
);
|
|
5571
|
+
if (result.success && typeof result.dataType === "string") {
|
|
5572
|
+
result.dataType = JSON.parse(result.dataType);
|
|
5573
|
+
}
|
|
5574
|
+
return result;
|
|
5575
|
+
} catch (error) {
|
|
5576
|
+
return dataTypeFailure("parseDataType", error);
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5432
5579
|
function tokenize(sql, dialect = "generic") {
|
|
5433
5580
|
try {
|
|
5434
5581
|
if (typeof wasm.tokenize_value === "function") {
|
|
@@ -5458,6 +5605,21 @@ function generate(ast2, dialect = "generic") {
|
|
|
5458
5605
|
return transpileFailure("generate", error);
|
|
5459
5606
|
}
|
|
5460
5607
|
}
|
|
5608
|
+
function generateDataType(dataType, dialect = "generic") {
|
|
5609
|
+
try {
|
|
5610
|
+
if (typeof wasm.generate_data_type_value === "function") {
|
|
5611
|
+
return decodeWasmPayload(
|
|
5612
|
+
wasm.generate_data_type_value(dataType, dialect)
|
|
5613
|
+
);
|
|
5614
|
+
}
|
|
5615
|
+
const dataTypeJson = JSON.stringify(dataType);
|
|
5616
|
+
return JSON.parse(
|
|
5617
|
+
wasm.generate_data_type(dataTypeJson, dialect)
|
|
5618
|
+
);
|
|
5619
|
+
} catch (error) {
|
|
5620
|
+
return generateDataTypeFailure("generateDataType", error);
|
|
5621
|
+
}
|
|
5622
|
+
}
|
|
5461
5623
|
function format(sql, dialect = "generic") {
|
|
5462
5624
|
return formatWithOptions(sql, dialect, {});
|
|
5463
5625
|
}
|
|
@@ -5492,6 +5654,30 @@ function getDialects() {
|
|
|
5492
5654
|
function getVersion() {
|
|
5493
5655
|
return wasm.version();
|
|
5494
5656
|
}
|
|
5657
|
+
function analyzeQuery(sql, options = {}) {
|
|
5658
|
+
try {
|
|
5659
|
+
const normalized = {
|
|
5660
|
+
dialect: "generic",
|
|
5661
|
+
...options
|
|
5662
|
+
};
|
|
5663
|
+
if (typeof wasm.analyze_query_value === "function") {
|
|
5664
|
+
return decodeWasmPayload(
|
|
5665
|
+
wasm.analyze_query_value(sql, normalized)
|
|
5666
|
+
);
|
|
5667
|
+
}
|
|
5668
|
+
if (typeof wasm.analyze_query === "function") {
|
|
5669
|
+
return JSON.parse(
|
|
5670
|
+
wasm.analyze_query(sql, JSON.stringify(normalized))
|
|
5671
|
+
);
|
|
5672
|
+
}
|
|
5673
|
+
return {
|
|
5674
|
+
success: false,
|
|
5675
|
+
error: "analyze_query not available in this WASM build"
|
|
5676
|
+
};
|
|
5677
|
+
} catch (error) {
|
|
5678
|
+
return queryAnalysisFailure("analyzeQuery", error);
|
|
5679
|
+
}
|
|
5680
|
+
}
|
|
5495
5681
|
function annotateTypes(sql, dialect = "generic", schema) {
|
|
5496
5682
|
try {
|
|
5497
5683
|
const schemaJson = schema ? JSON.stringify(schema) : "";
|
|
@@ -5546,6 +5732,12 @@ class Polyglot {
|
|
|
5546
5732
|
parse(sql, dialect = "generic") {
|
|
5547
5733
|
return parse(sql, dialect);
|
|
5548
5734
|
}
|
|
5735
|
+
/**
|
|
5736
|
+
* Parse a standalone SQL data type.
|
|
5737
|
+
*/
|
|
5738
|
+
parseDataType(sql, dialect = "generic") {
|
|
5739
|
+
return parseDataType(sql, dialect);
|
|
5740
|
+
}
|
|
5549
5741
|
/**
|
|
5550
5742
|
* Tokenize SQL into a token stream.
|
|
5551
5743
|
*/
|
|
@@ -5558,6 +5750,12 @@ class Polyglot {
|
|
|
5558
5750
|
generate(ast2, dialect = "generic") {
|
|
5559
5751
|
return generate(ast2, dialect);
|
|
5560
5752
|
}
|
|
5753
|
+
/**
|
|
5754
|
+
* Generate SQL from a standalone DataType AST node.
|
|
5755
|
+
*/
|
|
5756
|
+
generateDataType(dataType, dialect = "generic") {
|
|
5757
|
+
return generateDataType(dataType, dialect);
|
|
5758
|
+
}
|
|
5561
5759
|
/**
|
|
5562
5760
|
* Format SQL.
|
|
5563
5761
|
*/
|
|
@@ -5589,16 +5787,25 @@ class Polyglot {
|
|
|
5589
5787
|
annotateTypes(sql, dialect = "generic", schema) {
|
|
5590
5788
|
return annotateTypes(sql, dialect, schema);
|
|
5591
5789
|
}
|
|
5790
|
+
/**
|
|
5791
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
5792
|
+
*/
|
|
5793
|
+
analyzeQuery(sql, options = {}) {
|
|
5794
|
+
return analyzeQuery(sql, options);
|
|
5795
|
+
}
|
|
5592
5796
|
}
|
|
5593
5797
|
const index = {
|
|
5594
5798
|
init,
|
|
5595
5799
|
isInitialized,
|
|
5596
5800
|
transpile,
|
|
5597
5801
|
parse,
|
|
5802
|
+
parseDataType,
|
|
5598
5803
|
tokenize,
|
|
5599
5804
|
generate,
|
|
5805
|
+
generateDataType,
|
|
5600
5806
|
format,
|
|
5601
5807
|
annotateTypes,
|
|
5808
|
+
analyzeQuery,
|
|
5602
5809
|
getDialects,
|
|
5603
5810
|
getVersion,
|
|
5604
5811
|
lineage,
|
|
@@ -5628,6 +5835,7 @@ exports.ValidationSeverity = ValidationSeverity;
|
|
|
5628
5835
|
exports.WindowDefBuilder = WindowDefBuilder;
|
|
5629
5836
|
exports.abs = abs;
|
|
5630
5837
|
exports.alias = alias;
|
|
5838
|
+
exports.analyzeQuery = analyzeQuery;
|
|
5631
5839
|
exports.and = and;
|
|
5632
5840
|
exports.annotateTypes = annotateTypes;
|
|
5633
5841
|
exports.ast = index$1;
|
|
@@ -5661,6 +5869,7 @@ exports.format = format;
|
|
|
5661
5869
|
exports.formatWithOptions = formatWithOptions;
|
|
5662
5870
|
exports.func = func;
|
|
5663
5871
|
exports.generate = generate;
|
|
5872
|
+
exports.generateDataType = generateDataType;
|
|
5664
5873
|
exports.getColumns = getColumns;
|
|
5665
5874
|
exports.getDialects = getDialects;
|
|
5666
5875
|
exports.getInferredType = getInferredType;
|
|
@@ -5697,6 +5906,7 @@ exports.openLineageJobEvent = openLineageJobEvent;
|
|
|
5697
5906
|
exports.openLineageRunEvent = openLineageRunEvent;
|
|
5698
5907
|
exports.or = or;
|
|
5699
5908
|
exports.parse = parse;
|
|
5909
|
+
exports.parseDataType = parseDataType;
|
|
5700
5910
|
exports.plan = plan;
|
|
5701
5911
|
exports.power = power;
|
|
5702
5912
|
exports.rank = rank;
|
package/dist/index.d.cts
CHANGED
|
@@ -593,6 +593,18 @@ declare type AnalyzeListChainedRows = {
|
|
|
593
593
|
expression: Expression | null;
|
|
594
594
|
};
|
|
595
595
|
|
|
596
|
+
/**
|
|
597
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
598
|
+
*/
|
|
599
|
+
export declare function analyzeQuery(sql: string, options?: AnalyzeQueryOptions): QueryAnalysisResult;
|
|
600
|
+
|
|
601
|
+
export declare interface AnalyzeQueryOptions {
|
|
602
|
+
/** Dialect used for parsing and dialect-aware rendering */
|
|
603
|
+
dialect?: Dialect | string;
|
|
604
|
+
/** Optional schema used for qualification and type annotation */
|
|
605
|
+
schema?: Schema;
|
|
606
|
+
}
|
|
607
|
+
|
|
596
608
|
/**
|
|
597
609
|
* AnalyzeSample
|
|
598
610
|
*/
|
|
@@ -1817,6 +1829,16 @@ declare type ColumnPrefix = {
|
|
|
1817
1829
|
expression: Expression;
|
|
1818
1830
|
};
|
|
1819
1831
|
|
|
1832
|
+
export declare interface ColumnReferenceFact {
|
|
1833
|
+
sourceName?: string;
|
|
1834
|
+
sourceAlias?: string;
|
|
1835
|
+
sourceKind: QueryAnalysisSourceKind;
|
|
1836
|
+
table?: string;
|
|
1837
|
+
column: string;
|
|
1838
|
+
unqualified: boolean;
|
|
1839
|
+
confidence: ReferenceConfidence;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1820
1842
|
/**
|
|
1821
1843
|
* Columns
|
|
1822
1844
|
*/
|
|
@@ -3021,7 +3043,7 @@ declare type DataDeletionProperty = {
|
|
|
3021
3043
|
* Types that do not match any known variant fall through to `Custom { name }`,
|
|
3022
3044
|
* preserving the original type name for round-trip fidelity.
|
|
3023
3045
|
*/
|
|
3024
|
-
declare type DataType = {
|
|
3046
|
+
export declare type DataType = {
|
|
3025
3047
|
"data_type": "boolean";
|
|
3026
3048
|
} | {
|
|
3027
3049
|
"data_type": "tiny_int";
|
|
@@ -3158,6 +3180,23 @@ declare type DataType = {
|
|
|
3158
3180
|
"data_type": "unknown";
|
|
3159
3181
|
};
|
|
3160
3182
|
|
|
3183
|
+
/**
|
|
3184
|
+
* Result of a standalone data type parse operation
|
|
3185
|
+
*/
|
|
3186
|
+
export declare interface DataTypeResult {
|
|
3187
|
+
success: boolean;
|
|
3188
|
+
dataType?: DataType;
|
|
3189
|
+
error?: string;
|
|
3190
|
+
/** 1-based line number where the error occurred */
|
|
3191
|
+
errorLine?: number;
|
|
3192
|
+
/** 1-based column number where the error occurred */
|
|
3193
|
+
errorColumn?: number;
|
|
3194
|
+
/** Start byte offset of the error range */
|
|
3195
|
+
errorStart?: number;
|
|
3196
|
+
/** End byte offset of the error range (exclusive) */
|
|
3197
|
+
errorEnd?: number;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3161
3200
|
/**
|
|
3162
3201
|
* DATE_ADD / DATE_SUB function
|
|
3163
3202
|
*/
|
|
@@ -3366,10 +3405,13 @@ declare const _default: {
|
|
|
3366
3405
|
isInitialized: typeof isInitialized;
|
|
3367
3406
|
transpile: typeof transpile;
|
|
3368
3407
|
parse: typeof parse;
|
|
3408
|
+
parseDataType: typeof parseDataType;
|
|
3369
3409
|
tokenize: typeof tokenize;
|
|
3370
3410
|
generate: typeof generate;
|
|
3411
|
+
generateDataType: typeof generateDataType;
|
|
3371
3412
|
format: typeof format;
|
|
3372
3413
|
annotateTypes: typeof annotateTypes;
|
|
3414
|
+
analyzeQuery: typeof analyzeQuery;
|
|
3373
3415
|
getDialects: typeof getDialects;
|
|
3374
3416
|
getVersion: typeof getVersion;
|
|
3375
3417
|
lineage: typeof lineage;
|
|
@@ -6702,6 +6744,39 @@ declare type GeneratedAsRowColumnConstraint = {
|
|
|
6702
6744
|
hidden: Expression | null;
|
|
6703
6745
|
};
|
|
6704
6746
|
|
|
6747
|
+
/**
|
|
6748
|
+
* Generate SQL from a standalone DataType AST node.
|
|
6749
|
+
*
|
|
6750
|
+
* @param dataType - The DataType object to render
|
|
6751
|
+
* @param dialect - The target dialect
|
|
6752
|
+
* @returns The generated data type SQL
|
|
6753
|
+
*
|
|
6754
|
+
* @example
|
|
6755
|
+
* ```typescript
|
|
6756
|
+
* const parsed = parseDataType("VARCHAR(255)", Dialect.DuckDB);
|
|
6757
|
+
* const rendered = generateDataType(parsed.dataType!, Dialect.PostgreSQL);
|
|
6758
|
+
* // rendered.sql = "VARCHAR(255)"
|
|
6759
|
+
* ```
|
|
6760
|
+
*/
|
|
6761
|
+
export declare function generateDataType(dataType: DataType, dialect?: Dialect): GenerateDataTypeResult;
|
|
6762
|
+
|
|
6763
|
+
/**
|
|
6764
|
+
* Result of a standalone data type generation operation
|
|
6765
|
+
*/
|
|
6766
|
+
export declare interface GenerateDataTypeResult {
|
|
6767
|
+
success: boolean;
|
|
6768
|
+
sql?: string;
|
|
6769
|
+
error?: string;
|
|
6770
|
+
/** 1-based line number where the error occurred */
|
|
6771
|
+
errorLine?: number;
|
|
6772
|
+
/** 1-based column number where the error occurred */
|
|
6773
|
+
errorColumn?: number;
|
|
6774
|
+
/** Start byte offset of the error range */
|
|
6775
|
+
errorStart?: number;
|
|
6776
|
+
/** End byte offset of the error range (exclusive) */
|
|
6777
|
+
errorEnd?: number;
|
|
6778
|
+
}
|
|
6779
|
+
|
|
6705
6780
|
/**
|
|
6706
6781
|
* GenerateDateArray
|
|
6707
6782
|
*/
|
|
@@ -10227,6 +10302,21 @@ declare type Paren = {
|
|
|
10227
10302
|
*/
|
|
10228
10303
|
export declare function parse(sql: string, dialect?: Dialect): ParseResult;
|
|
10229
10304
|
|
|
10305
|
+
/**
|
|
10306
|
+
* Parse a standalone SQL data type.
|
|
10307
|
+
*
|
|
10308
|
+
* @param sql - The data type string to parse
|
|
10309
|
+
* @param dialect - The dialect to use
|
|
10310
|
+
* @returns The parsed DataType AST node
|
|
10311
|
+
*
|
|
10312
|
+
* @example
|
|
10313
|
+
* ```typescript
|
|
10314
|
+
* const result = parseDataType("DECIMAL(10, 2)", Dialect.DuckDB);
|
|
10315
|
+
* console.log(result.dataType);
|
|
10316
|
+
* ```
|
|
10317
|
+
*/
|
|
10318
|
+
export declare function parseDataType(sql: string, dialect?: Dialect): DataTypeResult;
|
|
10319
|
+
|
|
10230
10320
|
/**
|
|
10231
10321
|
* ParseDatetime
|
|
10232
10322
|
*/
|
|
@@ -10595,6 +10685,10 @@ export declare class Polyglot {
|
|
|
10595
10685
|
* Parse SQL into an AST.
|
|
10596
10686
|
*/
|
|
10597
10687
|
parse(sql: string, dialect?: Dialect): ParseResult;
|
|
10688
|
+
/**
|
|
10689
|
+
* Parse a standalone SQL data type.
|
|
10690
|
+
*/
|
|
10691
|
+
parseDataType(sql: string, dialect?: Dialect): DataTypeResult;
|
|
10598
10692
|
/**
|
|
10599
10693
|
* Tokenize SQL into a token stream.
|
|
10600
10694
|
*/
|
|
@@ -10603,6 +10697,10 @@ export declare class Polyglot {
|
|
|
10603
10697
|
* Generate SQL from an AST.
|
|
10604
10698
|
*/
|
|
10605
10699
|
generate(ast: any, dialect?: Dialect): TranspileResult;
|
|
10700
|
+
/**
|
|
10701
|
+
* Generate SQL from a standalone DataType AST node.
|
|
10702
|
+
*/
|
|
10703
|
+
generateDataType(dataType: DataType, dialect?: Dialect): GenerateDataTypeResult;
|
|
10606
10704
|
/**
|
|
10607
10705
|
* Format SQL.
|
|
10608
10706
|
*/
|
|
@@ -10624,6 +10722,10 @@ export declare class Polyglot {
|
|
|
10624
10722
|
* Parse SQL and annotate the AST with inferred type information.
|
|
10625
10723
|
*/
|
|
10626
10724
|
annotateTypes(sql: string, dialect?: Dialect, schema?: Schema): AnnotateTypesResult;
|
|
10725
|
+
/**
|
|
10726
|
+
* Return compact query analysis facts for a SELECT or set operation.
|
|
10727
|
+
*/
|
|
10728
|
+
analyzeQuery(sql: string, options?: AnalyzeQueryOptions): QueryAnalysisResult;
|
|
10627
10729
|
}
|
|
10628
10730
|
|
|
10629
10731
|
/**
|
|
@@ -10759,6 +10861,17 @@ declare type ProjectionDef = {
|
|
|
10759
10861
|
expression: Expression;
|
|
10760
10862
|
};
|
|
10761
10863
|
|
|
10864
|
+
export declare interface ProjectionFact {
|
|
10865
|
+
index: number;
|
|
10866
|
+
name?: string;
|
|
10867
|
+
isStar: boolean;
|
|
10868
|
+
starTable?: string;
|
|
10869
|
+
transformKind: TransformKind;
|
|
10870
|
+
castType?: string;
|
|
10871
|
+
typeHint?: string;
|
|
10872
|
+
upstream: ColumnReferenceFact[];
|
|
10873
|
+
}
|
|
10874
|
+
|
|
10762
10875
|
/**
|
|
10763
10876
|
* Properties
|
|
10764
10877
|
*/
|
|
@@ -10887,6 +11000,22 @@ declare type Quantile = {
|
|
|
10887
11000
|
quantile: Expression | null;
|
|
10888
11001
|
};
|
|
10889
11002
|
|
|
11003
|
+
export declare interface QueryAnalysis {
|
|
11004
|
+
shape: QueryShape;
|
|
11005
|
+
ctes: string[];
|
|
11006
|
+
projections: ProjectionFact[];
|
|
11007
|
+
relations: RelationFact[];
|
|
11008
|
+
setOperations: SetOperationFact[];
|
|
11009
|
+
}
|
|
11010
|
+
|
|
11011
|
+
export declare interface QueryAnalysisResult {
|
|
11012
|
+
success: boolean;
|
|
11013
|
+
analysis?: QueryAnalysis;
|
|
11014
|
+
error?: string;
|
|
11015
|
+
}
|
|
11016
|
+
|
|
11017
|
+
export declare type QueryAnalysisSourceKind = 'root' | 'table' | 'derived_table' | 'cte' | 'virtual' | 'unknown';
|
|
11018
|
+
|
|
10890
11019
|
/**
|
|
10891
11020
|
* QueryBand
|
|
10892
11021
|
*/
|
|
@@ -10916,6 +11045,8 @@ export declare interface QueryPlan {
|
|
|
10916
11045
|
leaves: PlanStep[];
|
|
10917
11046
|
}
|
|
10918
11047
|
|
|
11048
|
+
export declare type QueryShape = 'select' | 'set_operation';
|
|
11049
|
+
|
|
10919
11050
|
/**
|
|
10920
11051
|
* QueryTransform
|
|
10921
11052
|
*/
|
|
@@ -11048,6 +11179,8 @@ declare type Reference = {
|
|
|
11048
11179
|
options: Array<Expression>;
|
|
11049
11180
|
};
|
|
11050
11181
|
|
|
11182
|
+
export declare type ReferenceConfidence = 'resolved' | 'ambiguous' | 'unknown';
|
|
11183
|
+
|
|
11051
11184
|
/**
|
|
11052
11185
|
* Union of all reference expression types (identifiers, columns, tables)
|
|
11053
11186
|
*/
|
|
@@ -11271,6 +11404,13 @@ declare type RegrValy = {
|
|
|
11271
11404
|
expression: Expression;
|
|
11272
11405
|
};
|
|
11273
11406
|
|
|
11407
|
+
export declare interface RelationFact {
|
|
11408
|
+
name: string;
|
|
11409
|
+
alias?: string;
|
|
11410
|
+
kind: QueryAnalysisSourceKind;
|
|
11411
|
+
columns: string[];
|
|
11412
|
+
}
|
|
11413
|
+
|
|
11274
11414
|
/**
|
|
11275
11415
|
* RemoteWithConnectionModelProperty
|
|
11276
11416
|
*/
|
|
@@ -12141,11 +12281,24 @@ declare type SetOperation = {
|
|
|
12141
12281
|
on: Expression | null;
|
|
12142
12282
|
};
|
|
12143
12283
|
|
|
12284
|
+
export declare interface SetOperationBranchFact {
|
|
12285
|
+
index: number;
|
|
12286
|
+
projections: ProjectionFact[];
|
|
12287
|
+
}
|
|
12288
|
+
|
|
12144
12289
|
/**
|
|
12145
12290
|
* Union of all set operation expression types
|
|
12146
12291
|
*/
|
|
12147
12292
|
declare type SetOperationExpression = ExpressionByType<'union'> | ExpressionByType<'intersect'> | ExpressionByType<'except'>;
|
|
12148
12293
|
|
|
12294
|
+
export declare interface SetOperationFact {
|
|
12295
|
+
kind: 'union' | 'intersect' | 'except' | string;
|
|
12296
|
+
all: boolean;
|
|
12297
|
+
distinct: boolean;
|
|
12298
|
+
outputColumns: string[];
|
|
12299
|
+
branches: SetOperationBranchFact[];
|
|
12300
|
+
}
|
|
12301
|
+
|
|
12149
12302
|
export declare type SetOperationType = 'union' | 'union_all' | 'intersect' | 'except';
|
|
12150
12303
|
|
|
12151
12304
|
/**
|
|
@@ -13561,6 +13714,8 @@ declare type TransformFunc = {
|
|
|
13561
13714
|
transform: Expression;
|
|
13562
13715
|
};
|
|
13563
13716
|
|
|
13717
|
+
export declare type TransformKind = 'direct' | 'cast' | 'aggregation' | 'constant' | 'expression' | 'star';
|
|
13718
|
+
|
|
13564
13719
|
/**
|
|
13565
13720
|
* TransformModelProperty
|
|
13566
13721
|
*/
|