@uwdata/mosaic-sql 0.13.0 → 0.14.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.
Files changed (73) hide show
  1. package/dist/types/ast/aggregate.d.ts +5 -4
  2. package/dist/types/ast/case.d.ts +6 -7
  3. package/dist/types/ast/column-param.d.ts +7 -7
  4. package/dist/types/ast/column-ref.d.ts +7 -6
  5. package/dist/types/ast/param.d.ts +5 -4
  6. package/dist/types/ast/query.d.ts +46 -39
  7. package/dist/types/ast/window.d.ts +15 -12
  8. package/dist/types/functions/aggregate.d.ts +89 -88
  9. package/dist/types/functions/case.d.ts +6 -8
  10. package/dist/types/functions/column.d.ts +5 -3
  11. package/dist/types/functions/datetime.d.ts +12 -11
  12. package/dist/types/functions/numeric.d.ts +48 -46
  13. package/dist/types/functions/operators.d.ts +80 -78
  14. package/dist/types/functions/order-by.d.ts +5 -4
  15. package/dist/types/functions/spatial.d.ts +14 -13
  16. package/dist/types/functions/sql-template-tag.d.ts +4 -5
  17. package/dist/types/functions/string.d.ts +22 -20
  18. package/dist/types/functions/util.d.ts +8 -0
  19. package/dist/types/functions/window.d.ts +18 -16
  20. package/dist/types/index.d.ts +5 -0
  21. package/dist/types/transforms/bin-1d.d.ts +3 -2
  22. package/dist/types/transforms/bin-2d.d.ts +6 -5
  23. package/dist/types/transforms/bin-date.d.ts +44 -0
  24. package/dist/types/transforms/bin-histogram.d.ts +51 -0
  25. package/dist/types/transforms/bin-linear-1d.d.ts +6 -4
  26. package/dist/types/transforms/bin-linear-2d.d.ts +6 -5
  27. package/dist/types/transforms/line-density.d.ts +5 -4
  28. package/dist/types/transforms/m4.d.ts +7 -4
  29. package/dist/types/transforms/util/bin-step.d.ts +61 -0
  30. package/dist/types/transforms/util/time-interval.d.ts +13 -0
  31. package/dist/types/types.d.ts +1 -0
  32. package/dist/types/util/ast.d.ts +6 -5
  33. package/dist/types/util/function.d.ts +6 -4
  34. package/dist/types/util/type-check.d.ts +6 -2
  35. package/dist/types/visit/visitors.d.ts +3 -2
  36. package/dist/types/visit/walk.d.ts +7 -4
  37. package/package.json +2 -2
  38. package/src/ast/aggregate.js +5 -2
  39. package/src/ast/case.js +6 -5
  40. package/src/ast/column-param.js +7 -5
  41. package/src/ast/column-ref.js +6 -3
  42. package/src/ast/param.js +5 -2
  43. package/src/ast/query.js +23 -19
  44. package/src/ast/window.js +10 -6
  45. package/src/functions/aggregate.js +55 -52
  46. package/src/functions/case.js +7 -7
  47. package/src/functions/column.js +6 -2
  48. package/src/functions/datetime.js +9 -6
  49. package/src/functions/numeric.js +35 -31
  50. package/src/functions/operators.js +53 -50
  51. package/src/functions/order-by.js +5 -2
  52. package/src/functions/spatial.js +10 -7
  53. package/src/functions/sql-template-tag.js +5 -5
  54. package/src/functions/string.js +16 -13
  55. package/src/functions/util.js +14 -0
  56. package/src/functions/window.js +13 -10
  57. package/src/index.js +6 -0
  58. package/src/transforms/bin-1d.js +4 -1
  59. package/src/transforms/bin-2d.js +7 -4
  60. package/src/transforms/bin-date.js +37 -0
  61. package/src/transforms/bin-histogram.js +52 -0
  62. package/src/transforms/bin-linear-1d.js +7 -3
  63. package/src/transforms/bin-linear-2d.js +12 -8
  64. package/src/transforms/line-density.js +7 -3
  65. package/src/transforms/m4.js +7 -3
  66. package/src/transforms/util/bin-step.js +79 -0
  67. package/src/transforms/util/time-interval.js +97 -0
  68. package/src/types.ts +11 -0
  69. package/src/util/ast.js +6 -3
  70. package/src/util/function.js +6 -2
  71. package/src/util/type-check.js +5 -1
  72. package/src/visit/visitors.js +6 -2
  73. package/src/visit/walk.js +8 -3
