@polyglot-sql/sdk 0.5.0 → 0.5.2

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/dist/index.d.ts CHANGED
@@ -593,6 +593,20 @@ 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, dialect: Dialect | string): QueryAnalysisResult;
600
+
601
+ export declare function analyzeQuery(sql: string, options?: AnalyzeQueryOptions): QueryAnalysisResult;
602
+
603
+ export declare interface AnalyzeQueryOptions {
604
+ /** Dialect used for parsing and dialect-aware rendering */
605
+ dialect?: Dialect | string;
606
+ /** Optional schema used for qualification and type annotation */
607
+ schema?: Schema;
608
+ }
609
+
596
610
  /**
597
611
  * AnalyzeSample
598
612
  */
@@ -1817,6 +1831,16 @@ declare type ColumnPrefix = {
1817
1831
  expression: Expression;
1818
1832
  };
1819
1833
 
1834
+ export declare interface ColumnReferenceFact {
1835
+ sourceName?: string;
1836
+ sourceAlias?: string;
1837
+ sourceKind: QueryAnalysisSourceKind;
1838
+ table?: string;
1839
+ column: string;
1840
+ unqualified: boolean;
1841
+ confidence: ReferenceConfidence;
1842
+ }
1843
+
1820
1844
  /**
1821
1845
  * Columns
1822
1846
  */
