@housekit/orm 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +224 -0
- package/dist/builders/delete.d.ts +21 -0
- package/dist/builders/insert.d.ts +128 -0
- package/dist/builders/prepared.d.ts +11 -0
- package/dist/builders/select.d.ts +352 -0
- package/dist/builders/select.types.d.ts +76 -0
- package/dist/builders/update.d.ts +23 -0
- package/dist/client.d.ts +52 -0
- package/dist/codegen/zod.d.ts +4 -0
- package/dist/column.d.ts +76 -0
- package/dist/compiler.d.ts +27 -0
- package/dist/core.d.ts +6 -0
- package/dist/data-types.d.ts +150 -0
- package/dist/dictionary.d.ts +263 -0
- package/dist/engines.d.ts +558 -0
- package/dist/expressions.d.ts +72 -0
- package/dist/external.d.ts +177 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +222 -0
- package/dist/logger.d.ts +8 -0
- package/dist/materialized-views.d.ts +271 -0
- package/dist/metadata.d.ts +33 -0
- package/dist/modules/aggregates.d.ts +205 -0
- package/dist/modules/array.d.ts +122 -0
- package/dist/modules/conditional.d.ts +110 -0
- package/dist/modules/conversion.d.ts +189 -0
- package/dist/modules/geo.d.ts +202 -0
- package/dist/modules/hash.d.ts +7 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/json.d.ts +130 -0
- package/dist/modules/math.d.ts +28 -0
- package/dist/modules/string.d.ts +167 -0
- package/dist/modules/time.d.ts +154 -0
- package/dist/modules/types.d.ts +177 -0
- package/dist/modules/window.d.ts +27 -0
- package/dist/relational.d.ts +33 -0
- package/dist/relations.d.ts +15 -0
- package/dist/schema-builder.d.ts +172 -0
- package/dist/table.d.ts +172 -0
- package/dist/utils/background-batcher.d.ts +20 -0
- package/dist/utils/batch-transform.d.ts +20 -0
- package/dist/utils/binary-reader.d.ts +48 -0
- package/dist/utils/binary-serializer.d.ts +160 -0
- package/dist/utils/binary-worker-code.d.ts +1 -0
- package/dist/utils/binary-worker-pool.d.ts +76 -0
- package/dist/utils/binary-worker.d.ts +12 -0
- package/dist/utils/insert-processing.d.ts +23 -0
- package/dist/utils/lru-cache.d.ts +10 -0
- package/package.json +68 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { SQLExpression } from '../expressions';
|
|
3
|
+
/**
|
|
4
|
+
* Return alternative value if column is null
|
|
5
|
+
* @param col - Column to check
|
|
6
|
+
* @param alt - Alternative value
|
|
7
|
+
*/
|
|
8
|
+
export declare function ifNull(col: ClickHouseColumn | SQLExpression, alt: any): SQLExpression;
|
|
9
|
+
/**
|
|
10
|
+
* Simple if-then-else conditional
|
|
11
|
+
* @param condition - Condition to evaluate
|
|
12
|
+
* @param trueVal - Value if condition is true
|
|
13
|
+
* @param falseVal - Value if condition is false
|
|
14
|
+
*/
|
|
15
|
+
export declare function sqlIf(condition: SQLExpression, trueVal: any, falseVal: any): SQLExpression;
|
|
16
|
+
/**
|
|
17
|
+
* Multi-conditional function for ClickHouse case-like logic
|
|
18
|
+
* Usage: multiIf(cond1, val1, cond2, val2, ..., default)
|
|
19
|
+
*/
|
|
20
|
+
export declare function multiIf(...args: (ClickHouseColumn | SQLExpression | any)[]): SQLExpression;
|
|
21
|
+
/**
|
|
22
|
+
* Case When builder for analytics queries
|
|
23
|
+
* Compiles to multiIf for better DX
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* caseWhen()
|
|
27
|
+
* .when(gt(events.count, 100), sql`'high'`)
|
|
28
|
+
* .when(gt(events.count, 50), sql`'medium'`)
|
|
29
|
+
* .otherwise(sql`'low'`)
|
|
30
|
+
*/
|
|
31
|
+
export declare function caseWhen(): CaseWhenBuilder;
|
|
32
|
+
declare class CaseWhenBuilder {
|
|
33
|
+
private conditions;
|
|
34
|
+
private values;
|
|
35
|
+
private defaultValue?;
|
|
36
|
+
/**
|
|
37
|
+
* Add a condition-value pair
|
|
38
|
+
* @param condition - The condition to evaluate
|
|
39
|
+
* @param value - The value to return if condition is true
|
|
40
|
+
*/
|
|
41
|
+
when(condition: ClickHouseColumn | SQLExpression, value: ClickHouseColumn | SQLExpression | any): this;
|
|
42
|
+
/**
|
|
43
|
+
* Set the default value (required)
|
|
44
|
+
* @param value - The default value to return if all conditions are false
|
|
45
|
+
*/
|
|
46
|
+
otherwise(value: ClickHouseColumn | SQLExpression | any): SQLExpression;
|
|
47
|
+
/**
|
|
48
|
+
* Build the final multiIf expression
|
|
49
|
+
*/
|
|
50
|
+
private build;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Return first non-null value
|
|
54
|
+
* @param args - Values to check
|
|
55
|
+
*/
|
|
56
|
+
export declare function coalesce(...args: (ClickHouseColumn | SQLExpression | any)[]): SQLExpression;
|
|
57
|
+
/**
|
|
58
|
+
* Return greatest value
|
|
59
|
+
* @param args - Values to compare
|
|
60
|
+
*/
|
|
61
|
+
export declare function greatest(...args: (ClickHouseColumn | SQLExpression | any)[]): SQLExpression;
|
|
62
|
+
/**
|
|
63
|
+
* Return smallest value
|
|
64
|
+
* @param args - Values to compare
|
|
65
|
+
*/
|
|
66
|
+
export declare function least(...args: (ClickHouseColumn | SQLExpression | any)[]): SQLExpression;
|
|
67
|
+
/**
|
|
68
|
+
* Check if value is null
|
|
69
|
+
* @param col - Column or expression to check
|
|
70
|
+
*/
|
|
71
|
+
export declare function isNull(col: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
72
|
+
/**
|
|
73
|
+
* Check if value is not null
|
|
74
|
+
* @param col - Column or expression to check
|
|
75
|
+
*/
|
|
76
|
+
export declare function isNotNull(col: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
77
|
+
/**
|
|
78
|
+
* Convert to null if condition is met
|
|
79
|
+
* @param condition - Condition to check
|
|
80
|
+
* @param col - Column to convert to null
|
|
81
|
+
*/
|
|
82
|
+
export declare function nullIf(condition: SQLExpression, col: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
83
|
+
/**
|
|
84
|
+
* Convert to null if value matches
|
|
85
|
+
* @param col - Column to check
|
|
86
|
+
* @param value - Value to match
|
|
87
|
+
*/
|
|
88
|
+
export declare function nullIfEqual(col: ClickHouseColumn | SQLExpression, value: any): SQLExpression;
|
|
89
|
+
/**
|
|
90
|
+
* Logical NOT
|
|
91
|
+
* @param expr - Expression to negate
|
|
92
|
+
*/
|
|
93
|
+
export declare function not(expr: SQLExpression): SQLExpression;
|
|
94
|
+
/**
|
|
95
|
+
* Logical AND (multiple conditions)
|
|
96
|
+
* @param exprs - Conditions to AND together
|
|
97
|
+
*/
|
|
98
|
+
export declare function and(...exprs: (SQLExpression | undefined | null | false)[]): SQLExpression | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Logical OR (multiple conditions)
|
|
101
|
+
* @param exprs - Conditions to OR together
|
|
102
|
+
*/
|
|
103
|
+
export declare function or(...exprs: (SQLExpression | undefined | null | false)[]): SQLExpression | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Logical XOR (exclusive or)
|
|
106
|
+
* @param expr1 - First expression
|
|
107
|
+
* @param expr2 - Second expression
|
|
108
|
+
*/
|
|
109
|
+
export declare function xor(expr1: SQLExpression, expr2: SQLExpression): SQLExpression;
|
|
110
|
+
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { SQLExpression } from '../expressions';
|
|
3
|
+
type Expr<T = any> = ClickHouseColumn<T, any, any> | SQLExpression<T>;
|
|
4
|
+
/**
|
|
5
|
+
* Convert to string
|
|
6
|
+
* @param col - Column or expression to convert
|
|
7
|
+
*/
|
|
8
|
+
export declare function toString(col: Expr): SQLExpression<string>;
|
|
9
|
+
export declare function toInt32(col: Expr): SQLExpression<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Convert to integer (alias for toInt32)
|
|
12
|
+
*/
|
|
13
|
+
export declare const toInteger: typeof toInt32;
|
|
14
|
+
/**
|
|
15
|
+
* Convert to 64-bit integer
|
|
16
|
+
* @param col - Column or expression to convert
|
|
17
|
+
*/
|
|
18
|
+
export declare function toInt64(col: Expr): SQLExpression<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Convert to 32-bit unsigned integer
|
|
21
|
+
* @param col - Column or expression to convert
|
|
22
|
+
*/
|
|
23
|
+
export declare function toUInt32(col: Expr): SQLExpression<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Convert to 64-bit unsigned integer
|
|
26
|
+
* @param col - Column or expression to convert
|
|
27
|
+
*/
|
|
28
|
+
export declare function toUInt64(col: Expr): SQLExpression<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Convert to 32-bit float
|
|
31
|
+
* @param col - Column or expression to convert
|
|
32
|
+
*/
|
|
33
|
+
export declare function toFloat32(col: Expr): SQLExpression<number>;
|
|
34
|
+
/**
|
|
35
|
+
* Convert to 64-bit float
|
|
36
|
+
* @param col - Column or expression to convert
|
|
37
|
+
*/
|
|
38
|
+
export declare function toFloat64(col: Expr): SQLExpression<number>;
|
|
39
|
+
export declare function toBool(col: Expr): SQLExpression<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Convert to boolean (alias for toBool)
|
|
42
|
+
*/
|
|
43
|
+
export declare const toBoolean: typeof toBool;
|
|
44
|
+
/**
|
|
45
|
+
* Convert to UUID
|
|
46
|
+
* @param col - Column or expression to convert
|
|
47
|
+
*/
|
|
48
|
+
export declare function toUUID(col: Expr): SQLExpression<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Convert to Date type (without time)
|
|
51
|
+
* @param col - Column or expression to convert
|
|
52
|
+
*/
|
|
53
|
+
export declare function toDate(col: Expr): SQLExpression<string>;
|
|
54
|
+
export declare function toDateTime(col: Expr): SQLExpression<string>;
|
|
55
|
+
/**
|
|
56
|
+
* Convert to timestamp (alias for toDateTime)
|
|
57
|
+
*/
|
|
58
|
+
export declare const toTimestamp: typeof toDateTime;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to DateTime64 type
|
|
61
|
+
* @param col - Column or expression to convert
|
|
62
|
+
* @param precision - DateTime precision (default: 3)
|
|
63
|
+
*/
|
|
64
|
+
export declare function toDateTime64(col: Expr, precision?: number): SQLExpression<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Convert to lowercase
|
|
67
|
+
* @param col - Column or expression to convert
|
|
68
|
+
*/
|
|
69
|
+
export declare function toLowercase(col: Expr): SQLExpression<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Convert to uppercase
|
|
72
|
+
* @param col - Column or expression to convert
|
|
73
|
+
*/
|
|
74
|
+
export declare function toUppercase(col: Expr): SQLExpression<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Convert to title case (first letter uppercase, rest lowercase)
|
|
77
|
+
* @param col - Column or expression to convert
|
|
78
|
+
*/
|
|
79
|
+
export declare function toTitleCase(col: Expr): SQLExpression<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Trim whitespace from string
|
|
82
|
+
* @param col - Column or expression to trim
|
|
83
|
+
*/
|
|
84
|
+
export declare function convertTrim(col: Expr): SQLExpression<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Trim left whitespace
|
|
87
|
+
* @param col - Column or expression to trim
|
|
88
|
+
*/
|
|
89
|
+
export declare function convertTrimLeft(col: Expr): SQLExpression<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Trim right whitespace
|
|
92
|
+
* @param col - Column or expression to trim
|
|
93
|
+
*/
|
|
94
|
+
export declare function convertTrimRight(col: Expr): SQLExpression<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Left pad string
|
|
97
|
+
* @param col - Column or expression to pad
|
|
98
|
+
* @param length - Target length
|
|
99
|
+
* @param fill - Fill character (default: space)
|
|
100
|
+
*/
|
|
101
|
+
export declare function leftPad(col: Expr, length: number, fill?: string): SQLExpression<string>;
|
|
102
|
+
/**
|
|
103
|
+
* Right pad string
|
|
104
|
+
* @param col - Column or expression to pad
|
|
105
|
+
* @param length - Target length
|
|
106
|
+
* @param fill - Fill character (default: space)
|
|
107
|
+
*/
|
|
108
|
+
export declare function rightPad(col: Expr, length: number, fill?: string): SQLExpression<string>;
|
|
109
|
+
/**
|
|
110
|
+
* Convert to hexadecimal string
|
|
111
|
+
* @param col - Column or expression to convert
|
|
112
|
+
*/
|
|
113
|
+
export declare function toHex(col: Expr): SQLExpression<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Convert from hexadecimal string
|
|
116
|
+
* @param col - Column or expression to convert
|
|
117
|
+
*/
|
|
118
|
+
export declare function fromHex(col: Expr): SQLExpression<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Convert to base64 string
|
|
121
|
+
* @param col - Column or expression to convert
|
|
122
|
+
*/
|
|
123
|
+
export declare function toBase64(col: Expr): SQLExpression<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Convert from base64 string
|
|
126
|
+
* @param col - Column or expression to convert
|
|
127
|
+
*/
|
|
128
|
+
export declare function fromBase64(col: Expr): SQLExpression<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Convert to binary string
|
|
131
|
+
* @param col - Column or expression to convert
|
|
132
|
+
*/
|
|
133
|
+
export declare function toBin(col: Expr): SQLExpression<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Convert from binary string
|
|
136
|
+
* @param col - Column or expression to convert
|
|
137
|
+
*/
|
|
138
|
+
export declare function fromBin(col: Expr): SQLExpression<string>;
|
|
139
|
+
/**
|
|
140
|
+
* URL encode string
|
|
141
|
+
* @param col - Column or expression to encode
|
|
142
|
+
*/
|
|
143
|
+
export declare function urlEncode(col: Expr): SQLExpression<string>;
|
|
144
|
+
/**
|
|
145
|
+
* URL decode string
|
|
146
|
+
* @param col - Column or expression to decode
|
|
147
|
+
*/
|
|
148
|
+
export declare function urlDecode(col: Expr): SQLExpression<string>;
|
|
149
|
+
/**
|
|
150
|
+
* HTML escape string
|
|
151
|
+
* @param col - Column or expression to escape
|
|
152
|
+
*/
|
|
153
|
+
export declare function htmlEscape(col: Expr): SQLExpression<string>;
|
|
154
|
+
/**
|
|
155
|
+
* HTML unescape string
|
|
156
|
+
* @param col - Column or expression to unescape
|
|
157
|
+
*/
|
|
158
|
+
export declare function htmlUnescape(col: Expr): SQLExpression<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Format number with specified decimal places
|
|
161
|
+
* @param col - Column or expression to format
|
|
162
|
+
* @param precision - Number of decimal places
|
|
163
|
+
*/
|
|
164
|
+
export declare function formatDecimal(col: Expr, precision: number): SQLExpression<string>;
|
|
165
|
+
/**
|
|
166
|
+
* Format number in human-readable format
|
|
167
|
+
* @param col - Column or expression to format
|
|
168
|
+
* @param precision - Number of decimal places
|
|
169
|
+
*/
|
|
170
|
+
export declare function formatReadableDecimal(col: Expr, precision: number): SQLExpression<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Format number with specified number of digits
|
|
173
|
+
* @param col - Column or expression to format
|
|
174
|
+
* @param digits - Total number of digits
|
|
175
|
+
*/
|
|
176
|
+
export declare function formatNumber(col: Expr, digits: number): SQLExpression<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Format bytes in human-readable format
|
|
179
|
+
* @param col - Column or expression to format
|
|
180
|
+
* @param precision - Number of decimal places
|
|
181
|
+
*/
|
|
182
|
+
export declare function formatBytes(col: Expr, precision?: number): SQLExpression<string>;
|
|
183
|
+
/**
|
|
184
|
+
* Format percentage
|
|
185
|
+
* @param col - Column or expression to format
|
|
186
|
+
* @param precision - Number of decimal places
|
|
187
|
+
*/
|
|
188
|
+
export declare function formatPercentage(col: Expr, precision?: number): SQLExpression<string>;
|
|
189
|
+
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { SQLExpression } from '../expressions';
|
|
3
|
+
/**
|
|
4
|
+
* Calculate great circle distance between two points using Haversine formula
|
|
5
|
+
* @param point1 - First point (longitude, latitude)
|
|
6
|
+
* @param point2 - Second point (longitude, latitude)
|
|
7
|
+
* @param unit - Distance unit ('km' or 'mi')
|
|
8
|
+
*/
|
|
9
|
+
export declare function geoDistance(point1: ClickHouseColumn | SQLExpression, point2: ClickHouseColumn | SQLExpression, unit?: 'km' | 'mi'): SQLExpression;
|
|
10
|
+
/**
|
|
11
|
+
* Calculate great circle distance between two points (ClickHouse native)
|
|
12
|
+
* @param point1 - First point (longitude, latitude)
|
|
13
|
+
* @param point2 - Second point (longitude, latitude)
|
|
14
|
+
*/
|
|
15
|
+
export declare function greatCircleDistance(point1: ClickHouseColumn | SQLExpression, point2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate distance between two points using Euclidean distance
|
|
18
|
+
* @param point1 - First point (x, y)
|
|
19
|
+
* @param point2 - Second point (x, y)
|
|
20
|
+
*/
|
|
21
|
+
export declare function euclideanDistance(point1: ClickHouseColumn | SQLExpression, point2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
22
|
+
/**
|
|
23
|
+
* Calculate Manhattan distance between two points
|
|
24
|
+
* @param point1 - First point (x, y)
|
|
25
|
+
* @param point2 - Second point (x, y)
|
|
26
|
+
*/
|
|
27
|
+
export declare function manhattanDistance(point1: ClickHouseColumn | SQLExpression, point2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
28
|
+
/**
|
|
29
|
+
* Create a point from longitude and latitude
|
|
30
|
+
* @param longitude - Longitude coordinate
|
|
31
|
+
* @param latitude - Latitude coordinate
|
|
32
|
+
*/
|
|
33
|
+
export declare function geoPoint(longitude: ClickHouseColumn | SQLExpression | number, latitude: ClickHouseColumn | SQLExpression | number): SQLExpression;
|
|
34
|
+
/**
|
|
35
|
+
* Extract longitude from point
|
|
36
|
+
* @param point - Point column or expression
|
|
37
|
+
*/
|
|
38
|
+
export declare function geoLongitude(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
39
|
+
/**
|
|
40
|
+
* Extract latitude from point
|
|
41
|
+
* @param point - Point column or expression
|
|
42
|
+
*/
|
|
43
|
+
export declare function geoLatitude(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
44
|
+
/**
|
|
45
|
+
* Extract x coordinate from point
|
|
46
|
+
* @param point - Point column or expression
|
|
47
|
+
*/
|
|
48
|
+
export declare function geoX(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
49
|
+
/**
|
|
50
|
+
* Extract y coordinate from point
|
|
51
|
+
* @param point - Point column or expression
|
|
52
|
+
*/
|
|
53
|
+
export declare function geoY(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
54
|
+
/**
|
|
55
|
+
* Check if point is within polygon
|
|
56
|
+
* @param point - Point to check
|
|
57
|
+
* @param polygon - Polygon to check against
|
|
58
|
+
*/
|
|
59
|
+
export declare function pointInPolygon(point: ClickHouseColumn | SQLExpression, polygon: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
60
|
+
/**
|
|
61
|
+
* Check if polygon contains another polygon
|
|
62
|
+
* @param polygon1 - First polygon
|
|
63
|
+
* @param polygon2 - Second polygon
|
|
64
|
+
*/
|
|
65
|
+
export declare function polygonContains(polygon1: ClickHouseColumn | SQLExpression, polygon2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
66
|
+
/**
|
|
67
|
+
* Check if two polygons intersect
|
|
68
|
+
* @param polygon1 - First polygon
|
|
69
|
+
* @param polygon2 - Second polygon
|
|
70
|
+
*/
|
|
71
|
+
export declare function polygonsIntersect(polygon1: ClickHouseColumn | SQLExpression, polygon2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
72
|
+
/**
|
|
73
|
+
* Create a bounding box from two points (bottom-left and top-right)
|
|
74
|
+
* @param point1 - Bottom-left point
|
|
75
|
+
* @param point2 - Top-right point
|
|
76
|
+
*/
|
|
77
|
+
export declare function boundingBox(point1: ClickHouseColumn | SQLExpression, point2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
78
|
+
/**
|
|
79
|
+
* Check if point is within bounding box
|
|
80
|
+
* @param point - Point to check
|
|
81
|
+
* @param bbox - Bounding box
|
|
82
|
+
*/
|
|
83
|
+
export declare function pointInBoundingBox(point: ClickHouseColumn | SQLExpression, bbox: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
84
|
+
/**
|
|
85
|
+
* Get the minimum point of a bounding box
|
|
86
|
+
* @param bbox - Bounding box
|
|
87
|
+
*/
|
|
88
|
+
export declare function bboxMin(bbox: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
89
|
+
/**
|
|
90
|
+
* Get the maximum point of a bounding box
|
|
91
|
+
* @param bbox - Bounding box
|
|
92
|
+
*/
|
|
93
|
+
export declare function bboxMax(bbox: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
94
|
+
/**
|
|
95
|
+
* Calculate area of a polygon
|
|
96
|
+
* @param polygon - Polygon column or expression
|
|
97
|
+
*/
|
|
98
|
+
export declare function polygonArea(polygon: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate perimeter of a polygon
|
|
101
|
+
* @param polygon - Polygon column or expression
|
|
102
|
+
*/
|
|
103
|
+
export declare function polygonPerimeter(polygon: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
104
|
+
/**
|
|
105
|
+
* Get the centroid of a polygon
|
|
106
|
+
* @param polygon - Polygon column or expression
|
|
107
|
+
*/
|
|
108
|
+
export declare function polygonCentroid(polygon: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
109
|
+
/**
|
|
110
|
+
* Simplify a polygon (reduce number of points)
|
|
111
|
+
* @param polygon - Polygon to simplify
|
|
112
|
+
* @param epsilon - Simplification tolerance
|
|
113
|
+
*/
|
|
114
|
+
export declare function polygonSimplify(polygon: ClickHouseColumn | SQLExpression, epsilon: number): SQLExpression;
|
|
115
|
+
/**
|
|
116
|
+
* Buffer a polygon (expand/contract by distance)
|
|
117
|
+
* @param polygon - Polygon to buffer
|
|
118
|
+
* @param distance - Buffer distance
|
|
119
|
+
*/
|
|
120
|
+
export declare function polygonBuffer(polygon: ClickHouseColumn | SQLExpression, distance: number): SQLExpression;
|
|
121
|
+
/**
|
|
122
|
+
* Encode a point as geohash
|
|
123
|
+
* @param point - Point to encode
|
|
124
|
+
* @param precision - Geohash precision (1-12)
|
|
125
|
+
*/
|
|
126
|
+
export declare function geoHashEncode(point: ClickHouseColumn | SQLExpression, precision?: number): SQLExpression;
|
|
127
|
+
/**
|
|
128
|
+
* Decode a geohash to a point
|
|
129
|
+
* @param geohash - Geohash string to decode
|
|
130
|
+
*/
|
|
131
|
+
export declare function geoHashDecode(geohash: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
132
|
+
/**
|
|
133
|
+
* Get neighbors of a geohash
|
|
134
|
+
* @param geohash - Geohash string
|
|
135
|
+
*/
|
|
136
|
+
export declare function geoHashNeighbors(geohash: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
137
|
+
/**
|
|
138
|
+
* Check if two geohashes are neighbors
|
|
139
|
+
* @param geohash1 - First geohash
|
|
140
|
+
* @param geohash2 - Second geohash
|
|
141
|
+
*/
|
|
142
|
+
export declare function geoHashAreNeighbors(geohash1: ClickHouseColumn | SQLExpression, geohash2: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
143
|
+
/**
|
|
144
|
+
* Find points within radius of a center point
|
|
145
|
+
* @param center - Center point
|
|
146
|
+
* @param radius - Search radius
|
|
147
|
+
* @param points - Points to search
|
|
148
|
+
*/
|
|
149
|
+
export declare function pointsWithinRadius(center: ClickHouseColumn | SQLExpression, radius: number, points: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
150
|
+
/**
|
|
151
|
+
* Find nearest neighbors to a point
|
|
152
|
+
* @param point - Reference point
|
|
153
|
+
* @param points - Array of points to search
|
|
154
|
+
* @param k - Number of neighbors to find
|
|
155
|
+
*/
|
|
156
|
+
export declare function nearestNeighbors(point: ClickHouseColumn | SQLExpression, points: ClickHouseColumn | SQLExpression, k: number): SQLExpression;
|
|
157
|
+
/**
|
|
158
|
+
* Cluster points using k-means
|
|
159
|
+
* @param points - Array of points to cluster
|
|
160
|
+
* @param k - Number of clusters
|
|
161
|
+
*/
|
|
162
|
+
export declare function kMeansClustering(points: ClickHouseColumn | SQLExpression, k: number): SQLExpression;
|
|
163
|
+
/**
|
|
164
|
+
* Convert degrees to radians
|
|
165
|
+
* @param degrees - Degrees value
|
|
166
|
+
*/
|
|
167
|
+
export declare function degreesToRadians(degrees: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
168
|
+
/**
|
|
169
|
+
* Convert radians to degrees
|
|
170
|
+
* @param radians - Radians value
|
|
171
|
+
*/
|
|
172
|
+
export declare function radiansToDegrees(radians: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
173
|
+
/**
|
|
174
|
+
* Convert Web Mercator to WGS84
|
|
175
|
+
* @param point - Point in Web Mercator coordinates
|
|
176
|
+
*/
|
|
177
|
+
export declare function webMercatorToWGS84(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
178
|
+
/**
|
|
179
|
+
* Convert WGS84 to Web Mercator
|
|
180
|
+
* @param point - Point in WGS84 coordinates
|
|
181
|
+
*/
|
|
182
|
+
export declare function wGS84ToWebMercator(point: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
183
|
+
/**
|
|
184
|
+
* Check if a geometry is valid
|
|
185
|
+
* @param geometry - Geometry to validate
|
|
186
|
+
*/
|
|
187
|
+
export declare function isValidGeometry(geometry: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
188
|
+
/**
|
|
189
|
+
* Get the geometry type
|
|
190
|
+
* @param geometry - Geometry column or expression
|
|
191
|
+
*/
|
|
192
|
+
export declare function geometryType(geometry: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
193
|
+
/**
|
|
194
|
+
* Get the number of points in a geometry
|
|
195
|
+
* @param geometry - Geometry column or expression
|
|
196
|
+
*/
|
|
197
|
+
export declare function geometryNumPoints(geometry: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
198
|
+
/**
|
|
199
|
+
* Get the number of interior rings in a polygon
|
|
200
|
+
* @param polygon - Polygon column or expression
|
|
201
|
+
*/
|
|
202
|
+
export declare function polygonNumInteriorRings(polygon: ClickHouseColumn | SQLExpression): SQLExpression;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { type SQLExpression } from '../expressions';
|
|
3
|
+
type Expr<T = any> = ClickHouseColumn<T, any, any> | SQLExpression<T>;
|
|
4
|
+
export declare const cityHash64: (col: Expr) => SQLExpression<number>;
|
|
5
|
+
export declare const md5: (col: Expr) => SQLExpression<string>;
|
|
6
|
+
export declare const sha256: (col: Expr) => SQLExpression<string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './array';
|
|
2
|
+
export * from './json';
|
|
3
|
+
export * from './geo';
|
|
4
|
+
export * from './time';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './aggregates';
|
|
7
|
+
export * from './conditional';
|
|
8
|
+
export * from './conversion';
|
|
9
|
+
export * from './string';
|
|
10
|
+
export * from './math';
|
|
11
|
+
export * from './hash';
|
|
12
|
+
export * from './window';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { SQLExpression } from '../expressions';
|
|
3
|
+
type Expr<T = any> = ClickHouseColumn<T, any, any> | SQLExpression<T>;
|
|
4
|
+
/**
|
|
5
|
+
* Extract string value from JSON
|
|
6
|
+
* @param col - JSON column or expression
|
|
7
|
+
* @param path - JSONPath expression (e.g., 'user.name', '$.items[0].price')
|
|
8
|
+
*/
|
|
9
|
+
export declare function jsonExtractString(col: Expr, path: string): SQLExpression<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Extract integer value from JSON
|
|
12
|
+
* @param col - JSON column or expression
|
|
13
|
+
* @param path - JSONPath expression (e.g., 'user.age', '$.count')
|
|
14
|
+
*/
|
|
15
|
+
export declare function jsonExtractInt(col: Expr, path: string): SQLExpression<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Extract float value from JSON
|
|
18
|
+
* @param col - JSON column or expression
|
|
19
|
+
* @param path - JSONPath expression (e.g., 'user.score', '$.price')
|
|
20
|
+
*/
|
|
21
|
+
export declare function jsonExtractFloat(col: Expr, path: string): SQLExpression<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Extract boolean value from JSON
|
|
24
|
+
* @param col - JSON column or expression
|
|
25
|
+
* @param path - JSONPath expression (e.g., 'user.active', '$.enabled')
|
|
26
|
+
*/
|
|
27
|
+
export declare function jsonExtractBool(col: Expr, path: string): SQLExpression<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Generic JSON extraction with type specification
|
|
30
|
+
* @param col - JSON column or expression
|
|
31
|
+
* @param path - JSONPath expression
|
|
32
|
+
* @param type - ClickHouse type literal (e.g., 'String', 'Int', 'Float', 'Bool', 'Array(String)')
|
|
33
|
+
*/
|
|
34
|
+
export declare function jsonExtract(col: Expr, path: string, type: string): SQLExpression<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Extract raw JSON value as string
|
|
37
|
+
* Useful when you want to preserve the JSON structure
|
|
38
|
+
* @param col - JSON column or expression
|
|
39
|
+
* @param path - JSONPath expression
|
|
40
|
+
*/
|
|
41
|
+
export declare function jsonExtractRaw(col: Expr, path: string): SQLExpression<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if JSON has a specific path
|
|
44
|
+
* @param col - JSON column or expression
|
|
45
|
+
* @param path - JSONPath expression
|
|
46
|
+
*/
|
|
47
|
+
export declare function jsonHas(col: Expr, path: string): SQLExpression<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Extract all keys from JSON object at specified path
|
|
50
|
+
* Useful for introspecting JSON blobs
|
|
51
|
+
* @param col - JSON column or expression
|
|
52
|
+
* @param path - JSONPath expression (optional, defaults to root)
|
|
53
|
+
*/
|
|
54
|
+
export declare function jsonExtractKeys(col: Expr, path?: string): SQLExpression<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Extract all values from JSON object at specified path
|
|
57
|
+
* Useful for introspecting JSON blobs
|
|
58
|
+
* @param col - JSON column or expression
|
|
59
|
+
* @param path - JSONPath expression (optional, defaults to root)
|
|
60
|
+
*/
|
|
61
|
+
export declare function jsonExtractValues(col: Expr, path?: string): SQLExpression<any>;
|
|
62
|
+
/**
|
|
63
|
+
* Extract keys and values as tuples from JSON object
|
|
64
|
+
* Useful for introspecting JSON blobs
|
|
65
|
+
* @param col - JSON column or expression
|
|
66
|
+
* @param path - JSONPath expression (optional, defaults to root)
|
|
67
|
+
*/
|
|
68
|
+
export declare function jsonExtractKeysAndValues(col: Expr, path?: string): SQLExpression<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Get the length of JSON array or object
|
|
71
|
+
* @param col - JSON column or expression
|
|
72
|
+
* @param path - JSONPath expression (optional, defaults to root)
|
|
73
|
+
*/
|
|
74
|
+
export declare function jsonLength(col: Expr, path?: string): SQLExpression<number>;
|
|
75
|
+
/**
|
|
76
|
+
* Get the type of JSON value at specified path
|
|
77
|
+
* Returns: 'null', 'bool', 'number', 'string', 'array', 'object'
|
|
78
|
+
* @param col - JSON column or expression
|
|
79
|
+
* @param path - JSONPath expression (optional, defaults to root)
|
|
80
|
+
*/
|
|
81
|
+
export declare function jsonType(col: Expr, path?: string): SQLExpression<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Insert value into JSON at specified path
|
|
84
|
+
* @param col - JSON column or expression
|
|
85
|
+
* @param path - JSONPath expression
|
|
86
|
+
* @param value - Value to insert
|
|
87
|
+
*/
|
|
88
|
+
export declare function jsonInsert(col: Expr, path: string, value: any): SQLExpression<any>;
|
|
89
|
+
/**
|
|
90
|
+
* Replace value in JSON at specified path
|
|
91
|
+
* @param col - JSON column or expression
|
|
92
|
+
* @param path - JSONPath expression
|
|
93
|
+
* @param value - Value to replace with
|
|
94
|
+
*/
|
|
95
|
+
export declare function jsonReplace(col: Expr, path: string, value: any): SQLExpression<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Remove value from JSON at specified path
|
|
98
|
+
* @param col - JSON column or expression
|
|
99
|
+
* @param path - JSONPath expression
|
|
100
|
+
*/
|
|
101
|
+
export declare function jsonRemove(col: Expr, path: string): SQLExpression<any>;
|
|
102
|
+
/**
|
|
103
|
+
* Parse string as JSON
|
|
104
|
+
* @param col - String column or expression containing JSON
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseJSON(col: Expr): SQLExpression<any>;
|
|
107
|
+
/**
|
|
108
|
+
* Parse string as JSONBestEffort (more tolerant)
|
|
109
|
+
* @param col - String column or expression containing JSON
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseJSONBestEffort(col: Expr): SQLExpression<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Convert JSON to string
|
|
114
|
+
* @param col - JSON column or expression
|
|
115
|
+
*/
|
|
116
|
+
export declare function jsonStringify(col: Expr): SQLExpression<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Extract JSON array as ClickHouse array
|
|
119
|
+
* @param col - JSON column or expression
|
|
120
|
+
* @param path - JSONPath expression
|
|
121
|
+
* @param type - ClickHouse type for array elements (e.g., 'String', 'Int')
|
|
122
|
+
*/
|
|
123
|
+
export declare function jsonArrayExtract(col: Expr, path: string, type: string): SQLExpression<any>;
|
|
124
|
+
/**
|
|
125
|
+
* Get length of JSON array
|
|
126
|
+
* @param col - JSON column or expression
|
|
127
|
+
* @param path - JSONPath expression
|
|
128
|
+
*/
|
|
129
|
+
export declare function jsonArrayLength(col: Expr, path: string): SQLExpression<number>;
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ClickHouseColumn } from '../core';
|
|
2
|
+
import { type SQLExpression } from '../expressions';
|
|
3
|
+
export declare const abs: (col: ClickHouseColumn | SQLExpression) => SQLExpression<any>;
|
|
4
|
+
export declare const round: (col: ClickHouseColumn | SQLExpression, precision?: number) => SQLExpression<any>;
|
|
5
|
+
export declare const floor: (col: ClickHouseColumn | SQLExpression) => SQLExpression<any>;
|
|
6
|
+
export declare const ceil: (col: ClickHouseColumn | SQLExpression) => SQLExpression<any>;
|
|
7
|
+
export declare const sqrt: (col: ClickHouseColumn | SQLExpression) => SQLExpression<any>;
|
|
8
|
+
export declare const power: (col: ClickHouseColumn | SQLExpression, exponent: number) => SQLExpression<any>;
|
|
9
|
+
/**
|
|
10
|
+
* ⚠️ Advanced: Low-value arithmetic wrapper.
|
|
11
|
+
* Consider using `sql`${a} + ${b}`` directly.
|
|
12
|
+
*/
|
|
13
|
+
export declare const plus: (a: ClickHouseColumn | SQLExpression | number, b: ClickHouseColumn | SQLExpression | number) => SQLExpression<any>;
|
|
14
|
+
/**
|
|
15
|
+
* ⚠️ Advanced: Low-value arithmetic wrapper.
|
|
16
|
+
* Consider using `sql`${a} - ${b}`` directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare const minus: (a: ClickHouseColumn | SQLExpression | number, b: ClickHouseColumn | SQLExpression | number) => SQLExpression<any>;
|
|
19
|
+
/**
|
|
20
|
+
* ⚠️ Advanced: Low-value arithmetic wrapper.
|
|
21
|
+
* Consider using `sql`${a} * ${b}`` directly.
|
|
22
|
+
*/
|
|
23
|
+
export declare const mult: (a: ClickHouseColumn | SQLExpression | number, b: ClickHouseColumn | SQLExpression | number) => SQLExpression<any>;
|
|
24
|
+
/**
|
|
25
|
+
* ⚠️ Advanced: Low-value arithmetic wrapper.
|
|
26
|
+
* Consider using `sql`${a} / ${b}`` directly.
|
|
27
|
+
*/
|
|
28
|
+
export declare const div: (a: ClickHouseColumn | SQLExpression | number, b: ClickHouseColumn | SQLExpression | number) => SQLExpression<any>;
|