package/src/ast/query.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @import { FilterExpr, FromExpr, GroupByExpr, OrderByExpr, SelectExpr, WithExpr } from '../types.js'
3
+ * @import { SampleMethod } from './sample.js'
4
+ */
1
5
  import { DESCRIBE_QUERY, SELECT_QUERY, SET_OPERATION } from '../constants.js';
2
6
  import { asNode, asTableRef, asVerbatim } from '../util/ast.js';
3
7
  import { exprList } from '../util/function.js';
@@ -42,7 +46,7 @@ export function isDescribeQuery(value) {
42
46
  export class Query extends ExprNode {
43
47
  /**
44
48
  * Create a new WITH clause with the given CTE queries.
45
- * @param {...import('../types.js').WithExpr} expr The WITH CTE queries.
49
+ * @param {...WithExpr} expr The WITH CTE queries.
46
50
  * @returns {WithClause}
47
51
  */
48
52
  static with(...expr) {
@@ -51,7 +55,7 @@ export class Query extends ExprNode {
51
55
 
52
56
  /**
53
57
  * Create a new select query with the given SELECT expressions.
54
- * @param {...import('../types.js').SelectExpr} expr The SELECT expressions.
58
+ * @param {...SelectExpr} expr The SELECT expressions.
55
59
  * @returns {SelectQuery}
56
60
  */
57
61
  static select(...expr) {
@@ -60,7 +64,7 @@ export class Query extends ExprNode {
60
64
 
61
65
  /**
62
66
  * Create a new select query with the given FROM expressions.
63
- * @param {...import('../types.js').FromExpr} expr The FROM expressions.
67
+ * @param {...FromExpr} expr The FROM expressions.
64
68
  * @returns {SelectQuery}
65
69
  */
66
70
  static from(...expr) {
@@ -147,7 +151,7 @@ export class Query extends ExprNode {
147
151
 
148
152
  /**
149
153
  * Add WITH common table expressions (CTEs).
150
- * @param {...import('../types.js').WithExpr} expr Expressions to add.
154
+ * @param {...WithExpr} expr Expressions to add.
151
155
  * @returns {this}
152
156
  */
153
157
  with(...expr) {
@@ -168,7 +172,7 @@ export class Query extends ExprNode {
168
172
 
169
173
  /**
170
174
  * Add ORDER BY expressions.
171
- * @param {...import('../types.js').OrderByExpr} expr Expressions to add.
175
+ * @param {...OrderByExpr} expr Expressions to add.
172
176
  * @returns
173
177
  */
174
178
  orderby(...expr) {
@@ -255,7 +259,7 @@ export class SelectQuery extends Query {
255
259
 
256
260
  /**
257
261
  * Add SELECT expressions.
258
- * @param {...import('../types.js').SelectExpr} expr Expressions to add.
262
+ * @param {...SelectExpr} expr Expressions to add.
259
263
  * @returns {this}
260
264
  */
261
265
  select(...expr) {
@@ -281,7 +285,7 @@ export class SelectQuery extends Query {
281
285
 
282
286
  /**
283
287
  * Set SELECT expressions, replacing any prior expressions.
284
- * @param {...import('../types.js').SelectExpr} expr Expressions to add.
288
+ * @param {...SelectExpr} expr Expressions to add.
285
289
  * @returns {this}
286
290
  */
287
291
  setSelect(...expr) {
@@ -301,7 +305,7 @@ export class SelectQuery extends Query {
301
305
 
302
306
  /**
303
307
  * Add table FROM expressions.
304
- * @param {...import('../types.js').FromExpr} expr Expressions to add.
308
+ * @param {...FromExpr} expr Expressions to add.
305
309
  * @returns {this}
306
310
  */
307
311
  from(...expr) {
@@ -321,7 +325,7 @@ export class SelectQuery extends Query {
321
325
 
322
326
  /**
323
327
  * Set FROM expressions, replacing any prior expressions.
324
- * @param {...import('../types.js').FromExpr} expr Expressions to add.
328
+ * @param {...FromExpr} expr Expressions to add.
325
329
  * @returns {this}
326
330
  */
327
331
  setFrom(...expr) {
@@ -333,7 +337,7 @@ export class SelectQuery extends Query {
333
337
  * Set SAMPLE settings.
334
338
  * @param {number | SampleClauseNode} value Either a sample clause node
335
339
  * or the sample size as either a row count or percentage.
336
- * @param {import('./sample.js').SampleMethod} [method] The sampling method
340
+ * @param {SampleMethod} [method] The sampling method
337
341
  * to use.
338
342
  * @param {number} [seed] The random seed.
339
343
  * @returns {this}
@@ -353,7 +357,7 @@ export class SelectQuery extends Query {
353
357
 
354
358
  /**
355
359
  * Add WHERE expressions.
356
- * @param {...import('../types.js').FilterExpr} expr Expressions to add.
360
+ * @param {...FilterExpr} expr Expressions to add.
357
361
  * @returns {this}
358
362
  */
359
363
  where(...expr) {
@@ -363,7 +367,7 @@ export class SelectQuery extends Query {
363
367
 
364
368
  /**
365
369
  * Set WHERE expressions, replacing any prior expressions.
366
- * @param {...import('../types.js').FilterExpr} expr Expressions to add.
370
+ * @param {...FilterExpr} expr Expressions to add.
367
371
  * @returns {this}
368
372
  */
369
373
  setWhere(...expr) {
@@ -373,7 +377,7 @@ export class SelectQuery extends Query {
373
377
 
374
378
  /**
375
379
  * Add GROUP BY expressions.
376
- * @param {...import('../types.js').GroupByExpr} expr Expressions to add.
380
+ * @param {...GroupByExpr} expr Expressions to add.
377
381
  * @returns {this}
378
382
  */
379
383
  groupby(...expr) {
@@ -383,7 +387,7 @@ export class SelectQuery extends Query {
383
387
 
384
388
  /**
385
389
  * Set GROUP BY expressions, replacing any prior expressions.
386
- * @param {...import('../types.js').GroupByExpr} expr Expressions to add.
390
+ * @param {...GroupByExpr} expr Expressions to add.
387
391
  * @returns {this}
388
392
  */
389
393
  setGroupby(...expr) {
@@ -393,7 +397,7 @@ export class SelectQuery extends Query {
393
397
 
394
398
  /**
395
399
  * Add HAVING expressions.
396
- * @param {...import('../types.js').FilterExpr} expr Expressions to add.
400
+ * @param {...FilterExpr} expr Expressions to add.
397
401
  * @returns {this}
398
402
  */
399
403
  having(...expr) {
@@ -419,7 +423,7 @@ export class SelectQuery extends Query {
419
423
 
420
424
  /**
421
425
  * Add QUALIFY expressions.
422
- * @param {...import('../types.js').FilterExpr} expr Expressions to add.
426
+ * @param {...FilterExpr} expr Expressions to add.
423
427
  * @returns {this}
424
428
  */
425
429
  qualify(...expr) {
@@ -585,7 +589,7 @@ export class SetOperation extends Query {
585
589
  class WithClause {
586
590
  /**
587
591
  * Instantiate a new WITH clause instance.
588
- * @param {...import('../types.js').WithExpr} expr The WITH CTE queries.
592
+ * @param {...WithExpr} expr The WITH CTE queries.
589
593
  */
590
594
  constructor(...expr) {
591
595
  this._with = expr;
@@ -593,7 +597,7 @@ class WithClause {
593
597
 
594
598
  /**
595
599
  * Create a new select query with the given SELECT expressions.
596
- * @param {...import('../types.js').SelectExpr} expr The SELECT expressions.
600
+ * @param {...SelectExpr} expr The SELECT expressions.
597
601
  * @returns {SelectQuery}
598
602
  */
599
603
  select(...expr) {
@@ -602,7 +606,7 @@ class WithClause {
602
606
 
603
607
  /**
604
608
  * Create a new select query with the given FROM expressions.
605
- * @param {...import('../types.js').FromExpr} expr The FROM expressions.
609
+ * @param {...FromExpr} expr The FROM expressions.
606
610
  * @returns {SelectQuery}
607
611
  */
608
612
  from(...expr) {
package/src/ast/window.js CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @import { ExprVarArgs, WindowFunctionName } from '../types.js'
3
+ * @import { ParamLike } from '../types.js'
4
+ */
1
5
  import { WINDOW, WINDOW_CLAUSE, WINDOW_DEF, WINDOW_FRAME } from '../constants.js';
2
6
  import { exprList } from '../util/function.js';
3
7
  import { quoteIdentifier } from '../util/string.js';
@@ -8,7 +12,7 @@ import { ExprNode, isNode, SQLNode } from './node.js';
8
12
  import { ParamNode } from './param.js';
9
13
 
10
14
  /**
11
- * @typedef {[any, any] | import('../types.js').ParamLike} FrameExtent
15
+ * @typedef {[any, any] | ParamLike} FrameExtent
12
16
  */
13
17
 
14
18
  export class WindowClauseNode extends SQLNode {
@@ -69,7 +73,7 @@ export class WindowNode extends ExprNode {
69
73
 
70
74
  /**
71
75
  * Return an updated window with the given partitions.
72
- * @param {...import('../types.js').ExprVarArgs} expr The partition by criteria.
76
+ * @param {...ExprVarArgs} expr The partition by criteria.
73
77
  * @returns {WindowNode} A new window node.
74
78
  */
75
79
  partitionby(...expr) {
@@ -78,7 +82,7 @@ export class WindowNode extends ExprNode {
78
82
 
79
83
  /**
80
84
  * Return an updated window with the given ordering.
81
- * @param {...import('../types.js').ExprVarArgs} expr The order by criteria.
85
+ * @param {...ExprVarArgs} expr The order by criteria.
82
86
  * @returns {WindowNode} A new window node.
83
87
  */
84
88
  orderby(...expr) {
@@ -115,7 +119,7 @@ export class WindowNode extends ExprNode {
115
119
  export class WindowFunctionNode extends FunctionNode {
116
120
  /**
117
121
  * Instantiate a window function call node.
118
- * @param {import('../types.js').WindowFunctionName} name The function name.
122
+ * @param {WindowFunctionName} name The function name.
119
123
  * @param {ExprNode[]} [args=[]] The function arguments.
120
124
  */
121
125
  constructor(name, args) {
@@ -170,7 +174,7 @@ export class WindowDefNode extends SQLNode {
170
174
 
171
175
  /**
172
176
  * Return an updated window definition with the given partitions.
173
- * @param {...import('../types.js').ExprVarArgs} expr The partition by criteria.
177
+ * @param {...ExprVarArgs} expr The partition by criteria.
174
178
  * @returns {WindowDefNode} A new window definition node.
175
179
  */
176
180
  partitionby(...expr) {
@@ -179,7 +183,7 @@ export class WindowDefNode extends SQLNode {
179
183
 
180
184
  /**
181
185
  * Return an updated window definition with the given ordering.
182
- * @param {...import('../types.js').ExprVarArgs} expr The order by criteria.
186
+ * @param {...ExprVarArgs} expr The order by criteria.
183
187
  * @returns {WindowDefNode} A new window definition node.
184
188
  */
185
189
  orderby(...expr) {
@@ -1,10 +1,13 @@
1
- import { AggregateNode } from '../ast/aggregate.js';
1
+ /**
2
+ * @import { AggregateNode } from '../ast/aggregate.js'
3
+ * @import { ExprValue } from '../types.js'
4
+ */
2
5
  import { aggFn } from '../util/function.js';
3
6
 
4
7
  /**
5
8
  * Compute an arg_max aggregate.
6
- * @param {import('../types.js').ExprValue} y The argument to return.
7
- * @param {import('../types.js').ExprValue} x The expression to maximize.
9
+ * @param {ExprValue} y The argument to return.
10
+ * @param {ExprValue} x The expression to maximize.
8
11
  * @returns {AggregateNode} A SQL aggregate function call.
9
12
  */
10
13
  export function argmax(y, x) {
@@ -13,8 +16,8 @@ export function argmax(y, x) {
13
16
 
14
17
  /**
15
18
  * Compute an arg_min aggregate.
16
- * @param {import('../types.js').ExprValue} y The argument to return.
17
- * @param {import('../types.js').ExprValue} x The expression to minimize.
19
+ * @param {ExprValue} y The argument to return.
20
+ * @param {ExprValue} x The expression to minimize.
18
21
  * @returns {AggregateNode} A SQL aggregate function call.
19
22
  */
20
23
  export function argmin(y, x) {
@@ -23,7 +26,7 @@ export function argmin(y, x) {
23
26
 
24
27
  /**
25
28
  * Compute an array aggregation.
26
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
29
+ * @param {ExprValue} expr The expression to aggregate.
27
30
  * @returns {AggregateNode} A SQL aggregate function call.
28
31
  */
29
32
  export function arrayAgg(expr) {
@@ -32,7 +35,7 @@ export function arrayAgg(expr) {
32
35
 
33
36
  /**
34
37
  * Compute an average aggregate.
35
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
38
+ * @param {ExprValue} expr The expression to aggregate.
36
39
  * @returns {AggregateNode} A SQL aggregate function call.
37
40
  */
38
41
  export function avg(expr) {
@@ -41,8 +44,8 @@ export function avg(expr) {
41
44
 
42
45
  /**
43
46
  * Compute a correlation aggregate.
44
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
45
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
47
+ * @param {ExprValue} x The x expression to aggregate.
48
+ * @param {ExprValue} y The y expression to aggregate.
46
49
  * @returns {AggregateNode} A SQL aggregate function call.
47
50
  */
48
51
  export function corr(x, y) {
@@ -51,7 +54,7 @@ export function corr(x, y) {
51
54
 
52
55
  /**
53
56
  * Compute a count aggregate.
54
- * @param {import('../types.js').ExprValue} [expr] An optional expression
57
+ * @param {ExprValue} [expr] An optional expression
55
58
  * to count. If specified, only non-null expression values are counted.
56
59
  * If omitted, all rows within a group are counted.
57
60
  * @returns {AggregateNode} A SQL aggregate function call.
@@ -62,8 +65,8 @@ export function count(expr) {
62
65
 
63
66
  /**
64
67
  * Compute a sample covariance aggregate.
65
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
66
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
68
+ * @param {ExprValue} x The x expression to aggregate.
69
+ * @param {ExprValue} y The y expression to aggregate.
67
70
  * @returns {AggregateNode} A SQL aggregate function call.
68
71
  */
69
72
  export function covariance(x, y) {
@@ -72,8 +75,8 @@ export function covariance(x, y) {
72
75
 
73
76
  /**
74
77
  * Compute a population covariance aggregate.
75
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
76
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
78
+ * @param {ExprValue} x The x expression to aggregate.
79
+ * @param {ExprValue} y The y expression to aggregate.
77
80
  * @returns {AggregateNode} A SQL aggregate function call.
78
81
  */
79
82
  export function covarPop(x, y) {
@@ -82,7 +85,7 @@ export function covarPop(x, y) {
82
85
 
83
86
  /**
84
87
  * Compute an entropy aggregate.
85
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
88
+ * @param {ExprValue} expr The expression to aggregate.
86
89
  * @returns {AggregateNode} A SQL aggregate function call.
87
90
  */
88
91
  export function entropy(expr) {
@@ -91,7 +94,7 @@ export function entropy(expr) {
91
94
 
92
95
  /**
93
96
  * Compute a first aggregate.
94
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
97
+ * @param {ExprValue} expr The expression to aggregate.
95
98
  * @returns {AggregateNode} A SQL aggregate function call.
96
99
  */
97
100
  export function first(expr) {
@@ -100,7 +103,7 @@ export function first(expr) {
100
103
 
101
104
  /**
102
105
  * Compute a geomean aggregate.
103
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
106
+ * @param {ExprValue} expr The expression to aggregate.
104
107
  * @returns {AggregateNode} A SQL aggregate function call.
105
108
  */
106
109
  export function geomean(expr) {
@@ -109,7 +112,7 @@ export function geomean(expr) {
109
112
 
110
113
  /**
111
114
  * Compute a sample kurtosis aggregate.
112
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
115
+ * @param {ExprValue} expr The expression to aggregate.
113
116
  * @returns {AggregateNode} A SQL aggregate function call.
114
117
  */
115
118
  export function kurtosis(expr) {
@@ -118,7 +121,7 @@ export function kurtosis(expr) {
118
121
 
119
122
  /**
120
123
  * Compute a median absolute deviation (MAD) aggregate.
121
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
124
+ * @param {ExprValue} expr The expression to aggregate.
122
125
  * @returns {AggregateNode} A SQL aggregate function call.
123
126
  */
124
127
  export function mad(expr) {
@@ -127,7 +130,7 @@ export function mad(expr) {
127
130
 
128
131
  /**
129
132
  * Compute a maximum aggregate.
130
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
133
+ * @param {ExprValue} expr The expression to aggregate.
131
134
  * @returns {AggregateNode} A SQL aggregate function call.
132
135
  */
133
136
  export function max(expr) {
@@ -136,7 +139,7 @@ export function max(expr) {
136
139
 
137
140
  /**
138
141
  * Compute a median aggregate.
139
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
142
+ * @param {ExprValue} expr The expression to aggregate.
140
143
  * @returns {AggregateNode} A SQL aggregate function call.
141
144
  */
142
145
  export function median(expr) {
@@ -145,7 +148,7 @@ export function median(expr) {
145
148
 
146
149
  /**
147
150
  * Compute a minimum aggregate.
148
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
151
+ * @param {ExprValue} expr The expression to aggregate.
149
152
  * @returns {AggregateNode} A SQL aggregate function call.
150
153
  */
151
154
  export function min(expr) {
@@ -154,7 +157,7 @@ export function min(expr) {
154
157
 
155
158
  /**
156
159
  * Compute a mode aggregate.
157
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
160
+ * @param {ExprValue} expr The expression to aggregate.
158
161
  * @returns {AggregateNode} A SQL aggregate function call.
159
162
  */
160
163
  export function mode(expr) {
@@ -163,7 +166,7 @@ export function mode(expr) {
163
166
 
164
167
  /**
165
168
  * Compute a last aggregate.
166
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
169
+ * @param {ExprValue} expr The expression to aggregate.
167
170
  * @returns {AggregateNode} A SQL aggregate function call.
168
171
  */
169
172
  export function last(expr) {
@@ -172,7 +175,7 @@ export function last(expr) {
172
175
 
173
176
  /**
174
177
  * Compute a product aggregate.
175
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
178
+ * @param {ExprValue} expr The expression to aggregate.
176
179
  * @returns {AggregateNode} A SQL aggregate function call.
177
180
  */
178
181
  export function product(expr) {
@@ -181,8 +184,8 @@ export function product(expr) {
181
184
 
182
185
  /**
183
186
  * Compute a quantile aggregate.
184
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
185
- * @param {import('../types.js').ExprValue} p The quantile value.
187
+ * @param {ExprValue} expr The expression to aggregate.
188
+ * @param {ExprValue} p The quantile value.
186
189
  * @returns {AggregateNode} A SQL aggregate function call.
187
190
  */
188
191
  export function quantile(expr, p) {
@@ -191,8 +194,8 @@ export function quantile(expr, p) {
191
194
 
192
195
  /**
193
196
  * Compute a linear regression reg_avgX aggregate.
194
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
195
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
197
+ * @param {ExprValue} x The x expression to aggregate.
198
+ * @param {ExprValue} y The y expression to aggregate.
196
199
  * @returns {AggregateNode} A SQL aggregate function call.
197
200
  */
198
201
  export function regrAvgX(x, y) {
@@ -201,8 +204,8 @@ export function regrAvgX(x, y) {
201
204
 
202
205
  /**
203
206
  * Compute a linear regression reg_avgY aggregate.
204
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
205
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
207
+ * @param {ExprValue} x The x expression to aggregate.
208
+ * @param {ExprValue} y The y expression to aggregate.
206
209
  * @returns {AggregateNode} A SQL aggregate function call.
207
210
  */
208
211
  export function regrAvgY(x, y) {
@@ -212,8 +215,8 @@ export function regrAvgY(x, y) {
212
215
  /**
213
216
  * Compute a linear regression count aggregate.
214
217
  * This returns the count of rows where both x and y are non-null.
215
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
216
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
218
+ * @param {ExprValue} x The x expression to aggregate.
219
+ * @param {ExprValue} y The y expression to aggregate.
217
220
  * @returns {AggregateNode} A SQL aggregate function call.
218
221
  */
219
222
  export function regrCount(x, y) {
@@ -222,8 +225,8 @@ export function regrCount(x, y) {
222
225
 
223
226
  /**
224
227
  * Compute a linear regression intercept aggregate.
225
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
226
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
228
+ * @param {ExprValue} x The x expression to aggregate.
229
+ * @param {ExprValue} y The y expression to aggregate.
227
230
  * @returns {AggregateNode} A SQL aggregate function call.
228
231
  */
229
232
  export function regrIntercept(x, y) {
@@ -232,8 +235,8 @@ export function regrIntercept(x, y) {
232
235
 
233
236
  /**
234
237
  * Compute a linear regression R^2 aggregate.
235
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
236
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
238
+ * @param {ExprValue} x The x expression to aggregate.
239
+ * @param {ExprValue} y The y expression to aggregate.
237
240
  * @returns {AggregateNode} A SQL aggregate function call.
238
241
  */
239
242
  export function regrR2(x, y) {
@@ -242,8 +245,8 @@ export function regrR2(x, y) {
242
245
 
243
246
  /**
244
247
  * Compute a linear regression regr_sxx aggregate.
245
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
246
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
248
+ * @param {ExprValue} x The x expression to aggregate.
249
+ * @param {ExprValue} y The y expression to aggregate.
247
250
  * @returns {AggregateNode} A SQL aggregate function call.
248
251
  */
249
252
  export function regrSXX(x, y) {
@@ -252,8 +255,8 @@ export function regrSXX(x, y) {
252
255
 
253
256
  /**
254
257
  * Compute a linear regression regr_sxy aggregate.
255
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
256
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
258
+ * @param {ExprValue} x The x expression to aggregate.
259
+ * @param {ExprValue} y The y expression to aggregate.
257
260
  * @returns {AggregateNode} A SQL aggregate function call.
258
261
  */
259
262
  export function regrSXY(x, y) {
@@ -262,8 +265,8 @@ export function regrSXY(x, y) {
262
265
 
263
266
  /**
264
267
  * Compute a linear regression regr_syy aggregate.
265
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
266
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
268
+ * @param {ExprValue} x The x expression to aggregate.
269
+ * @param {ExprValue} y The y expression to aggregate.
267
270
  * @returns {AggregateNode} A SQL aggregate function call.
268
271
  */
269
272
  export function regrSYY(x, y) {
@@ -272,8 +275,8 @@ export function regrSYY(x, y) {
272
275
 
273
276
  /**
274
277
  * Compute a linear regression slope aggregate.
275
- * @param {import('../types.js').ExprValue} x The x expression to aggregate.
276
- * @param {import('../types.js').ExprValue} y The y expression to aggregate.
278
+ * @param {ExprValue} x The x expression to aggregate.
279
+ * @param {ExprValue} y The y expression to aggregate.
277
280
  * @returns {AggregateNode} A SQL aggregate function call.
278
281
  */
279
282
  export function regrSlope(x, y) {
@@ -282,7 +285,7 @@ export function regrSlope(x, y) {
282
285
 
283
286
  /**
284
287
  * Compute a skewness aggregate.
285
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
288
+ * @param {ExprValue} expr The expression to aggregate.
286
289
  * @returns {AggregateNode} A SQL aggregate function call.
287
290
  */
288
291
  export function skewness(expr) {
@@ -291,7 +294,7 @@ export function skewness(expr) {
291
294
 
292
295
  /**
293
296
  * Compute a sample standard deviation aggregate.
294
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
297
+ * @param {ExprValue} expr The expression to aggregate.
295
298
  * @returns {AggregateNode} A SQL aggregate function call.
296
299
  */
297
300
  export function stddev(expr) {
@@ -300,7 +303,7 @@ export function stddev(expr) {
300
303
 
301
304
  /**
302
305
  * Compute a population standard deviation aggregate.
303
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
306
+ * @param {ExprValue} expr The expression to aggregate.
304
307
  * @returns {AggregateNode} A SQL aggregate function call.
305
308
  */
306
309
  export function stddevPop(expr) {
@@ -309,7 +312,7 @@ export function stddevPop(expr) {
309
312
 
310
313
  /**
311
314
  * Compute a string aggregation.
312
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
315
+ * @param {ExprValue} expr The expression to aggregate.
313
316
  * @returns {AggregateNode} A SQL aggregate function call.
314
317
  */
315
318
  export function stringAgg(expr) {
@@ -318,7 +321,7 @@ export function stringAgg(expr) {
318
321
 
319
322
  /**
320
323
  * Compute a sum aggregate.
321
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
324
+ * @param {ExprValue} expr The expression to aggregate.
322
325
  * @returns {AggregateNode} A SQL aggregate function call.
323
326
  */
324
327
  export function sum(expr) {
@@ -327,7 +330,7 @@ export function sum(expr) {
327
330
 
328
331
  /**
329
332
  * Compute a sample variance aggregate.
330
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
333
+ * @param {ExprValue} expr The expression to aggregate.
331
334
  * @returns {AggregateNode} A SQL aggregate function call.
332
335
  */
333
336
  export function variance(expr) {
@@ -336,7 +339,7 @@ export function variance(expr) {
336
339
 
337
340
  /**
338
341
  * Compute a population variance aggregate.
339
- * @param {import('../types.js').ExprValue} expr The expression to aggregate.
342
+ * @param {ExprValue} expr The expression to aggregate.
340
343
  * @returns {AggregateNode} A SQL aggregate function call.
341
344
  */
342
345
  export function varPop(expr) {
@@ -1,17 +1,17 @@
1
+ /**
2
+ * @import { ExprValue } from '../types.js'
3
+ */
1
4
  import { CaseNode, WhenNode } from '../ast/case.js';
2
5
  import { asNode } from '../util/ast.js';
3
6
 
4
7
  /**
5
8
  * Create a new conditional CASE statement. If three arguments are provided,
6
- * acts like a ternary conditional (if, then else). If no arguments are
9
+ * acts like a ternary conditional (if, then, else). If no arguments are
7
10
  * provided, the chained `when` and `else` methods can be used to to complete
8
11
  * a conditional statement with WHEN/THEN and ELSE expressions.
9
- * @param {import('../types.js').ExprValue} [when]
10
- * A conditional WHEN expression.
11
- * @param {import('../types.js').ExprValue} [then]
12
- * A THEN value expression.
13
- * @param {import('../types.js').ExprValue} [other]
14
- * An ELSE expression.
12
+ * @param {ExprValue} [when] A conditional WHEN expression.
13
+ * @param {ExprValue} [then] A THEN value expression.
14
+ * @param {ExprValue} [other] An ELSE expression.
15
15
  * @returns {CaseNode}
16
16
  */
17
17
  export function cond(when, then, other) {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @import { ColumnRefNode } from '../ast/column-ref.js'
3
+ * @import { ParamLike } from '../types.js'
4
+ */
1
5
  import { ColumnParamNode } from '../ast/column-param.js';
2
6
  import { ColumnNameRefNode } from '../ast/column-ref.js';
3
7
  import { ParamNode } from '../ast/param.js';
@@ -7,10 +11,10 @@ import { isParamLike } from '../util/type-check.js';
7
11
 
8
12
  /**
9
13
  * Create a column reference.
10
- * @param {string | import('../types.js').ParamLike} name The column name,
14
+ * @param {string | ParamLike} name The column name,
11
15
  * as a string or as a dynamic parameter.
12
16
  * @param {string | string[] | TableRefNode} [table] The table reference.
13
- * @returns {import('../ast/column-ref.js').ColumnRefNode}
17
+ * @returns {ColumnRefNode}
14
18
  */
15
19
  export function column(name, table) {
16
20
  const tref = asTableRef(table);
@@ -1,4 +1,7 @@
1
- import { FunctionNode } from '../ast/function.js';
1
+ /**
2
+ * @import { FunctionNode } from '../ast/function.js'
3
+ * @import { ExprValue } from '../types.js'
4
+ */
2
5
  import { IntervalNode } from '../ast/interval.js';
3
6
  import { asNode } from '../util/ast.js';
4
7
  import { fn } from '../util/function.js';
@@ -15,7 +18,7 @@ export function interval(unit, steps) {
15
18
 
16
19
  /**
17
20
  * Given a date/time value, return the milliseconds since the UNIX epoch.
18
- * @param {import('../types.js').ExprValue} expr The date/time expression.
21
+ * @param {ExprValue} expr The date/time expression.
19
22
  * @returns {FunctionNode}
20
23
  */
21
24
  export function epoch_ms(expr) {
@@ -24,7 +27,7 @@ export function epoch_ms(expr) {
24
27
 
25
28
  /**
26
29
  * Perform data binning according to the provided interval unit and steps.
27
- * @param {import('../types.js').ExprValue} expr The date/time expression to bin.
30
+ * @param {ExprValue} expr The date/time expression to bin.
28
31
  * @param {string} unit The datetime interval unit to bin by.
29
32
  * @param {number} [steps=1] The number of interval steps.
30
33
  * @returns {FunctionNode}
@@ -36,7 +39,7 @@ export function dateBin(expr, unit, steps = 1) {
36
39
  /**
37
40
  * Map date/times to a month value, all within the same year for comparison.
38
41
  * The resulting value is still date-typed.
39
- * @param {import('../types.js').ExprValue} expr The date/time expression.
42
+ * @param {ExprValue} expr The date/time expression.
40
43
  * @returns {FunctionNode}
41
44
  */
42
45
  export function dateMonth(expr) {
@@ -46,7 +49,7 @@ export function dateMonth(expr) {
46
49
  /**
47
50
  * Map date/times to a month and day value, all within the same year for
48
51
  * comparison. The resulting value is still date-typed.
49
- * @param {import('../types.js').ExprValue} expr The date/time expression.
52
+ * @param {ExprValue} expr The date/time expression.
50
53
  * @returns {FunctionNode}
51
54
  */
52
55
  export function dateMonthDay(expr) {
@@ -57,7 +60,7 @@ export function dateMonthDay(expr) {
57
60
  /**
58
61
  * Map date/times to a day of the month value, all within the same year and month
59
62
  * for comparison. The resulting value is still date-typed.
60
- * @param {import('../types.js').ExprValue} expr The date/time expression.
63
+ * @param {ExprValue} expr The date/time expression.
61
64
  * @returns {FunctionNode}
62
65
  */
63
66
  export function dateDay(expr) {