@@ -3021,7 +3045,7 @@ declare type DataDeletionProperty = {
3021
3045
  * Types that do not match any known variant fall through to `Custom { name }`,
3022
3046
  * preserving the original type name for round-trip fidelity.
3023
3047
  */
3024
- declare type DataType = {
3048
+ export declare type DataType = {
3025
3049
  "data_type": "boolean";
3026
3050
  } | {
3027
3051
  "data_type": "tiny_int";
@@ -3158,6 +3182,23 @@ declare type DataType = {
3158
3182
  "data_type": "unknown";
3159
3183
  };
3160
3184
 
3185
+ /**
3186
+ * Result of a standalone data type parse operation
3187
+ */
3188
+ export declare interface DataTypeResult {
3189
+ success: boolean;
3190
+ dataType?: DataType;
3191
+ error?: string;
3192
+ /** 1-based line number where the error occurred */
3193
+ errorLine?: number;
3194
+ /** 1-based column number where the error occurred */
3195
+ errorColumn?: number;
3196
+ /** Start byte offset of the error range */
3197
+ errorStart?: number;
3198
+ /** End byte offset of the error range (exclusive) */
3199
+ errorEnd?: number;
3200
+ }
3201
+
3161
3202
  /**
3162
3203
  * DATE_ADD / DATE_SUB function
3163
3204
  */
@@ -3366,10 +3407,13 @@ declare const _default: {
3366
3407
  isInitialized: typeof isInitialized;
3367
3408
  transpile: typeof transpile;
3368
3409
  parse: typeof parse;
3410
+ parseDataType: typeof parseDataType;
3369
3411
  tokenize: typeof tokenize;
3370
3412
  generate: typeof generate;
3413
+ generateDataType: typeof generateDataType;
3371
3414
  format: typeof format;
3372
3415
  annotateTypes: typeof annotateTypes;
3416
+ analyzeQuery: typeof analyzeQuery;
3373
3417
  getDialects: typeof getDialects;
3374
3418
  getVersion: typeof getVersion;
3375
3419
  lineage: typeof lineage;
@@ -6702,6 +6746,39 @@ declare type GeneratedAsRowColumnConstraint = {
6702
6746
  hidden: Expression | null;
6703
6747
  };
6704
6748
 
6749
+ /**
6750
+ * Generate SQL from a standalone DataType AST node.
6751
+ *
6752
+ * @param dataType - The DataType object to render
6753
+ * @param dialect - The target dialect
6754
+ * @returns The generated data type SQL
6755
+ *
6756
+ * @example
6757
+ * ```typescript
6758
+ * const parsed = parseDataType("VARCHAR(255)", Dialect.DuckDB);
6759
+ * const rendered = generateDataType(parsed.dataType!, Dialect.PostgreSQL);
6760
+ * // rendered.sql = "VARCHAR(255)"
6761
+ * ```
6762
+ */
6763
+ export declare function generateDataType(dataType: DataType, dialect?: Dialect): GenerateDataTypeResult;
6764
+
6765
+ /**
6766
+ * Result of a standalone data type generation operation
6767
+ */
6768
+ export declare interface GenerateDataTypeResult {
6769
+ success: boolean;
6770
+ sql?: string;
6771
+ error?: string;
6772
+ /** 1-based line number where the error occurred */
6773
+ errorLine?: number;
6774
+ /** 1-based column number where the error occurred */
6775
+ errorColumn?: number;
6776
+ /** Start byte offset of the error range */
6777
+ errorStart?: number;
6778
+ /** End byte offset of the error range (exclusive) */
6779
+ errorEnd?: number;
6780
+ }
6781
+
6705
6782
  /**
6706
6783
  * GenerateDateArray
6707
6784
  */
@@ -10227,6 +10304,21 @@ declare type Paren = {
10227
10304
  */
10228
10305
  export declare function parse(sql: string, dialect?: Dialect): ParseResult;
10229
10306
 
10307
+ /**
10308
+ * Parse a standalone SQL data type.
10309
+ *
10310
+ * @param sql - The data type string to parse
10311
+ * @param dialect - The dialect to use
10312
+ * @returns The parsed DataType AST node
10313
+ *
10314
+ * @example
10315
+ * ```typescript
10316
+ * const result = parseDataType("DECIMAL(10, 2)", Dialect.DuckDB);
10317
+ * console.log(result.dataType);
10318
+ * ```
10319
+ */
10320
+ export declare function parseDataType(sql: string, dialect?: Dialect): DataTypeResult;
10321
+
10230
10322
  /**
10231
10323
  * ParseDatetime
10232
10324
  */
@@ -10595,6 +10687,10 @@ export declare class Polyglot {
10595
10687
  * Parse SQL into an AST.
10596
10688
  */
10597
10689
  parse(sql: string, dialect?: Dialect): ParseResult;
10690
+ /**
10691
+ * Parse a standalone SQL data type.
10692
+ */
10693
+ parseDataType(sql: string, dialect?: Dialect): DataTypeResult;
10598
10694
  /**
10599
10695
  * Tokenize SQL into a token stream.
10600
10696
  */
@@ -10603,6 +10699,10 @@ export declare class Polyglot {
10603
10699
  * Generate SQL from an AST.
10604
10700
  */
10605
10701
  generate(ast: any, dialect?: Dialect): TranspileResult;
10702
+ /**
10703
+ * Generate SQL from a standalone DataType AST node.
10704
+ */
10705
+ generateDataType(dataType: DataType, dialect?: Dialect): GenerateDataTypeResult;
10606
10706
  /**
10607
10707
  * Format SQL.
10608
10708
  */
@@ -10624,6 +10724,11 @@ export declare class Polyglot {
10624
10724
  * Parse SQL and annotate the AST with inferred type information.
10625
10725
  */
10626
10726
  annotateTypes(sql: string, dialect?: Dialect, schema?: Schema): AnnotateTypesResult;
10727
+ /**
10728
+ * Return compact query analysis facts for a SELECT or set operation.
10729
+ */
10730
+ analyzeQuery(sql: string, dialect: Dialect | string): QueryAnalysisResult;
10731
+ analyzeQuery(sql: string, options?: AnalyzeQueryOptions): QueryAnalysisResult;
10627
10732
  }
10628
10733
 
10629
10734
  /**
@@ -10759,6 +10864,17 @@ declare type ProjectionDef = {
10759
10864
  expression: Expression;
10760
10865
  };
10761
10866
 
10867
+ export declare interface ProjectionFact {
10868
+ index: number;
10869
+ name?: string;
10870
+ isStar: boolean;
10871
+ starTable?: string;
10872
+ transformKind: TransformKind;
10873
+ castType?: string;
10874
+ typeHint?: string;
10875
+ upstream: ColumnReferenceFact[];
10876
+ }
10877
+
10762
10878
  /**
10763
10879
  * Properties
10764
10880
  */
@@ -10887,6 +11003,23 @@ declare type Quantile = {
10887
11003
  quantile: Expression | null;
10888
11004
  };
10889
11005
 
11006
+ export declare interface QueryAnalysis {
11007
+ shape: QueryShape;
11008
+ ctes: string[];
11009
+ projections: ProjectionFact[];
11010
+ relations: RelationFact[];
11011
+ baseTables: RelationFact[];
11012
+ setOperations: SetOperationFact[];
11013
+ }
11014
+
11015
+ export declare interface QueryAnalysisResult {
11016
+ success: boolean;
11017
+ analysis?: QueryAnalysis;
11018
+ error?: string;
11019
+ }
11020
+
11021
+ export declare type QueryAnalysisSourceKind = 'root' | 'table' | 'derived_table' | 'cte' | 'virtual' | 'unknown';
11022
+
10890
11023
  /**
10891
11024
  * QueryBand
10892
11025
  */
@@ -10916,6 +11049,8 @@ export declare interface QueryPlan {
10916
11049
  leaves: PlanStep[];
10917
11050
  }
10918
11051
 
11052
+ export declare type QueryShape = 'select' | 'set_operation';
11053
+
10919
11054
  /**
10920
11055
  * QueryTransform
10921
11056
  */
@@ -11048,6 +11183,8 @@ declare type Reference = {
11048
11183
  options: Array<Expression>;
11049
11184
  };
11050
11185
 
11186
+ export declare type ReferenceConfidence = 'resolved' | 'ambiguous' | 'unknown';
11187
+
11051
11188
  /**
11052
11189
  * Union of all reference expression types (identifiers, columns, tables)
11053
11190
  */
@@ -11271,6 +11408,13 @@ declare type RegrValy = {
11271
11408
  expression: Expression;
11272
11409
  };
11273
11410
 
11411
+ export declare interface RelationFact {
11412
+ name: string;
11413
+ alias?: string;
11414
+ kind: QueryAnalysisSourceKind;
11415
+ columns: string[];
11416
+ }
11417
+
11274
11418
  /**
11275
11419
  * RemoteWithConnectionModelProperty
11276
11420
  */
@@ -12141,11 +12285,24 @@ declare type SetOperation = {
12141
12285
  on: Expression | null;
12142
12286
  };
12143
12287
 
12288
+ export declare interface SetOperationBranchFact {
12289
+ index: number;
12290
+ projections: ProjectionFact[];
12291
+ }
12292
+
12144
12293
  /**
12145
12294
  * Union of all set operation expression types
12146
12295
  */
12147
12296
  declare type SetOperationExpression = ExpressionByType<'union'> | ExpressionByType<'intersect'> | ExpressionByType<'except'>;
12148
12297
 
12298
+ export declare interface SetOperationFact {
12299
+ kind: 'union' | 'intersect' | 'except' | string;
12300
+ all: boolean;
12301
+ distinct: boolean;
12302
+ outputColumns: string[];
12303
+ branches: SetOperationBranchFact[];
12304
+ }
12305
+
12149
12306
  export declare type SetOperationType = 'union' | 'union_all' | 'intersect' | 'except';
12150
12307
 
12151
12308
  /**
@@ -13561,6 +13718,8 @@ declare type TransformFunc = {
13561
13718
  transform: Expression;
13562
13719
  };
13563
13720
 
13721
+ export declare type TransformKind = 'direct' | 'cast' | 'aggregation' | 'constant' | 'expression' | 'star';
13722
+
13564
13723
  /**
13565
13724
  * TransformModelProperty
13566
13725
  */
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
@@ -3678,6 +3800,8 @@ const __wbg_wasmselectbuilder_free = __vite__wasmModule.__wbg_wasmselectbuilder_
3678
3800
  const __wbg_wasmsetopbuilder_free = __vite__wasmModule.__wbg_wasmsetopbuilder_free;
3679
3801
  const __wbg_wasmupdatebuilder_free = __vite__wasmModule.__wbg_wasmupdatebuilder_free;
3680
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;
3681
3805
  const annotate_types = __vite__wasmModule.annotate_types;
3682
3806
  const annotate_types_value = __vite__wasmModule.annotate_types_value;
3683
3807
  const ast_add_where = __vite__wasmModule.ast_add_where;
@@ -3703,6 +3827,8 @@ const format_sql_value = __vite__wasmModule.format_sql_value;
3703
3827
  const format_sql_with_options = __vite__wasmModule.format_sql_with_options;
3704
3828
  const format_sql_with_options_value = __vite__wasmModule.format_sql_with_options_value;
3705
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;
3706
3832
  const generate_value = __vite__wasmModule.generate_value;
3707
3833
  const get_dialects = __vite__wasmModule.get_dialects;
3708
3834
  const get_dialects_value = __vite__wasmModule.get_dialects_value;
@@ -3712,6 +3838,8 @@ const openlineage_column_lineage = __vite__wasmModule.openlineage_column_lineage
3712
3838
  const openlineage_job_event = __vite__wasmModule.openlineage_job_event;
3713
3839
  const openlineage_run_event = __vite__wasmModule.openlineage_run_event;
3714
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;
3715
3843
  const parse_value = __vite__wasmModule.parse_value;
3716
3844
  const plan$1 = __vite__wasmModule.plan;
3717
3845
  const source_tables = __vite__wasmModule.source_tables;
@@ -3874,6 +4002,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3874
4002
  __wbindgen_export2,
3875
4003
  __wbindgen_export3,
3876
4004
  __wbindgen_export4,
4005
+ analyze_query,
4006
+ analyze_query_value,
3877
4007
  annotate_types,
3878
4008
  annotate_types_value,
3879
4009
  ast_add_where,
@@ -3899,6 +4029,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3899
4029
  format_sql_with_options,
3900
4030
  format_sql_with_options_value,
3901
4031
  generate: generate$1,
4032
+ generate_data_type,
4033
+ generate_data_type_value,
3902
4034
  generate_value,
3903
4035
  get_dialects,
3904
4036
  get_dialects_value,
@@ -3909,6 +4041,8 @@ const wasm$2 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3909
4041
  openlineage_job_event,
3910
4042
  openlineage_run_event,
3911
4043
  parse: parse$1,
4044
+ parse_data_type,
4045
+ parse_data_type_value,
3912
4046
  parse_value,
3913
4047
  plan: plan$1,
3914
4048
  source_tables,
@@ -4066,6 +4200,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
4066
4200
  WasmSetOpBuilder,
4067
4201
  WasmUpdateBuilder,
4068
4202
  WasmWindowDefBuilder,
4203
+ analyze_query: analyze_query$1,
4204
+ analyze_query_value: analyze_query_value$1,
4069
4205
  annotate_types: annotate_types$1,
4070
4206
  annotate_types_value: annotate_types_value$1,
4071
4207
  ast_add_where: ast_add_where$1,
@@ -4091,6 +4227,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
4091
4227
  format_sql_with_options: format_sql_with_options$1,
4092
4228
  format_sql_with_options_value: format_sql_with_options_value$1,
4093
4229
  generate: generate$2,
4230
+ generate_data_type: generate_data_type$1,
4231
+ generate_data_type_value: generate_data_type_value$1,
4094
4232
  generate_value: generate_value$1,
4095
4233
  get_dialects: get_dialects$1,
4096
4234
  get_dialects_value: get_dialects_value$1,
@@ -4100,6 +4238,8 @@ const wasmModule = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty
4100
4238
  openlineage_job_event: openlineage_job_event$1,
4101
4239
  openlineage_run_event: openlineage_run_event$1,
4102
4240
  parse: parse$2,
4241
+ parse_data_type: parse_data_type$1,
4242
+ parse_data_type_value: parse_data_type_value$1,
4103
4243
  parse_value: parse_value$1,
4104
4244
  plan: plan$2,
4105
4245
  source_tables: source_tables$1,
@@ -5866,12 +6006,46 @@ function parseFailure(context, error) {
5866
6006
  errorColumn: void 0
5867
6007
  };
5868
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
+ }
5869
6027
  function decodeWasmPayload(payload) {
5870
6028
  if (typeof payload === "string") {
5871
6029
  return JSON.parse(payload);
5872
6030
  }
5873
6031
  return payload;
5874
6032
  }
6033
+ function queryAnalysisFailure(context, error) {
6034
+ return {
6035
+ success: false,
6036
+ analysis: void 0,
6037
+ error: `WASM ${context} failed: ${errorMessage(error)}`
6038
+ };
6039
+ }
6040
+ function normalizeAnalyzeQueryOptions(optionsOrDialect = {}) {
6041
+ if (typeof optionsOrDialect === "string") {
6042
+ return { dialect: optionsOrDialect };
6043
+ }
6044
+ return {
6045
+ dialect: "generic" /* Generic */,
6046
+ ...optionsOrDialect
6047
+ };
6048
+ }
5875
6049
  async function init() {
5876
6050
  return Promise.resolve();
5877
6051
  }
@@ -5921,6 +6095,24 @@ function parse(sql, dialect = "generic" /* Generic */) {
5921
6095
  return parseFailure("parse", error);
5922
6096
  }
5923
6097
  }
6098
+ function parseDataType(sql, dialect = "generic" /* Generic */) {
6099
+ try {
6100
+ if (typeof wasm.parse_data_type_value === "function") {
6101
+ return decodeWasmPayload(
6102
+ wasm.parse_data_type_value(sql, dialect)
6103
+ );
6104
+ }
6105
+ const result = JSON.parse(
6106
+ wasm.parse_data_type(sql, dialect)
6107
+ );
6108
+ if (result.success && typeof result.dataType === "string") {
6109
+ result.dataType = JSON.parse(result.dataType);
6110
+ }
6111
+ return result;
6112
+ } catch (error) {
6113
+ return dataTypeFailure("parseDataType", error);
6114
+ }
6115
+ }
5924
6116
  function tokenize(sql, dialect = "generic" /* Generic */) {
5925
6117
  try {
5926
6118
  if (typeof wasm.tokenize_value === "function") {
@@ -5950,6 +6142,21 @@ function generate(ast2, dialect = "generic" /* Generic */) {
5950
6142
  return transpileFailure("generate", error);
5951
6143
  }
5952
6144
  }
6145
+ function generateDataType(dataType, dialect = "generic" /* Generic */) {
6146
+ try {
6147
+ if (typeof wasm.generate_data_type_value === "function") {
6148
+ return decodeWasmPayload(
6149
+ wasm.generate_data_type_value(dataType, dialect)
6150
+ );
6151
+ }
6152
+ const dataTypeJson = JSON.stringify(dataType);
6153
+ return JSON.parse(
6154
+ wasm.generate_data_type(dataTypeJson, dialect)
6155
+ );
6156
+ } catch (error) {
6157
+ return generateDataTypeFailure("generateDataType", error);
6158
+ }
6159
+ }
5953
6160
  function format(sql, dialect = "generic" /* Generic */) {
5954
6161
  return formatWithOptions(sql, dialect, {});
5955
6162
  }
@@ -5984,6 +6191,27 @@ function getDialects() {
5984
6191
  function getVersion() {
5985
6192
  return wasm.version();
5986
6193
  }
6194
+ function analyzeQuery(sql, optionsOrDialect = {}) {
6195
+ try {
6196
+ const normalized = normalizeAnalyzeQueryOptions(optionsOrDialect);
6197
+ if (typeof wasm.analyze_query_value === "function") {
6198
+ return decodeWasmPayload(
6199
+ wasm.analyze_query_value(sql, normalized)
6200
+ );
6201
+ }
6202
+ if (typeof wasm.analyze_query === "function") {
6203
+ return JSON.parse(
6204
+ wasm.analyze_query(sql, JSON.stringify(normalized))
6205
+ );
6206
+ }
6207
+ return {
6208
+ success: false,
6209
+ error: "analyze_query not available in this WASM build"
6210
+ };
6211
+ } catch (error) {
6212
+ return queryAnalysisFailure("analyzeQuery", error);
6213
+ }
6214
+ }
5987
6215
  function annotateTypes(sql, dialect = "generic" /* Generic */, schema) {
5988
6216
  try {
5989
6217
  const schemaJson = schema ? JSON.stringify(schema) : "";
@@ -6038,6 +6266,12 @@ class Polyglot {
6038
6266
  parse(sql, dialect = "generic" /* Generic */) {
6039
6267
  return parse(sql, dialect);
6040
6268
  }
6269
+ /**
6270
+ * Parse a standalone SQL data type.
6271
+ */
6272
+ parseDataType(sql, dialect = "generic" /* Generic */) {
6273
+ return parseDataType(sql, dialect);
6274
+ }
6041
6275
  /**
6042
6276
  * Tokenize SQL into a token stream.
6043
6277
  */
@@ -6050,6 +6284,12 @@ class Polyglot {
6050
6284
  generate(ast2, dialect = "generic" /* Generic */) {
6051
6285
  return generate(ast2, dialect);
6052
6286
  }
6287
+ /**
6288
+ * Generate SQL from a standalone DataType AST node.
6289
+ */
6290
+ generateDataType(dataType, dialect = "generic" /* Generic */) {
6291
+ return generateDataType(dataType, dialect);
6292
+ }
6053
6293
  /**
6054
6294
  * Format SQL.
6055
6295
  */
@@ -6081,16 +6321,22 @@ class Polyglot {
6081
6321
  annotateTypes(sql, dialect = "generic" /* Generic */, schema) {
6082
6322
  return annotateTypes(sql, dialect, schema);
6083
6323
  }
6324
+ analyzeQuery(sql, optionsOrDialect = {}) {
6325
+ return analyzeQuery(sql, normalizeAnalyzeQueryOptions(optionsOrDialect));
6326
+ }
6084
6327
  }
6085
6328
  const index = {
6086
6329
  init,
6087
6330
  isInitialized,
6088
6331
  transpile,
6089
6332
  parse,
6333
+ parseDataType,
6090
6334
  tokenize,
6091
6335
  generate,
6336
+ generateDataType,
6092
6337
  format,
6093
6338
  annotateTypes,
6339
+ analyzeQuery,
6094
6340
  getDialects,
6095
6341
  getVersion,
6096
6342
  lineage: lineage,
@@ -6107,4 +6353,4 @@ const index = {
6107
6353
  Polyglot
6108
6354
  };
6109
6355
 
6110
- 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 };
6356
+ 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 };