@uwdata/mosaic-sql 0.16.2 → 0.17.0
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/package.json +5 -9
- package/src/ast/aggregate.js +50 -8
- package/src/ast/collate.js +33 -0
- package/src/ast/from.js +13 -4
- package/src/ast/node.js +13 -0
- package/src/ast/query.js +54 -22
- package/src/ast/sample.js +3 -3
- package/src/ast/subquery.js +23 -0
- package/src/ast/verbatim.js +8 -1
- package/src/ast/window-frame.js +107 -0
- package/src/ast/window.js +65 -99
- package/src/constants.js +5 -6
- package/src/functions/collate.js +16 -0
- package/src/functions/datetime.js +1 -11
- package/src/functions/interval.js +83 -0
- package/src/functions/literal.js +3 -2
- package/src/functions/window-frame.js +61 -0
- package/src/index.js +12 -4
- package/src/load/load.js +1 -1
- package/src/transforms/bin-date.js +2 -1
- package/src/transforms/filter-query.js +44 -0
- package/src/types.ts +9 -0
- package/src/visit/clone.js +53 -0
- package/src/visit/recurse.js +17 -5
- package/src/visit/rewrite.js +3 -11
- package/src/visit/walk.js +0 -1
- package/tsconfig.json +3 -7
- package/LICENSE +0 -47
- package/dist/types/ast/aggregate.d.ts +0 -71
- package/dist/types/ast/between-op.d.ts +0 -46
- package/dist/types/ast/binary-op.d.ts +0 -28
- package/dist/types/ast/case.d.ts +0 -67
- package/dist/types/ast/cast.d.ts +0 -21
- package/dist/types/ast/column-param.d.ts +0 -23
- package/dist/types/ast/column-ref.d.ts +0 -40
- package/dist/types/ast/fragment.d.ts +0 -14
- package/dist/types/ast/from.d.ts +0 -21
- package/dist/types/ast/function.d.ts +0 -21
- package/dist/types/ast/in-op.d.ts +0 -21
- package/dist/types/ast/interval.d.ts +0 -21
- package/dist/types/ast/literal.d.ts +0 -15
- package/dist/types/ast/logical-op.d.ts +0 -46
- package/dist/types/ast/node.d.ts +0 -24
- package/dist/types/ast/order-by.d.ts +0 -29
- package/dist/types/ast/param.d.ts +0 -20
- package/dist/types/ast/query.d.ts +0 -320
- package/dist/types/ast/sample.d.ts +0 -42
- package/dist/types/ast/select.d.ts +0 -22
- package/dist/types/ast/table-ref.d.ts +0 -25
- package/dist/types/ast/unary-op.d.ts +0 -39
- package/dist/types/ast/verbatim.d.ts +0 -9
- package/dist/types/ast/window.d.ts +0 -180
- package/dist/types/ast/with.d.ts +0 -32
- package/dist/types/constants.d.ts +0 -38
- package/dist/types/functions/aggregate.d.ts +0 -236
- package/dist/types/functions/case.d.ts +0 -13
- package/dist/types/functions/cast.d.ts +0 -26
- package/dist/types/functions/column.d.ts +0 -11
- package/dist/types/functions/cte.d.ts +0 -13
- package/dist/types/functions/datetime.d.ts +0 -45
- package/dist/types/functions/literal.d.ts +0 -16
- package/dist/types/functions/numeric.d.ts +0 -95
- package/dist/types/functions/operators.d.ts +0 -200
- package/dist/types/functions/order-by.d.ts +0 -18
- package/dist/types/functions/spatial.d.ts +0 -38
- package/dist/types/functions/sql-template-tag.d.ts +0 -15
- package/dist/types/functions/string.d.ts +0 -57
- package/dist/types/functions/table-ref.d.ts +0 -9
- package/dist/types/functions/util.d.ts +0 -8
- package/dist/types/functions/window.d.ts +0 -89
- package/dist/types/index-types.d.ts +0 -2
- package/dist/types/index.d.ts +0 -59
- package/dist/types/load/create.d.ts +0 -8
- package/dist/types/load/extension.d.ts +0 -1
- package/dist/types/load/load.d.ts +0 -12
- package/dist/types/load/sql-from.d.ts +0 -11
- package/dist/types/transforms/bin-1d.d.ts +0 -15
- package/dist/types/transforms/bin-2d.d.ts +0 -19
- package/dist/types/transforms/bin-date.d.ts +0 -44
- package/dist/types/transforms/bin-histogram.d.ts +0 -51
- package/dist/types/transforms/bin-linear-1d.d.ts +0 -12
- package/dist/types/transforms/bin-linear-2d.d.ts +0 -19
- package/dist/types/transforms/line-density.d.ts +0 -24
- package/dist/types/transforms/m4.d.ts +0 -21
- package/dist/types/transforms/scales.d.ts +0 -1
- package/dist/types/transforms/util/bin-step.d.ts +0 -61
- package/dist/types/transforms/util/time-interval.d.ts +0 -13
- package/dist/types/types.d.ts +0 -62
- package/dist/types/util/ast.d.ts +0 -61
- package/dist/types/util/function.d.ts +0 -56
- package/dist/types/util/string.d.ts +0 -3
- package/dist/types/util/type-check.d.ts +0 -22
- package/dist/types/visit/recurse.d.ts +0 -28
- package/dist/types/visit/rewrite.d.ts +0 -10
- package/dist/types/visit/visitors.d.ts +0 -34
- package/dist/types/visit/walk.d.ts +0 -10
- package/jsconfig.json +0 -11
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} BinHistogramOptions
|
|
3
|
-
* @property {number} [step] An exact binning step to use.
|
|
4
|
-
* @property {number} [steps] The desired number of binning steps.
|
|
5
|
-
* This value is a hint, it does not guarantee an exact number of steps.
|
|
6
|
-
* @property {number} [minstep] A minimum binning step value. No generated
|
|
7
|
-
* step can be less than this value.
|
|
8
|
-
* @property {boolean} [nice] A boolean flag (default true) indicating if bin
|
|
9
|
-
* extents should be snapped to "nice" numbers such as multiples of 5 or 10.
|
|
10
|
-
* @property {number} [offset] The number of bin steps (default 0) by
|
|
11
|
-
* which to offset the result.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Return a SQL expression for histogram bins.
|
|
15
|
-
* @param {ExprValue} field The column or expression to bin.
|
|
16
|
-
* @param {[number, number]} extent The min/max extent over which to bin.
|
|
17
|
-
* @param {BinHistogramOptions} [options] Binning options.
|
|
18
|
-
* @param {ReturnType<typeof scaleTransform>} [transform] Scale transforms to
|
|
19
|
-
* apply to create (potentially non-linear) binning intervals.
|
|
20
|
-
* @returns {ExprNode} The resulting SQL expression
|
|
21
|
-
*/
|
|
22
|
-
export function binHistogram(field: ExprValue, extent: [number, number], options?: BinHistogramOptions, transform?: ReturnType<typeof scaleTransform>): ExprNode;
|
|
23
|
-
export type BinHistogramOptions = {
|
|
24
|
-
/**
|
|
25
|
-
* An exact binning step to use.
|
|
26
|
-
*/
|
|
27
|
-
step?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The desired number of binning steps.
|
|
30
|
-
* This value is a hint, it does not guarantee an exact number of steps.
|
|
31
|
-
*/
|
|
32
|
-
steps?: number;
|
|
33
|
-
/**
|
|
34
|
-
* A minimum binning step value. No generated
|
|
35
|
-
* step can be less than this value.
|
|
36
|
-
*/
|
|
37
|
-
minstep?: number;
|
|
38
|
-
/**
|
|
39
|
-
* A boolean flag (default true) indicating if bin
|
|
40
|
-
* extents should be snapped to "nice" numbers such as multiples of 5 or 10.
|
|
41
|
-
*/
|
|
42
|
-
nice?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* The number of bin steps (default 0) by
|
|
45
|
-
* which to offset the result.
|
|
46
|
-
*/
|
|
47
|
-
offset?: number;
|
|
48
|
-
};
|
|
49
|
-
import type { ExprValue } from '../types.js';
|
|
50
|
-
import { scaleTransform } from './scales.js';
|
|
51
|
-
import type { ExprNode } from '../ast/node.js';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Perform linear binning in one dimension.
|
|
3
|
-
* @param {SelectQuery} query The base query to bin.
|
|
4
|
-
* @param {ExprValue} x The expression to bin.
|
|
5
|
-
* @param {ExprValue} [weight] The expression to weight by.
|
|
6
|
-
* @param {string[]} [groupby] Group by expressions.
|
|
7
|
-
* @returns {Query}
|
|
8
|
-
*/
|
|
9
|
-
export function binLinear1d(query: SelectQuery, x: ExprValue, weight?: ExprValue, groupby?: string[]): Query;
|
|
10
|
-
import type { SelectQuery } from '../ast/query.js';
|
|
11
|
-
import type { ExprValue } from '../types.js';
|
|
12
|
-
import { Query } from '../ast/query.js';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute densities over a 2D domain using linear binning. The weight of
|
|
3
|
-
* each data point is linearly distributed over adjacent bins, providing
|
|
4
|
-
* a better base for subsequent kernel density estimation. This method takes
|
|
5
|
-
* expressions for the (non-truncated) x and y bin values; these expressions
|
|
6
|
-
* should be in units of grid indices, but can contain fractional components.
|
|
7
|
-
* @param {SelectQuery} q The input query. The FROM and WHERE clauses should
|
|
8
|
-
* be added to the query separately, before this method is invoked.
|
|
9
|
-
* @param {ExprValue} xp The x grid bin expression
|
|
10
|
-
* @param {ExprValue} yp The y grid bin expression
|
|
11
|
-
* @param {ExprValue | undefined} weight Point weights.
|
|
12
|
-
* @param {number} xn The number of x grid bins.
|
|
13
|
-
* @param {string[]} [groupby] Group by expressions.
|
|
14
|
-
* @returns {SelectQuery} A linear binning query for bin `index` and
|
|
15
|
-
* aggregate `density` columns, in addition to any group by expressions.
|
|
16
|
-
*/
|
|
17
|
-
export function binLinear2d(q: SelectQuery, xp: ExprValue, yp: ExprValue, weight: ExprValue | undefined, xn: number, groupby?: string[]): SelectQuery;
|
|
18
|
-
import type { SelectQuery } from '../ast/query.js';
|
|
19
|
-
import type { ExprValue } from '../types.js';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute line segment densities over a gridded 2D domain. The returned
|
|
3
|
-
* query uses multiple subqueries (CTEs) to identify line segment end point
|
|
4
|
-
* pairs, perform line rasterization in-database, normalize arc lengths,
|
|
5
|
-
* and then sum results for all line series to produce a density map.
|
|
6
|
-
* Based on Moritz and Fisher's work: https://arxiv.org/abs/1808.06019
|
|
7
|
-
* @param {SelectQuery} q The base query over the data.
|
|
8
|
-
* @param {ExprValue} x Bin expression for x dimension.
|
|
9
|
-
* Provides gridded x coordinates, potentially with a fractional component.
|
|
10
|
-
* @param {ExprValue} y Bin expression for x dimension.
|
|
11
|
-
* Provides gridded y coordinates, potentially with a fractional component.
|
|
12
|
-
* @param {string[]} z Group by columns that segment data into individual line
|
|
13
|
-
* series. An empty array indicates there is only a single line series.
|
|
14
|
-
* @param {number} xn The number of grid bins for the x dimension.
|
|
15
|
-
* @param {number} yn The number of grid bins for the y dimension.
|
|
16
|
-
* @param {string[]} [groupby] Additional group by expressions. Separate
|
|
17
|
-
* line density maps are created for each of these groups.
|
|
18
|
-
* @param {boolean} [normalize=true] Flag toggling approximate arc-length
|
|
19
|
-
* normalization to improve accuracy and reduce artifacts (default `true`).
|
|
20
|
-
* @returns {SelectQuery}
|
|
21
|
-
*/
|
|
22
|
-
export function lineDensity(q: SelectQuery, x: ExprValue, y: ExprValue, z: string[], xn: number, yn: number, groupby?: string[], normalize?: boolean): SelectQuery;
|
|
23
|
-
import type { SelectQuery } from '../ast/query.js';
|
|
24
|
-
import type { ExprValue } from '../types.js';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* M4 is an optimization for value-preserving time-series aggregation
|
|
3
|
-
* (https://www.vldb.org/pvldb/vol7/p797-jugel.pdf). This implementation uses
|
|
4
|
-
* an efficient version with a single scan and the aggregate functions
|
|
5
|
-
* argmin and argmax, following https://arxiv.org/pdf/2306.03714.pdf.
|
|
6
|
-
* This method can bin along either the *x* or *y* dimension, as determined
|
|
7
|
-
* by the caller-provided *bin* expression.
|
|
8
|
-
* @param {FromExpr} input The base query or table.
|
|
9
|
-
* @param {ExprValue} bin An expression that maps
|
|
10
|
-
* time-series values to fractional pixel positions.
|
|
11
|
-
* @param {string} x The x dimension column name.
|
|
12
|
-
* @param {string} y The y dimension column name.
|
|
13
|
-
* @param {ExprNode[]} [groups] Additional
|
|
14
|
-
* groupby columns, for example for faceted charts.
|
|
15
|
-
* @returns {Query} The resulting M4 query.
|
|
16
|
-
*/
|
|
17
|
-
export function m4(input: FromExpr, bin: ExprValue, x: string, y: string, groups?: ExprNode[]): Query;
|
|
18
|
-
import type { FromExpr } from '../types.js';
|
|
19
|
-
import type { ExprValue } from '../types.js';
|
|
20
|
-
import type { ExprNode } from '../ast/node.js';
|
|
21
|
-
import { Query } from '../ast/query.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function scaleTransform(options: any): any;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} BinOptions
|
|
3
|
-
* @property {number} [step] An exact binning step to use.
|
|
4
|
-
* @property {number} [steps] The desired number of binning steps.
|
|
5
|
-
* This value is a hint, it does not guarantee an exact number of steps.
|
|
6
|
-
* @property {number} [minstep] A minimum binning step value. No generated
|
|
7
|
-
* step can be less than this value.
|
|
8
|
-
* @property {boolean} [nice] A boolean flag (default true) indicating if bin
|
|
9
|
-
* extents should be snapped to "nice" numbers such as multiples of 5 or 10.
|
|
10
|
-
* @property {number} [base] A number indicating the the logarithm base to
|
|
11
|
-
* use for automatic step size determination. Defaults to base 10.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Generate a numeric binning scheme suitable for a histogram.
|
|
15
|
-
* @param {number} min The minimum value of the extent to bin.
|
|
16
|
-
* @param {number} max The maximum value of the extent to bin.
|
|
17
|
-
* @param {BinOptions} options Binning scheme options.
|
|
18
|
-
*/
|
|
19
|
-
export function binSpec(min: number, max: number, options: BinOptions): {
|
|
20
|
-
min: number;
|
|
21
|
-
max: number;
|
|
22
|
-
steps: number;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Determine a bin step interval.
|
|
26
|
-
* @param {number} span The span from maximum to minimum value.
|
|
27
|
-
* @param {number} steps The approximate number of desired bins.
|
|
28
|
-
* @param {number} [minstep=0] The minimum acceptable bin step size.
|
|
29
|
-
* @param {number} [logb=Math.LN10] The log base for determining
|
|
30
|
-
* orders of magnitude for step sizes. Defaults to log base 10
|
|
31
|
-
* (`Math.LN10`). For example to use log base 2, provide the
|
|
32
|
-
* argument `Math.LN2` instead.
|
|
33
|
-
* @returns {number} The bin step interval (bin size).
|
|
34
|
-
*/
|
|
35
|
-
export function binStep(span: number, steps: number, minstep?: number, logb?: number): number;
|
|
36
|
-
export type BinOptions = {
|
|
37
|
-
/**
|
|
38
|
-
* An exact binning step to use.
|
|
39
|
-
*/
|
|
40
|
-
step?: number;
|
|
41
|
-
/**
|
|
42
|
-
* The desired number of binning steps.
|
|
43
|
-
* This value is a hint, it does not guarantee an exact number of steps.
|
|
44
|
-
*/
|
|
45
|
-
steps?: number;
|
|
46
|
-
/**
|
|
47
|
-
* A minimum binning step value. No generated
|
|
48
|
-
* step can be less than this value.
|
|
49
|
-
*/
|
|
50
|
-
minstep?: number;
|
|
51
|
-
/**
|
|
52
|
-
* A boolean flag (default true) indicating if bin
|
|
53
|
-
* extents should be snapped to "nice" numbers such as multiples of 5 or 10.
|
|
54
|
-
*/
|
|
55
|
-
nice?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* A number indicating the the logarithm base to
|
|
58
|
-
* use for automatic step size determination. Defaults to base 10.
|
|
59
|
-
*/
|
|
60
|
-
base?: number;
|
|
61
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determine a time interval for binning based on provided min
|
|
3
|
-
* and max timestamps and approximate step count.
|
|
4
|
-
* @param {Date|number} min The minimum timestamp value.
|
|
5
|
-
* @param {Date|number} max The maximum timestamp value.
|
|
6
|
-
* @param {number} steps The approximate number of bins desired.
|
|
7
|
-
* @returns {{ unit: TimeUnit, step: number }}
|
|
8
|
-
*/
|
|
9
|
-
export function timeInterval(min: Date | number, max: Date | number, steps: number): {
|
|
10
|
-
unit: TimeUnit;
|
|
11
|
-
step: number;
|
|
12
|
-
};
|
|
13
|
-
import type { TimeUnit } from '../../types.js';
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { ColumnRefNode } from './ast/column-ref.js';
|
|
2
|
-
import { ExprNode, SQLNode } from './ast/node.js';
|
|
3
|
-
import { TableRefNode } from './ast/table-ref.js';
|
|
4
|
-
import { Query } from './ast/query.js';
|
|
5
|
-
import { WithClauseNode } from './ast/with.js';
|
|
6
|
-
/**
|
|
7
|
-
* Interface representing a dynamic parameter value.
|
|
8
|
-
*/
|
|
9
|
-
export interface ParamLike {
|
|
10
|
-
/** The current parameter value. */
|
|
11
|
-
value: any;
|
|
12
|
-
/** Add an event listener callback. */
|
|
13
|
-
addEventListener(type: string, callback: EventCallback): void;
|
|
14
|
-
/** Remove an event listener callback. */
|
|
15
|
-
removeEventListener(type: string, callback: EventCallback): void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Expression value input to SQL builder method.
|
|
19
|
-
*/
|
|
20
|
-
export type ExprValue = ExprNode | ParamLike | string | number | boolean | Date;
|
|
21
|
-
/**
|
|
22
|
-
* Expression values that may be nested in arrays.
|
|
23
|
-
*/
|
|
24
|
-
export type ExprVarArgs = MaybeArray<ExprValue>;
|
|
25
|
-
/**
|
|
26
|
-
* String-typed expression value.
|
|
27
|
-
*/
|
|
28
|
-
export type StringValue = ExprNode | ParamLike | string;
|
|
29
|
-
/**
|
|
30
|
-
* Number-typed expression value.
|
|
31
|
-
*/
|
|
32
|
-
export type NumberValue = ExprNode | ParamLike | number;
|
|
33
|
-
/**
|
|
34
|
-
* Event listener callback function.
|
|
35
|
-
*/
|
|
36
|
-
export type EventCallback = <T>(value: any) => Promise<T> | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* SQL AST traversal visitor callback result.
|
|
39
|
-
* A falsy value (including `undefined`, `null`, `false`, and `0`) indicates
|
|
40
|
-
* that traversal should continue.
|
|
41
|
-
* A negative number values indicates that traversal should stop immediately.
|
|
42
|
-
* Any other truthy value indicates that traversal should not recurse on the
|
|
43
|
-
* current node, but should otherwise continue.
|
|
44
|
-
*/
|
|
45
|
-
export type VisitorResult = boolean | number | null | undefined | void;
|
|
46
|
-
/**
|
|
47
|
-
* SQL AST traversal callback function.
|
|
48
|
-
*/
|
|
49
|
-
export type VisitorCallback = (node: SQLNode) => VisitorResult;
|
|
50
|
-
/** Valid window function names. */
|
|
51
|
-
export type WindowFunctionName = 'cume_dist' | 'dense_rank' | 'first_value' | 'lag' | 'last_value' | 'lead' | 'nth_value' | 'ntile' | 'percent_rank' | 'rank_dense' | 'rank' | 'row_number';
|
|
52
|
-
export type MaybeArray<T> = T | T[];
|
|
53
|
-
export type SelectEntry = string | ColumnRefNode | [string, ExprNode] | Record<string, ExprValue>;
|
|
54
|
-
export type SelectExpr = MaybeArray<SelectEntry>;
|
|
55
|
-
export type WithEntry = WithClauseNode | Record<string, Query>;
|
|
56
|
-
export type WithExpr = MaybeArray<WithEntry>;
|
|
57
|
-
export type FromEntry = string | TableRefNode | SQLNode | [string, SQLNode] | Record<string, string | SQLNode>;
|
|
58
|
-
export type FromExpr = MaybeArray<FromEntry>;
|
|
59
|
-
export type FilterExpr = MaybeArray<string | ExprNode>;
|
|
60
|
-
export type GroupByExpr = MaybeArray<string | ExprNode>;
|
|
61
|
-
export type OrderByExpr = MaybeArray<string | ExprNode>;
|
|
62
|
-
export type TimeUnit = 'year' | 'quarter' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond' | 'microsecond';
|
package/dist/types/util/ast.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interpret a value as a SQL AST node. String values are assumed to be
|
|
3
|
-
* column references. All other primitive values are interpreted as
|
|
4
|
-
* SQL literals. Dynamic parameters are interpreted as param AST nodes,
|
|
5
|
-
* while existing AST nodes are left as-is.
|
|
6
|
-
* @param {*} value The value to interpret as a SQL AST node.
|
|
7
|
-
* @returns {ExprNode}
|
|
8
|
-
*/
|
|
9
|
-
export function asNode(value: any): ExprNode;
|
|
10
|
-
/**
|
|
11
|
-
* Interpret a value as a verbatim SQL AST node. String values will be
|
|
12
|
-
* passed through to queries as verbatim text. All other primitive values
|
|
13
|
-
* are interpreted as SQL literals. Dynamic parameters are interpreted
|
|
14
|
-
* as param AST nodes, while existing AST nodes are left as-is.
|
|
15
|
-
* @param {*} value The value to interpret as a verbatim AST node.
|
|
16
|
-
* @returns {ExprNode}
|
|
17
|
-
*/
|
|
18
|
-
export function asVerbatim(value: any): ExprNode;
|
|
19
|
-
/**
|
|
20
|
-
* Interpret a value as a literal AST node. All other primitive values
|
|
21
|
-
* are interpreted as SQL literals. Dynamic parameters are interpreted
|
|
22
|
-
* as param AST nodes, while existing AST nodes are left as-is.
|
|
23
|
-
* @param {*} value The value to interpret as a literal AST node.
|
|
24
|
-
* @returns {ExprNode}
|
|
25
|
-
*/
|
|
26
|
-
export function asLiteral(value: any): ExprNode;
|
|
27
|
-
/**
|
|
28
|
-
* Interpret a value as a table reference AST node. String values are parsed
|
|
29
|
-
* assuming dot ('.') delimiters (as in `schema.table`). Array values are
|
|
30
|
-
* interpreted as pre-parsed name paths (as in `['schema', 'table']`). Any
|
|
31
|
-
* other values are left as-is.
|
|
32
|
-
* @param {string | string[] | TableRefNode} value The value to interpret as a
|
|
33
|
-
* table reference AST node.
|
|
34
|
-
* @returns {TableRefNode}
|
|
35
|
-
*/
|
|
36
|
-
export function asTableRef(value: string | string[] | TableRefNode): TableRefNode;
|
|
37
|
-
/**
|
|
38
|
-
* Parse a string as a column reference, potentially with
|
|
39
|
-
* dot ('.') delimited table, schema, and database references.
|
|
40
|
-
* @param {string} ref The column reference string.
|
|
41
|
-
* @returns {ColumnRefNode}
|
|
42
|
-
*/
|
|
43
|
-
export function parseColumnRef(ref: string): ColumnRefNode;
|
|
44
|
-
/**
|
|
45
|
-
* Parse a string as a table reference, potentially with
|
|
46
|
-
* dot ('.') delimited schema and database references.
|
|
47
|
-
* @param {string} ref The table reference string.
|
|
48
|
-
* @returns {TableRefNode}
|
|
49
|
-
*/
|
|
50
|
-
export function parseTableRef(ref: string): TableRefNode;
|
|
51
|
-
/**
|
|
52
|
-
* Create a new window definition node. The return value is an empty
|
|
53
|
-
* window definition. Use chained calls such as `partitionby` and `orderby`
|
|
54
|
-
* to specify the window settings.
|
|
55
|
-
* @returns {WindowDefNode}
|
|
56
|
-
*/
|
|
57
|
-
export function over(): WindowDefNode;
|
|
58
|
-
import { ExprNode } from '../ast/node.js';
|
|
59
|
-
import type { TableRefNode } from '../ast/table-ref.js';
|
|
60
|
-
import type { ColumnRefNode } from '../ast/column-ref.js';
|
|
61
|
-
import { WindowDefNode } from '../ast/window.js';
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test if an AST node is a specific function call.
|
|
3
|
-
* @param {SQLNode} node The SQL AST node to test.
|
|
4
|
-
* @param {string} name The function name.
|
|
5
|
-
* @returns {node is FunctionNode}
|
|
6
|
-
*/
|
|
7
|
-
export function isFunctionCall(node: SQLNode, name: string): node is FunctionNode;
|
|
8
|
-
/**
|
|
9
|
-
* Create a new function call AST node.
|
|
10
|
-
* @param {string} name The function name.
|
|
11
|
-
* @param {...any} args The function arguments.
|
|
12
|
-
* @returns {FunctionNode}
|
|
13
|
-
*/
|
|
14
|
-
export function fn(name: string, ...args: any[]): FunctionNode;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new aggregate function AST node.
|
|
17
|
-
* @param {string} name The function name.
|
|
18
|
-
* @param {...any} args The function arguments.
|
|
19
|
-
* @returns {AggregateNode}
|
|
20
|
-
*/
|
|
21
|
-
export function aggFn(name: string, ...args: any[]): AggregateNode;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new window AST node. The output node has an empty window
|
|
24
|
-
* definition. Use chained calls such as `partitionby` and `orderby`
|
|
25
|
-
* to specify the window settings.
|
|
26
|
-
* @param {WindowFunctionName} name The function name.
|
|
27
|
-
* @param {...any} args The function arguments.
|
|
28
|
-
* @returns {WindowNode}
|
|
29
|
-
*/
|
|
30
|
-
export function winFn(name: WindowFunctionName, ...args: any[]): WindowNode;
|
|
31
|
-
/**
|
|
32
|
-
* Process a list of expression inputs. Nested arrays are flattened,
|
|
33
|
-
* null results are removed, and each input is cast (as needed) to
|
|
34
|
-
* be a proper SQL AST node. By default, strings are assumed to be
|
|
35
|
-
* column names, while other primitive values map to SQL literals.
|
|
36
|
-
* Use an alternative *cast* function to change this behavior.
|
|
37
|
-
* @param {any[]} list The list of expression inputs.
|
|
38
|
-
* @param {function} [cast] A function that casts an input value
|
|
39
|
-
* to a desired type. By default, `asNode` is used to coerce
|
|
40
|
-
* inputs to AST nodes as needed.
|
|
41
|
-
* @returns {ReturnType<cast>[]}
|
|
42
|
-
*/
|
|
43
|
-
export function exprList(list: any[], cast?: Function): ReturnType<Function>[];
|
|
44
|
-
/**
|
|
45
|
-
* Process a list of function arguments, stripping any undefined
|
|
46
|
-
* values from the end of the list.
|
|
47
|
-
* @template T
|
|
48
|
-
* @param {T[]} list The input function arguments.
|
|
49
|
-
* @returns {T[]} The prepared argument list.
|
|
50
|
-
*/
|
|
51
|
-
export function argsList<T>(list: T[]): T[];
|
|
52
|
-
import type { SQLNode } from '../ast/node.js';
|
|
53
|
-
import { FunctionNode } from '../ast/function.js';
|
|
54
|
-
import { AggregateNode } from '../ast/aggregate.js';
|
|
55
|
-
import type { WindowFunctionName } from '../types.js';
|
|
56
|
-
import { WindowNode } from '../ast/window.js';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import { ParamLike } from '../types.js'
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Check if a value is a string.
|
|
6
|
-
* @param {*} value The value to check.
|
|
7
|
-
* @returns {value is string}
|
|
8
|
-
*/
|
|
9
|
-
export function isString(value: any): value is string;
|
|
10
|
-
/**
|
|
11
|
-
* Check if a value is an array.
|
|
12
|
-
* @param {*} value The value to check.
|
|
13
|
-
* @returns {value is Array}
|
|
14
|
-
*/
|
|
15
|
-
export function isArray(value: any): value is any[];
|
|
16
|
-
/**
|
|
17
|
-
* Check if a value is a dynamic parameter.
|
|
18
|
-
* @param {*} value The value to check.
|
|
19
|
-
* @returns {value is ParamLike}
|
|
20
|
-
*/
|
|
21
|
-
export function isParamLike(value: any): value is ParamLike;
|
|
22
|
-
import type { ParamLike } from '../types.js';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export namespace recurse {
|
|
2
|
-
let AGGREGATE: string[];
|
|
3
|
-
let BETWEEN: string[];
|
|
4
|
-
let BINARY: string[];
|
|
5
|
-
let CASE: string[];
|
|
6
|
-
let CAST: string[];
|
|
7
|
-
let COLUMN_PARAM: string[];
|
|
8
|
-
let COLUMN_REF: string[];
|
|
9
|
-
let DESCRIBE_QUERY: string[];
|
|
10
|
-
let EXPRESSION: string[];
|
|
11
|
-
let FRAGMENT: string[];
|
|
12
|
-
let FROM_CLAUSE: string[];
|
|
13
|
-
let FUNCTION: string[];
|
|
14
|
-
let IN: string[];
|
|
15
|
-
let LOGICAL_OPERATOR: string[];
|
|
16
|
-
let NOT_BETWEEN: string[];
|
|
17
|
-
let ORDER_BY: string[];
|
|
18
|
-
let PARAM: string[];
|
|
19
|
-
let SELECT_CLAUSE: string[];
|
|
20
|
-
let SELECT_QUERY: string[];
|
|
21
|
-
let SET_OPERATION: string[];
|
|
22
|
-
let UNARY: string[];
|
|
23
|
-
let WHEN: string[];
|
|
24
|
-
let WINDOW: string[];
|
|
25
|
-
let WINDOW_CLAUSE: string[];
|
|
26
|
-
let WINDOW_DEF: string[];
|
|
27
|
-
let WINDOW_FRAME: string[];
|
|
28
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rewrite a SQL expression, based on a map of nodes to replace.
|
|
3
|
-
* This method copies nodes as needed; it does not modify the input node.
|
|
4
|
-
* @param {ExprNode} node The root AST node of the expression.
|
|
5
|
-
* @param {Map<ExprNode, ExprNode>} map The rewrite map.
|
|
6
|
-
* When encountered, key nodes are replaced by value nodes.
|
|
7
|
-
* @returns {ExprNode}
|
|
8
|
-
*/
|
|
9
|
-
export function rewrite(node: ExprNode, map: Map<ExprNode, ExprNode>): ExprNode;
|
|
10
|
-
import type { ExprNode } from '../ast/node.js';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Indicate if the input AST contains an aggregate expression.
|
|
3
|
-
* The string content of verbatim nodes is analyzed to try to identify
|
|
4
|
-
* unparsed aggregate functions calls within SQL strings.
|
|
5
|
-
* @param {SQLNode} root The root of the AST to search.
|
|
6
|
-
* @returns {number} Return 0 if no aggregate functions are found.
|
|
7
|
-
* Sets bit 1 if an AggregateFunction instance is found.
|
|
8
|
-
* Sets bit 2 if an aggregate embedded in verbatim text is found.
|
|
9
|
-
*/
|
|
10
|
-
export function isAggregateExpression(root: SQLNode): number;
|
|
11
|
-
/**
|
|
12
|
-
* Collect all aggregate function nodes.
|
|
13
|
-
* @param {SQLNode} root The root of the AST to search.
|
|
14
|
-
* @returns {AggregateNode[]}
|
|
15
|
-
*/
|
|
16
|
-
export function collectAggregates(root: SQLNode): AggregateNode[];
|
|
17
|
-
/**
|
|
18
|
-
* Collect all unique column references.
|
|
19
|
-
* Multiple references to the same column are de-duplicated, even if
|
|
20
|
-
* they are not object-equal node instances.
|
|
21
|
-
* @param {SQLNode} root The root of the AST to search.
|
|
22
|
-
* @returns {ColumnRefNode[]}
|
|
23
|
-
*/
|
|
24
|
-
export function collectColumns(root: SQLNode): ColumnRefNode[];
|
|
25
|
-
/**
|
|
26
|
-
* Collect all unique dynamic parameter instances.
|
|
27
|
-
* @param {SQLNode} root The root of the AST to search.
|
|
28
|
-
* @returns {ParamLike[]}
|
|
29
|
-
*/
|
|
30
|
-
export function collectParams(root: SQLNode): ParamLike[];
|
|
31
|
-
import type { SQLNode } from '../ast/node.js';
|
|
32
|
-
import type { AggregateNode } from '../ast/aggregate.js';
|
|
33
|
-
import type { ColumnRefNode } from '../ast/column-ref.js';
|
|
34
|
-
import type { ParamLike } from '../types.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Perform a traversal of a SQL expression AST.
|
|
3
|
-
* @param {SQLNode} node Root node for AST traversal.
|
|
4
|
-
* @param {VisitorCallback} visit Visitor callback function.
|
|
5
|
-
* @return {VisitorResult}
|
|
6
|
-
*/
|
|
7
|
-
export function walk(node: SQLNode, visit: VisitorCallback): VisitorResult;
|
|
8
|
-
import type { SQLNode } from '../ast/node.js';
|
|
9
|
-
import type { VisitorCallback } from '../types.js';
|
|
10
|
-
import type { VisitorResult } from '../types.js';
|