@milaboratories/ptabler-expression-js 1.1.22 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +36 -0
- package/dist/expressions.cjs +752 -835
- package/dist/expressions.cjs.map +1 -1
- package/dist/expressions.d.ts +266 -265
- package/dist/expressions.js +752 -834
- package/dist/expressions.js.map +1 -1
- package/dist/functions.cjs +101 -130
- package/dist/functions.cjs.map +1 -1
- package/dist/functions.d.ts +30 -30
- package/dist/functions.js +96 -123
- package/dist/functions.js.map +1 -1
- package/dist/index.cjs +42 -46
- package/dist/index.d.ts +12 -9
- package/dist/index.js +4 -3
- package/dist/types.d.ts +8 -1
- package/package.json +8 -8
- package/dist/expressions.d.ts.map +0 -1
- package/dist/functions.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
package/dist/expressions.js
CHANGED
|
@@ -1,840 +1,758 @@
|
|
|
1
|
+
//#region src/expressions.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
* Base abstract class for all expressions
|
|
4
|
+
*/
|
|
5
|
+
var ExpressionImpl = class {
|
|
6
|
+
_alias;
|
|
7
|
+
/**
|
|
8
|
+
* Set an alias for this expression
|
|
9
|
+
*/
|
|
10
|
+
alias(name) {
|
|
11
|
+
const cloned = this.clone();
|
|
12
|
+
cloned._alias = name;
|
|
13
|
+
return cloned;
|
|
14
|
+
}
|
|
15
|
+
plus(other) {
|
|
16
|
+
return new ArithmeticExpressionImpl("plus", this, coerceToExpression(other));
|
|
17
|
+
}
|
|
18
|
+
minus(other) {
|
|
19
|
+
return new ArithmeticExpressionImpl("minus", this, coerceToExpression(other));
|
|
20
|
+
}
|
|
21
|
+
multiply(other) {
|
|
22
|
+
return new ArithmeticExpressionImpl("multiply", this, coerceToExpression(other));
|
|
23
|
+
}
|
|
24
|
+
truediv(other) {
|
|
25
|
+
return new ArithmeticExpressionImpl("truediv", this, coerceToExpression(other));
|
|
26
|
+
}
|
|
27
|
+
floordiv(other) {
|
|
28
|
+
return new ArithmeticExpressionImpl("floordiv", this, coerceToExpression(other));
|
|
29
|
+
}
|
|
30
|
+
gt(other) {
|
|
31
|
+
return new ComparisonExpressionImpl("gt", this, coerceToExpression(other));
|
|
32
|
+
}
|
|
33
|
+
ge(other) {
|
|
34
|
+
return new ComparisonExpressionImpl("ge", this, coerceToExpression(other));
|
|
35
|
+
}
|
|
36
|
+
eq(other) {
|
|
37
|
+
return new ComparisonExpressionImpl("eq", this, coerceToExpression(other));
|
|
38
|
+
}
|
|
39
|
+
lt(other) {
|
|
40
|
+
return new ComparisonExpressionImpl("lt", this, coerceToExpression(other));
|
|
41
|
+
}
|
|
42
|
+
le(other) {
|
|
43
|
+
return new ComparisonExpressionImpl("le", this, coerceToExpression(other));
|
|
44
|
+
}
|
|
45
|
+
neq(other) {
|
|
46
|
+
return new ComparisonExpressionImpl("neq", this, coerceToExpression(other));
|
|
47
|
+
}
|
|
48
|
+
and(...others) {
|
|
49
|
+
return new LogicalExpressionImpl("and", [this, ...others]);
|
|
50
|
+
}
|
|
51
|
+
or(...others) {
|
|
52
|
+
return new LogicalExpressionImpl("or", [this, ...others]);
|
|
53
|
+
}
|
|
54
|
+
not() {
|
|
55
|
+
return new LogicalExpressionImpl("not", [this]);
|
|
56
|
+
}
|
|
57
|
+
abs() {
|
|
58
|
+
return new UnaryArithmeticExpressionImpl("abs", this);
|
|
59
|
+
}
|
|
60
|
+
sqrt() {
|
|
61
|
+
return new UnaryArithmeticExpressionImpl("sqrt", this);
|
|
62
|
+
}
|
|
63
|
+
log() {
|
|
64
|
+
return new UnaryArithmeticExpressionImpl("log", this);
|
|
65
|
+
}
|
|
66
|
+
log10() {
|
|
67
|
+
return new UnaryArithmeticExpressionImpl("log10", this);
|
|
68
|
+
}
|
|
69
|
+
log2() {
|
|
70
|
+
return new UnaryArithmeticExpressionImpl("log2", this);
|
|
71
|
+
}
|
|
72
|
+
floor() {
|
|
73
|
+
return new UnaryArithmeticExpressionImpl("floor", this);
|
|
74
|
+
}
|
|
75
|
+
ceil() {
|
|
76
|
+
return new UnaryArithmeticExpressionImpl("ceil", this);
|
|
77
|
+
}
|
|
78
|
+
round() {
|
|
79
|
+
return new UnaryArithmeticExpressionImpl("round", this);
|
|
80
|
+
}
|
|
81
|
+
negate() {
|
|
82
|
+
return new UnaryArithmeticExpressionImpl("negate", this);
|
|
83
|
+
}
|
|
84
|
+
isNull() {
|
|
85
|
+
return new NullCheckExpressionImpl("is_na", this);
|
|
86
|
+
}
|
|
87
|
+
isNotNull() {
|
|
88
|
+
return new NullCheckExpressionImpl("is_not_na", this);
|
|
89
|
+
}
|
|
90
|
+
fillNull(value) {
|
|
91
|
+
return new FillNullExpressionImpl(this, coerceToExpression(value));
|
|
92
|
+
}
|
|
93
|
+
fillNaN(value) {
|
|
94
|
+
return new FillNaNExpressionImpl(this, coerceToExpression(value));
|
|
95
|
+
}
|
|
96
|
+
strConcat(...others) {
|
|
97
|
+
return new StringConcatExpressionImpl([this, ...others.map(coerceToExpression)]);
|
|
98
|
+
}
|
|
99
|
+
substring(start, length) {
|
|
100
|
+
return new SubstringExpressionImpl(this, start, length);
|
|
101
|
+
}
|
|
102
|
+
strReplace(pattern, value, options) {
|
|
103
|
+
return new StringReplaceExpressionImpl(this, pattern, value, options);
|
|
104
|
+
}
|
|
105
|
+
strContains(pattern, literal, strict) {
|
|
106
|
+
return new StringContainsExpressionImpl(this, coerceToExpression(pattern), literal, strict);
|
|
107
|
+
}
|
|
108
|
+
strToUpper() {
|
|
109
|
+
return new StringCaseExpressionImpl("to_upper", this);
|
|
110
|
+
}
|
|
111
|
+
strToLower() {
|
|
112
|
+
return new StringCaseExpressionImpl("to_lower", this);
|
|
113
|
+
}
|
|
114
|
+
strStartsWith(pattern) {
|
|
115
|
+
return new StringStartsWithExpressionImpl(this, coerceToExpression(pattern));
|
|
116
|
+
}
|
|
117
|
+
strEndsWith(pattern) {
|
|
118
|
+
return new StringEndsWithExpressionImpl(this, coerceToExpression(pattern));
|
|
119
|
+
}
|
|
120
|
+
sum() {
|
|
121
|
+
return new AggregationExpressionImpl("sum", this);
|
|
122
|
+
}
|
|
123
|
+
mean() {
|
|
124
|
+
return new AggregationExpressionImpl("mean", this);
|
|
125
|
+
}
|
|
126
|
+
count() {
|
|
127
|
+
return new AggregationExpressionImpl("count", this);
|
|
128
|
+
}
|
|
129
|
+
min() {
|
|
130
|
+
return new AggregationExpressionImpl("min", this);
|
|
131
|
+
}
|
|
132
|
+
max() {
|
|
133
|
+
return new AggregationExpressionImpl("max", this);
|
|
134
|
+
}
|
|
135
|
+
first() {
|
|
136
|
+
return new AggregationExpressionImpl("first", this);
|
|
137
|
+
}
|
|
138
|
+
last() {
|
|
139
|
+
return new AggregationExpressionImpl("last", this);
|
|
140
|
+
}
|
|
141
|
+
cumsum() {
|
|
142
|
+
return new CumsumExpressionImpl(this);
|
|
143
|
+
}
|
|
144
|
+
stringDistance(other, metric, returnSimilarity) {
|
|
145
|
+
return new StringDistanceExpressionImpl(this, coerceToExpression(other), metric, returnSimilarity);
|
|
146
|
+
}
|
|
147
|
+
fuzzyStringFilter(pattern, metric, bound) {
|
|
148
|
+
return new FuzzyStringFilterExpressionImpl(this, coerceToExpression(pattern), metric, bound);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var ColumnExpressionImpl = class ColumnExpressionImpl extends ExpressionImpl {
|
|
152
|
+
constructor(columnName) {
|
|
153
|
+
super();
|
|
154
|
+
this.columnName = columnName;
|
|
155
|
+
}
|
|
156
|
+
toJSON() {
|
|
157
|
+
return {
|
|
158
|
+
type: "col",
|
|
159
|
+
name: this.columnName
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
getAlias() {
|
|
163
|
+
return this._alias || this.columnName;
|
|
164
|
+
}
|
|
165
|
+
clone() {
|
|
166
|
+
const cloned = new ColumnExpressionImpl(this.columnName);
|
|
167
|
+
cloned._alias = this._alias;
|
|
168
|
+
return cloned;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the column name
|
|
172
|
+
*/
|
|
173
|
+
getColumnName() {
|
|
174
|
+
return this.columnName;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
4
177
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class ExpressionImpl {
|
|
8
|
-
_alias;
|
|
9
|
-
/**
|
|
10
|
-
* Set an alias for this expression
|
|
11
|
-
*/
|
|
12
|
-
alias(name) {
|
|
13
|
-
const cloned = this.clone();
|
|
14
|
-
cloned._alias = name;
|
|
15
|
-
return cloned;
|
|
16
|
-
}
|
|
17
|
-
// Arithmetic operations
|
|
18
|
-
plus(other) {
|
|
19
|
-
return new ArithmeticExpressionImpl("plus", this, coerceToExpression(other));
|
|
20
|
-
}
|
|
21
|
-
minus(other) {
|
|
22
|
-
return new ArithmeticExpressionImpl("minus", this, coerceToExpression(other));
|
|
23
|
-
}
|
|
24
|
-
multiply(other) {
|
|
25
|
-
return new ArithmeticExpressionImpl("multiply", this, coerceToExpression(other));
|
|
26
|
-
}
|
|
27
|
-
truediv(other) {
|
|
28
|
-
return new ArithmeticExpressionImpl("truediv", this, coerceToExpression(other));
|
|
29
|
-
}
|
|
30
|
-
floordiv(other) {
|
|
31
|
-
return new ArithmeticExpressionImpl("floordiv", this, coerceToExpression(other));
|
|
32
|
-
}
|
|
33
|
-
// Comparison operations
|
|
34
|
-
gt(other) {
|
|
35
|
-
return new ComparisonExpressionImpl("gt", this, coerceToExpression(other));
|
|
36
|
-
}
|
|
37
|
-
ge(other) {
|
|
38
|
-
return new ComparisonExpressionImpl("ge", this, coerceToExpression(other));
|
|
39
|
-
}
|
|
40
|
-
eq(other) {
|
|
41
|
-
return new ComparisonExpressionImpl("eq", this, coerceToExpression(other));
|
|
42
|
-
}
|
|
43
|
-
lt(other) {
|
|
44
|
-
return new ComparisonExpressionImpl("lt", this, coerceToExpression(other));
|
|
45
|
-
}
|
|
46
|
-
le(other) {
|
|
47
|
-
return new ComparisonExpressionImpl("le", this, coerceToExpression(other));
|
|
48
|
-
}
|
|
49
|
-
neq(other) {
|
|
50
|
-
return new ComparisonExpressionImpl("neq", this, coerceToExpression(other));
|
|
51
|
-
}
|
|
52
|
-
// Logical operations
|
|
53
|
-
and(...others) {
|
|
54
|
-
return new LogicalExpressionImpl("and", [this, ...others]);
|
|
55
|
-
}
|
|
56
|
-
or(...others) {
|
|
57
|
-
return new LogicalExpressionImpl("or", [this, ...others]);
|
|
58
|
-
}
|
|
59
|
-
not() {
|
|
60
|
-
return new LogicalExpressionImpl("not", [this]);
|
|
61
|
-
}
|
|
62
|
-
// Unary arithmetic operations
|
|
63
|
-
abs() {
|
|
64
|
-
return new UnaryArithmeticExpressionImpl("abs", this);
|
|
65
|
-
}
|
|
66
|
-
sqrt() {
|
|
67
|
-
return new UnaryArithmeticExpressionImpl("sqrt", this);
|
|
68
|
-
}
|
|
69
|
-
log() {
|
|
70
|
-
return new UnaryArithmeticExpressionImpl("log", this);
|
|
71
|
-
}
|
|
72
|
-
log10() {
|
|
73
|
-
return new UnaryArithmeticExpressionImpl("log10", this);
|
|
74
|
-
}
|
|
75
|
-
log2() {
|
|
76
|
-
return new UnaryArithmeticExpressionImpl("log2", this);
|
|
77
|
-
}
|
|
78
|
-
floor() {
|
|
79
|
-
return new UnaryArithmeticExpressionImpl("floor", this);
|
|
80
|
-
}
|
|
81
|
-
ceil() {
|
|
82
|
-
return new UnaryArithmeticExpressionImpl("ceil", this);
|
|
83
|
-
}
|
|
84
|
-
round() {
|
|
85
|
-
return new UnaryArithmeticExpressionImpl("round", this);
|
|
86
|
-
}
|
|
87
|
-
negate() {
|
|
88
|
-
return new UnaryArithmeticExpressionImpl("negate", this);
|
|
89
|
-
}
|
|
90
|
-
// Null checks
|
|
91
|
-
isNull() {
|
|
92
|
-
return new NullCheckExpressionImpl("is_na", this);
|
|
93
|
-
}
|
|
94
|
-
isNotNull() {
|
|
95
|
-
return new NullCheckExpressionImpl("is_not_na", this);
|
|
96
|
-
}
|
|
97
|
-
// Fill null/NaN
|
|
98
|
-
fillNull(value) {
|
|
99
|
-
return new FillNullExpressionImpl(this, coerceToExpression(value));
|
|
100
|
-
}
|
|
101
|
-
fillNaN(value) {
|
|
102
|
-
return new FillNaNExpressionImpl(this, coerceToExpression(value));
|
|
103
|
-
}
|
|
104
|
-
// String operations
|
|
105
|
-
strConcat(...others) {
|
|
106
|
-
return new StringConcatExpressionImpl([this, ...others.map(coerceToExpression)]);
|
|
107
|
-
}
|
|
108
|
-
substring(start, length) {
|
|
109
|
-
return new SubstringExpressionImpl(this, start, length);
|
|
110
|
-
}
|
|
111
|
-
strReplace(pattern, value, options) {
|
|
112
|
-
return new StringReplaceExpressionImpl(this, pattern, value, options);
|
|
113
|
-
}
|
|
114
|
-
strContains(pattern, literal, strict) {
|
|
115
|
-
return new StringContainsExpressionImpl(this, coerceToExpression(pattern), literal, strict);
|
|
116
|
-
}
|
|
117
|
-
strToUpper() {
|
|
118
|
-
return new StringCaseExpressionImpl("to_upper", this);
|
|
119
|
-
}
|
|
120
|
-
strToLower() {
|
|
121
|
-
return new StringCaseExpressionImpl("to_lower", this);
|
|
122
|
-
}
|
|
123
|
-
strStartsWith(pattern) {
|
|
124
|
-
return new StringStartsWithExpressionImpl(this, coerceToExpression(pattern));
|
|
125
|
-
}
|
|
126
|
-
strEndsWith(pattern) {
|
|
127
|
-
return new StringEndsWithExpressionImpl(this, coerceToExpression(pattern));
|
|
128
|
-
}
|
|
129
|
-
// Aggregation operations
|
|
130
|
-
sum() {
|
|
131
|
-
return new AggregationExpressionImpl("sum", this);
|
|
132
|
-
}
|
|
133
|
-
mean() {
|
|
134
|
-
return new AggregationExpressionImpl("mean", this);
|
|
135
|
-
}
|
|
136
|
-
count() {
|
|
137
|
-
return new AggregationExpressionImpl("count", this);
|
|
138
|
-
}
|
|
139
|
-
min() {
|
|
140
|
-
return new AggregationExpressionImpl("min", this);
|
|
141
|
-
}
|
|
142
|
-
max() {
|
|
143
|
-
return new AggregationExpressionImpl("max", this);
|
|
144
|
-
}
|
|
145
|
-
first() {
|
|
146
|
-
return new AggregationExpressionImpl("first", this);
|
|
147
|
-
}
|
|
148
|
-
last() {
|
|
149
|
-
return new AggregationExpressionImpl("last", this);
|
|
150
|
-
}
|
|
151
|
-
cumsum() {
|
|
152
|
-
return new CumsumExpressionImpl(this);
|
|
153
|
-
}
|
|
154
|
-
// Fuzzy operations
|
|
155
|
-
stringDistance(other, metric, returnSimilarity) {
|
|
156
|
-
return new StringDistanceExpressionImpl(this, coerceToExpression(other), metric, returnSimilarity);
|
|
157
|
-
}
|
|
158
|
-
fuzzyStringFilter(pattern, metric, bound) {
|
|
159
|
-
return new FuzzyStringFilterExpressionImpl(this, coerceToExpression(pattern), metric, bound);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
class ColumnExpressionImpl extends ExpressionImpl {
|
|
163
|
-
columnName;
|
|
164
|
-
constructor(columnName) {
|
|
165
|
-
super();
|
|
166
|
-
this.columnName = columnName;
|
|
167
|
-
}
|
|
168
|
-
toJSON() {
|
|
169
|
-
return {
|
|
170
|
-
type: "col",
|
|
171
|
-
name: this.columnName,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
getAlias() {
|
|
175
|
-
return this._alias || this.columnName;
|
|
176
|
-
}
|
|
177
|
-
clone() {
|
|
178
|
-
const cloned = new ColumnExpressionImpl(this.columnName);
|
|
179
|
-
cloned._alias = this._alias;
|
|
180
|
-
return cloned;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Get the column name
|
|
184
|
-
*/
|
|
185
|
-
getColumnName() {
|
|
186
|
-
return this.columnName;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Helper function to coerce values to expressions
|
|
191
|
-
*/
|
|
178
|
+
* Helper function to coerce values to expressions
|
|
179
|
+
*/
|
|
192
180
|
function coerceToExpression(value) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return new LiteralExpressionImpl(value);
|
|
197
|
-
}
|
|
198
|
-
class MinMaxExpressionImpl extends ExpressionImpl {
|
|
199
|
-
op;
|
|
200
|
-
ops;
|
|
201
|
-
constructor(op, ops) {
|
|
202
|
-
super();
|
|
203
|
-
this.op = op;
|
|
204
|
-
this.ops = ops;
|
|
205
|
-
}
|
|
206
|
-
toJSON() {
|
|
207
|
-
return {
|
|
208
|
-
type: this.op,
|
|
209
|
-
operands: this.ops.map((o) => o.toJSON()),
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
getAlias() {
|
|
213
|
-
return this._alias || `${this.op}_${this.ops.map((o) => o.getAlias()).join("_")}`;
|
|
214
|
-
}
|
|
215
|
-
clone() {
|
|
216
|
-
const cloned = new MinMaxExpressionImpl(this.op, this.ops);
|
|
217
|
-
cloned._alias = this._alias;
|
|
218
|
-
return cloned;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
// Forward declarations for concrete expressionImpl classes
|
|
222
|
-
// These will be imported from their respective modules
|
|
223
|
-
class ArithmeticExpressionImpl extends ExpressionImpl {
|
|
224
|
-
operator;
|
|
225
|
-
lhs;
|
|
226
|
-
rhs;
|
|
227
|
-
constructor(operator, lhs, rhs) {
|
|
228
|
-
super();
|
|
229
|
-
this.operator = operator;
|
|
230
|
-
this.lhs = lhs;
|
|
231
|
-
this.rhs = rhs;
|
|
232
|
-
}
|
|
233
|
-
toJSON() {
|
|
234
|
-
return {
|
|
235
|
-
type: this.operator,
|
|
236
|
-
lhs: this.lhs.toJSON(),
|
|
237
|
-
rhs: this.rhs.toJSON(),
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
getAlias() {
|
|
241
|
-
return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;
|
|
242
|
-
}
|
|
243
|
-
clone() {
|
|
244
|
-
const cloned = new ArithmeticExpressionImpl(this.operator, this.lhs, this.rhs);
|
|
245
|
-
cloned._alias = this._alias;
|
|
246
|
-
return cloned;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
class ComparisonExpressionImpl extends ExpressionImpl {
|
|
250
|
-
operator;
|
|
251
|
-
lhs;
|
|
252
|
-
rhs;
|
|
253
|
-
constructor(operator, lhs, rhs) {
|
|
254
|
-
super();
|
|
255
|
-
this.operator = operator;
|
|
256
|
-
this.lhs = lhs;
|
|
257
|
-
this.rhs = rhs;
|
|
258
|
-
}
|
|
259
|
-
toJSON() {
|
|
260
|
-
return {
|
|
261
|
-
type: this.operator,
|
|
262
|
-
lhs: this.lhs.toJSON(),
|
|
263
|
-
rhs: this.rhs.toJSON(),
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
getAlias() {
|
|
267
|
-
return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;
|
|
268
|
-
}
|
|
269
|
-
clone() {
|
|
270
|
-
const cloned = new ComparisonExpressionImpl(this.operator, this.lhs, this.rhs);
|
|
271
|
-
cloned._alias = this._alias;
|
|
272
|
-
return cloned;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
class LogicalExpressionImpl extends ExpressionImpl {
|
|
276
|
-
operator;
|
|
277
|
-
operands;
|
|
278
|
-
constructor(operator, operands) {
|
|
279
|
-
super();
|
|
280
|
-
this.operator = operator;
|
|
281
|
-
this.operands = operands;
|
|
282
|
-
}
|
|
283
|
-
toJSON() {
|
|
284
|
-
if (this.operator === "not") {
|
|
285
|
-
return {
|
|
286
|
-
type: "not",
|
|
287
|
-
value: this.operands[0].toJSON(),
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
return {
|
|
291
|
-
type: this.operator,
|
|
292
|
-
operands: this.operands.map((op) => op.toJSON()),
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
getAlias() {
|
|
296
|
-
if (this._alias)
|
|
297
|
-
return this._alias;
|
|
298
|
-
if (this.operator === "not") {
|
|
299
|
-
return `not_${this.operands[0].getAlias()}`;
|
|
300
|
-
}
|
|
301
|
-
return this.operands.map((op) => op.getAlias()).join(`_${this.operator}_`);
|
|
302
|
-
}
|
|
303
|
-
clone() {
|
|
304
|
-
const cloned = new LogicalExpressionImpl(this.operator, this.operands);
|
|
305
|
-
cloned._alias = this._alias;
|
|
306
|
-
return cloned;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
class UnaryArithmeticExpressionImpl extends ExpressionImpl {
|
|
310
|
-
operator;
|
|
311
|
-
value;
|
|
312
|
-
constructor(operator, value) {
|
|
313
|
-
super();
|
|
314
|
-
this.operator = operator;
|
|
315
|
-
this.value = value;
|
|
316
|
-
}
|
|
317
|
-
toJSON() {
|
|
318
|
-
return {
|
|
319
|
-
type: this.operator,
|
|
320
|
-
value: this.value.toJSON(),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
getAlias() {
|
|
324
|
-
return this._alias || `${this.operator}_${this.value.getAlias()}`;
|
|
325
|
-
}
|
|
326
|
-
clone() {
|
|
327
|
-
const cloned = new UnaryArithmeticExpressionImpl(this.operator, this.value);
|
|
328
|
-
cloned._alias = this._alias;
|
|
329
|
-
return cloned;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
class NullCheckExpressionImpl extends ExpressionImpl {
|
|
333
|
-
operator;
|
|
334
|
-
value;
|
|
335
|
-
constructor(operator, value) {
|
|
336
|
-
super();
|
|
337
|
-
this.operator = operator;
|
|
338
|
-
this.value = value;
|
|
339
|
-
}
|
|
340
|
-
toJSON() {
|
|
341
|
-
return {
|
|
342
|
-
type: this.operator,
|
|
343
|
-
value: this.value.toJSON(),
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
getAlias() {
|
|
347
|
-
return this._alias || `${this.value.getAlias()}_${this.operator}`;
|
|
348
|
-
}
|
|
349
|
-
clone() {
|
|
350
|
-
const cloned = new NullCheckExpressionImpl(this.operator, this.value);
|
|
351
|
-
cloned._alias = this._alias;
|
|
352
|
-
return cloned;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
class LiteralExpressionImpl extends ExpressionImpl {
|
|
356
|
-
value;
|
|
357
|
-
constructor(value) {
|
|
358
|
-
super();
|
|
359
|
-
this.value = value;
|
|
360
|
-
}
|
|
361
|
-
toJSON() {
|
|
362
|
-
return {
|
|
363
|
-
type: "const",
|
|
364
|
-
value: this.value,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
getAlias() {
|
|
368
|
-
return this._alias || this.generateDefaultAlias();
|
|
369
|
-
}
|
|
370
|
-
clone() {
|
|
371
|
-
const cloned = new LiteralExpressionImpl(this.value);
|
|
372
|
-
cloned._alias = this._alias;
|
|
373
|
-
return cloned;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Get the literal value
|
|
377
|
-
*/
|
|
378
|
-
getValue() {
|
|
379
|
-
return this.value;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Generate a default alias based on the value
|
|
383
|
-
*/
|
|
384
|
-
generateDefaultAlias() {
|
|
385
|
-
if (this.value === null || this.value === undefined) {
|
|
386
|
-
return "null";
|
|
387
|
-
}
|
|
388
|
-
if (typeof this.value === "string") {
|
|
389
|
-
// For string values, truncate if too long and make safe for column names
|
|
390
|
-
const safe = this.value.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
391
|
-
return safe.length > 20 ? safe.substring(0, 17) + "..." : safe;
|
|
392
|
-
}
|
|
393
|
-
if (typeof this.value === "boolean") {
|
|
394
|
-
return this.value ? "true" : "false";
|
|
395
|
-
}
|
|
396
|
-
if (typeof this.value === "number") {
|
|
397
|
-
return String(this.value);
|
|
398
|
-
}
|
|
399
|
-
if (Array.isArray(this.value)) {
|
|
400
|
-
return "array";
|
|
401
|
-
}
|
|
402
|
-
if (typeof this.value === "object") {
|
|
403
|
-
return "object";
|
|
404
|
-
}
|
|
405
|
-
return "literal";
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
class FillNullExpressionImpl extends ExpressionImpl {
|
|
409
|
-
expr;
|
|
410
|
-
fillValue;
|
|
411
|
-
constructor(expr, fillValue) {
|
|
412
|
-
super();
|
|
413
|
-
this.expr = expr;
|
|
414
|
-
this.fillValue = fillValue;
|
|
415
|
-
}
|
|
416
|
-
toJSON() {
|
|
417
|
-
return {
|
|
418
|
-
type: "fill_null",
|
|
419
|
-
input: this.expr.toJSON(),
|
|
420
|
-
fillValue: this.fillValue.toJSON(),
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
getAlias() {
|
|
424
|
-
return this._alias || `${this.expr.getAlias()}_fill_null`;
|
|
425
|
-
}
|
|
426
|
-
clone() {
|
|
427
|
-
const cloned = new FillNullExpressionImpl(this.expr, this.fillValue);
|
|
428
|
-
cloned._alias = this._alias;
|
|
429
|
-
return cloned;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
class FillNaNExpressionImpl extends ExpressionImpl {
|
|
433
|
-
expr;
|
|
434
|
-
fillValue;
|
|
435
|
-
constructor(expr, fillValue) {
|
|
436
|
-
super();
|
|
437
|
-
this.expr = expr;
|
|
438
|
-
this.fillValue = fillValue;
|
|
439
|
-
}
|
|
440
|
-
toJSON() {
|
|
441
|
-
return {
|
|
442
|
-
type: "fill_nan",
|
|
443
|
-
input: this.expr.toJSON(),
|
|
444
|
-
fillValue: this.fillValue.toJSON(),
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
getAlias() {
|
|
448
|
-
return this._alias || `${this.expr.getAlias()}_fill_nan`;
|
|
449
|
-
}
|
|
450
|
-
clone() {
|
|
451
|
-
const cloned = new FillNaNExpressionImpl(this.expr, this.fillValue);
|
|
452
|
-
cloned._alias = this._alias;
|
|
453
|
-
return cloned;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
class StringConcatExpressionImpl extends ExpressionImpl {
|
|
457
|
-
operands;
|
|
458
|
-
delimiter;
|
|
459
|
-
constructor(operands, delimiter = "") {
|
|
460
|
-
super();
|
|
461
|
-
this.operands = operands;
|
|
462
|
-
this.delimiter = delimiter;
|
|
463
|
-
}
|
|
464
|
-
toJSON() {
|
|
465
|
-
return {
|
|
466
|
-
type: "str_join",
|
|
467
|
-
operands: this.operands.map((o) => o.toJSON()),
|
|
468
|
-
delimiter: this.delimiter,
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
getAlias() {
|
|
472
|
-
return this._alias || this.operands.map((o) => o.getAlias()).join("_");
|
|
473
|
-
}
|
|
474
|
-
clone() {
|
|
475
|
-
const cloned = new StringConcatExpressionImpl(this.operands);
|
|
476
|
-
cloned._alias = this._alias;
|
|
477
|
-
return cloned;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
class SubstringExpressionImpl extends ExpressionImpl {
|
|
481
|
-
expr;
|
|
482
|
-
start;
|
|
483
|
-
length;
|
|
484
|
-
constructor(expr, start, length) {
|
|
485
|
-
super();
|
|
486
|
-
this.expr = expr;
|
|
487
|
-
this.start = start;
|
|
488
|
-
this.length = length;
|
|
489
|
-
}
|
|
490
|
-
toJSON() {
|
|
491
|
-
return {
|
|
492
|
-
type: "substring",
|
|
493
|
-
value: this.expr.toJSON(),
|
|
494
|
-
start: { type: "const", value: this.start },
|
|
495
|
-
length: this.length !== undefined ? { type: "const", value: this.length } : undefined,
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
getAlias() {
|
|
499
|
-
return this._alias || `${this.expr.getAlias()}_substring`;
|
|
500
|
-
}
|
|
501
|
-
clone() {
|
|
502
|
-
const cloned = new SubstringExpressionImpl(this.expr, this.start, this.length);
|
|
503
|
-
cloned._alias = this._alias;
|
|
504
|
-
return cloned;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
class StringReplaceExpressionImpl extends ExpressionImpl {
|
|
508
|
-
expr;
|
|
509
|
-
pattern;
|
|
510
|
-
value;
|
|
511
|
-
options;
|
|
512
|
-
constructor(expr, pattern, value, options) {
|
|
513
|
-
super();
|
|
514
|
-
this.expr = expr;
|
|
515
|
-
this.pattern = pattern;
|
|
516
|
-
this.value = value;
|
|
517
|
-
this.options = options;
|
|
518
|
-
}
|
|
519
|
-
toJSON() {
|
|
520
|
-
return {
|
|
521
|
-
type: "str_replace",
|
|
522
|
-
value: this.expr.toJSON(),
|
|
523
|
-
pattern: this.pattern,
|
|
524
|
-
replacement: this.value,
|
|
525
|
-
replaceAll: this.options?.replaceAll || false,
|
|
526
|
-
literal: this.options?.literal || false,
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
getAlias() {
|
|
530
|
-
return this._alias || `${this.expr.getAlias()}_replace`;
|
|
531
|
-
}
|
|
532
|
-
clone() {
|
|
533
|
-
const cloned = new StringReplaceExpressionImpl(this.expr, this.pattern, this.value, this.options);
|
|
534
|
-
cloned._alias = this._alias;
|
|
535
|
-
return cloned;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
class StringContainsExpressionImpl extends ExpressionImpl {
|
|
539
|
-
expr;
|
|
540
|
-
pattern;
|
|
541
|
-
literal;
|
|
542
|
-
strict;
|
|
543
|
-
constructor(expr, pattern, literal, strict) {
|
|
544
|
-
super();
|
|
545
|
-
this.expr = expr;
|
|
546
|
-
this.pattern = pattern;
|
|
547
|
-
this.literal = literal;
|
|
548
|
-
this.strict = strict;
|
|
549
|
-
}
|
|
550
|
-
toJSON() {
|
|
551
|
-
return {
|
|
552
|
-
type: "str_contains",
|
|
553
|
-
value: this.expr.toJSON(),
|
|
554
|
-
pattern: this.pattern.toJSON(),
|
|
555
|
-
literal: this.literal || false,
|
|
556
|
-
strict: this.strict !== undefined ? this.strict : true,
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
getAlias() {
|
|
560
|
-
return this._alias || `${this.expr.getAlias()}_contains`;
|
|
561
|
-
}
|
|
562
|
-
clone() {
|
|
563
|
-
const cloned = new StringContainsExpressionImpl(this.expr, this.pattern, this.literal, this.strict);
|
|
564
|
-
cloned._alias = this._alias;
|
|
565
|
-
return cloned;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
class StringCaseExpressionImpl extends ExpressionImpl {
|
|
569
|
-
operation;
|
|
570
|
-
expr;
|
|
571
|
-
constructor(operation, expr) {
|
|
572
|
-
super();
|
|
573
|
-
this.operation = operation;
|
|
574
|
-
this.expr = expr;
|
|
575
|
-
}
|
|
576
|
-
toJSON() {
|
|
577
|
-
return {
|
|
578
|
-
type: this.operation,
|
|
579
|
-
value: this.expr.toJSON(),
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
getAlias() {
|
|
583
|
-
return this._alias || `${this.expr.getAlias()}_${this.operation}`;
|
|
584
|
-
}
|
|
585
|
-
clone() {
|
|
586
|
-
const cloned = new StringCaseExpressionImpl(this.operation, this.expr);
|
|
587
|
-
cloned._alias = this._alias;
|
|
588
|
-
return cloned;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
class StringStartsWithExpressionImpl extends ExpressionImpl {
|
|
592
|
-
expr;
|
|
593
|
-
pattern;
|
|
594
|
-
constructor(expr, pattern) {
|
|
595
|
-
super();
|
|
596
|
-
this.expr = expr;
|
|
597
|
-
this.pattern = pattern;
|
|
598
|
-
}
|
|
599
|
-
toJSON() {
|
|
600
|
-
return {
|
|
601
|
-
type: "str_starts_with",
|
|
602
|
-
value: this.expr.toJSON(),
|
|
603
|
-
prefix: this.pattern.toJSON(),
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
getAlias() {
|
|
607
|
-
return this._alias || `${this.expr.getAlias()}_starts_with`;
|
|
608
|
-
}
|
|
609
|
-
clone() {
|
|
610
|
-
const cloned = new StringStartsWithExpressionImpl(this.expr, this.pattern);
|
|
611
|
-
cloned._alias = this._alias;
|
|
612
|
-
return cloned;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
class StringEndsWithExpressionImpl extends ExpressionImpl {
|
|
616
|
-
expr;
|
|
617
|
-
pattern;
|
|
618
|
-
constructor(expr, pattern) {
|
|
619
|
-
super();
|
|
620
|
-
this.expr = expr;
|
|
621
|
-
this.pattern = pattern;
|
|
622
|
-
}
|
|
623
|
-
toJSON() {
|
|
624
|
-
return {
|
|
625
|
-
type: "str_ends_with",
|
|
626
|
-
value: this.expr.toJSON(),
|
|
627
|
-
suffix: this.pattern.toJSON(),
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
getAlias() {
|
|
631
|
-
return this._alias || `${this.expr.getAlias()}_ends_with`;
|
|
632
|
-
}
|
|
633
|
-
clone() {
|
|
634
|
-
const cloned = new StringEndsWithExpressionImpl(this.expr, this.pattern);
|
|
635
|
-
cloned._alias = this._alias;
|
|
636
|
-
return cloned;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
class CumsumExpressionImpl extends ExpressionImpl {
|
|
640
|
-
value;
|
|
641
|
-
additionalOrderBy;
|
|
642
|
-
partitionBy;
|
|
643
|
-
descending;
|
|
644
|
-
constructor(value, additionalOrderBy = [], partitionBy = [], descending) {
|
|
645
|
-
super();
|
|
646
|
-
this.value = value;
|
|
647
|
-
this.additionalOrderBy = additionalOrderBy;
|
|
648
|
-
this.partitionBy = partitionBy;
|
|
649
|
-
this.descending = descending;
|
|
650
|
-
}
|
|
651
|
-
toJSON() {
|
|
652
|
-
return {
|
|
653
|
-
type: "cumsum",
|
|
654
|
-
value: this.value.toJSON(),
|
|
655
|
-
additionalOrderBy: this.additionalOrderBy.map((expr) => expr.toJSON()),
|
|
656
|
-
partitionBy: this.partitionBy.map((expr) => expr.toJSON()),
|
|
657
|
-
descending: this.descending,
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
getAlias() {
|
|
661
|
-
return this._alias || `cumsum_${this.value.getAlias()}`;
|
|
662
|
-
}
|
|
663
|
-
clone() {
|
|
664
|
-
const cloned = new CumsumExpressionImpl(this.value, this.additionalOrderBy, this.partitionBy, this.descending);
|
|
665
|
-
cloned._alias = this._alias;
|
|
666
|
-
return cloned;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
class AggregationExpressionImpl extends ExpressionImpl {
|
|
670
|
-
operation;
|
|
671
|
-
expr;
|
|
672
|
-
constructor(operation, expr) {
|
|
673
|
-
super();
|
|
674
|
-
this.operation = operation;
|
|
675
|
-
this.expr = expr;
|
|
676
|
-
}
|
|
677
|
-
toJSON() {
|
|
678
|
-
return {
|
|
679
|
-
type: "aggregate",
|
|
680
|
-
aggregation: this.operation,
|
|
681
|
-
value: this.expr?.toJSON() || { type: "const", value: 1 },
|
|
682
|
-
partitionBy: [],
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
getAlias() {
|
|
686
|
-
return this._alias || `${this.operation}${this.expr ? "_" + this.expr.getAlias() : ""}`;
|
|
687
|
-
}
|
|
688
|
-
clone() {
|
|
689
|
-
const cloned = new AggregationExpressionImpl(this.operation, this.expr);
|
|
690
|
-
cloned._alias = this._alias;
|
|
691
|
-
return cloned;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
class WindowExpressionImpl extends ExpressionImpl {
|
|
695
|
-
expr;
|
|
696
|
-
aggregation;
|
|
697
|
-
partitionBy;
|
|
698
|
-
constructor(expr, aggregation, partitionBy) {
|
|
699
|
-
super();
|
|
700
|
-
this.expr = expr;
|
|
701
|
-
this.aggregation = aggregation;
|
|
702
|
-
this.partitionBy = partitionBy;
|
|
703
|
-
}
|
|
704
|
-
toJSON() {
|
|
705
|
-
return {
|
|
706
|
-
type: "aggregate",
|
|
707
|
-
aggregation: this.aggregation,
|
|
708
|
-
value: this.expr.toJSON(),
|
|
709
|
-
partitionBy: this.partitionBy.map((expr) => expr.toJSON()),
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
getAlias() {
|
|
713
|
-
return this._alias || `${this.expr.getAlias()}_window`;
|
|
714
|
-
}
|
|
715
|
-
clone() {
|
|
716
|
-
const cloned = new WindowExpressionImpl(this.expr, this.aggregation, this.partitionBy);
|
|
717
|
-
cloned._alias = this._alias;
|
|
718
|
-
return cloned;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
class StringDistanceExpressionImpl extends ExpressionImpl {
|
|
722
|
-
string1;
|
|
723
|
-
string2;
|
|
724
|
-
metric;
|
|
725
|
-
returnSimilarity;
|
|
726
|
-
constructor(string1, string2, metric, returnSimilarity) {
|
|
727
|
-
super();
|
|
728
|
-
this.string1 = string1;
|
|
729
|
-
this.string2 = string2;
|
|
730
|
-
this.metric = metric;
|
|
731
|
-
this.returnSimilarity = returnSimilarity;
|
|
732
|
-
}
|
|
733
|
-
toJSON() {
|
|
734
|
-
return {
|
|
735
|
-
type: "string_distance",
|
|
736
|
-
metric: this.metric,
|
|
737
|
-
string1: this.string1.toJSON(),
|
|
738
|
-
string2: this.string2.toJSON(),
|
|
739
|
-
returnSimilarity: this.returnSimilarity || false,
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
getAlias() {
|
|
743
|
-
return this._alias || `${this.string1.getAlias()}_distance_${this.string2.getAlias()}`;
|
|
744
|
-
}
|
|
745
|
-
clone() {
|
|
746
|
-
const cloned = new StringDistanceExpressionImpl(this.string1, this.string2, this.metric, this.returnSimilarity);
|
|
747
|
-
cloned._alias = this._alias;
|
|
748
|
-
return cloned;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
class FuzzyStringFilterExpressionImpl extends ExpressionImpl {
|
|
752
|
-
expr;
|
|
753
|
-
pattern;
|
|
754
|
-
metric;
|
|
755
|
-
bound;
|
|
756
|
-
constructor(expr, pattern, metric, bound) {
|
|
757
|
-
super();
|
|
758
|
-
this.expr = expr;
|
|
759
|
-
this.pattern = pattern;
|
|
760
|
-
this.metric = metric;
|
|
761
|
-
this.bound = bound;
|
|
762
|
-
}
|
|
763
|
-
toJSON() {
|
|
764
|
-
return {
|
|
765
|
-
type: "fuzzy_string_filter",
|
|
766
|
-
metric: this.metric,
|
|
767
|
-
value: this.expr.toJSON(),
|
|
768
|
-
pattern: this.pattern.toJSON(),
|
|
769
|
-
bound: this.bound,
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
getAlias() {
|
|
773
|
-
return this._alias || `${this.expr.getAlias()}_fuzzy_filter`;
|
|
774
|
-
}
|
|
775
|
-
clone() {
|
|
776
|
-
const cloned = new FuzzyStringFilterExpressionImpl(this.expr, this.pattern, this.metric, this.bound);
|
|
777
|
-
cloned._alias = this._alias;
|
|
778
|
-
return cloned;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
class RankExpressionImpl extends ExpressionImpl {
|
|
782
|
-
orderBy;
|
|
783
|
-
partitionBy;
|
|
784
|
-
descending;
|
|
785
|
-
constructor(orderBy, partitionBy, descending) {
|
|
786
|
-
super();
|
|
787
|
-
this.orderBy = orderBy;
|
|
788
|
-
this.partitionBy = partitionBy;
|
|
789
|
-
this.descending = descending;
|
|
790
|
-
}
|
|
791
|
-
toJSON() {
|
|
792
|
-
return {
|
|
793
|
-
type: "rank",
|
|
794
|
-
orderBy: this.orderBy.map((e) => e.toJSON()),
|
|
795
|
-
partitionBy: this.partitionBy.map((e) => e.toJSON()),
|
|
796
|
-
descending: this.descending || undefined,
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
getAlias() {
|
|
800
|
-
const order = this.orderBy.map((e) => e.getAlias()).join("_");
|
|
801
|
-
const part = this.partitionBy.map((e) => e.getAlias()).join("_");
|
|
802
|
-
const dir = this.descending ? "desc" : "asc";
|
|
803
|
-
return this._alias || `rank_${order}${part ? `_over_${part}` : ""}_${dir}`;
|
|
804
|
-
}
|
|
805
|
-
clone() {
|
|
806
|
-
const cloned = new RankExpressionImpl(this.orderBy, this.partitionBy, this.descending);
|
|
807
|
-
cloned._alias = this._alias;
|
|
808
|
-
return cloned;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
class WhenThenOtherwiseExpressionImpl extends ExpressionImpl {
|
|
812
|
-
conditions;
|
|
813
|
-
otherwiseValue;
|
|
814
|
-
constructor(conditions, otherwiseValue) {
|
|
815
|
-
super();
|
|
816
|
-
this.conditions = conditions;
|
|
817
|
-
this.otherwiseValue = otherwiseValue;
|
|
818
|
-
}
|
|
819
|
-
toJSON() {
|
|
820
|
-
return {
|
|
821
|
-
type: "when_then_otherwise",
|
|
822
|
-
conditions: this.conditions.map((clause) => ({
|
|
823
|
-
when: clause.when.toJSON(),
|
|
824
|
-
then: clause.then.toJSON(),
|
|
825
|
-
})),
|
|
826
|
-
otherwise: this.otherwiseValue.toJSON(),
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
getAlias() {
|
|
830
|
-
return this._alias || "conditional";
|
|
831
|
-
}
|
|
832
|
-
clone() {
|
|
833
|
-
const cloned = new WhenThenOtherwiseExpressionImpl(this.conditions, this.otherwiseValue);
|
|
834
|
-
cloned._alias = this._alias;
|
|
835
|
-
return cloned;
|
|
836
|
-
}
|
|
181
|
+
if (value instanceof ExpressionImpl) return value;
|
|
182
|
+
return new LiteralExpressionImpl(value);
|
|
837
183
|
}
|
|
184
|
+
var MinMaxExpressionImpl = class MinMaxExpressionImpl extends ExpressionImpl {
|
|
185
|
+
constructor(op, ops) {
|
|
186
|
+
super();
|
|
187
|
+
this.op = op;
|
|
188
|
+
this.ops = ops;
|
|
189
|
+
}
|
|
190
|
+
toJSON() {
|
|
191
|
+
return {
|
|
192
|
+
type: this.op,
|
|
193
|
+
operands: this.ops.map((o) => o.toJSON())
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
getAlias() {
|
|
197
|
+
return this._alias || `${this.op}_${this.ops.map((o) => o.getAlias()).join("_")}`;
|
|
198
|
+
}
|
|
199
|
+
clone() {
|
|
200
|
+
const cloned = new MinMaxExpressionImpl(this.op, this.ops);
|
|
201
|
+
cloned._alias = this._alias;
|
|
202
|
+
return cloned;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
var ArithmeticExpressionImpl = class ArithmeticExpressionImpl extends ExpressionImpl {
|
|
206
|
+
constructor(operator, lhs, rhs) {
|
|
207
|
+
super();
|
|
208
|
+
this.operator = operator;
|
|
209
|
+
this.lhs = lhs;
|
|
210
|
+
this.rhs = rhs;
|
|
211
|
+
}
|
|
212
|
+
toJSON() {
|
|
213
|
+
return {
|
|
214
|
+
type: this.operator,
|
|
215
|
+
lhs: this.lhs.toJSON(),
|
|
216
|
+
rhs: this.rhs.toJSON()
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
getAlias() {
|
|
220
|
+
return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;
|
|
221
|
+
}
|
|
222
|
+
clone() {
|
|
223
|
+
const cloned = new ArithmeticExpressionImpl(this.operator, this.lhs, this.rhs);
|
|
224
|
+
cloned._alias = this._alias;
|
|
225
|
+
return cloned;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
var ComparisonExpressionImpl = class ComparisonExpressionImpl extends ExpressionImpl {
|
|
229
|
+
constructor(operator, lhs, rhs) {
|
|
230
|
+
super();
|
|
231
|
+
this.operator = operator;
|
|
232
|
+
this.lhs = lhs;
|
|
233
|
+
this.rhs = rhs;
|
|
234
|
+
}
|
|
235
|
+
toJSON() {
|
|
236
|
+
return {
|
|
237
|
+
type: this.operator,
|
|
238
|
+
lhs: this.lhs.toJSON(),
|
|
239
|
+
rhs: this.rhs.toJSON()
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
getAlias() {
|
|
243
|
+
return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;
|
|
244
|
+
}
|
|
245
|
+
clone() {
|
|
246
|
+
const cloned = new ComparisonExpressionImpl(this.operator, this.lhs, this.rhs);
|
|
247
|
+
cloned._alias = this._alias;
|
|
248
|
+
return cloned;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var LogicalExpressionImpl = class LogicalExpressionImpl extends ExpressionImpl {
|
|
252
|
+
constructor(operator, operands) {
|
|
253
|
+
super();
|
|
254
|
+
this.operator = operator;
|
|
255
|
+
this.operands = operands;
|
|
256
|
+
}
|
|
257
|
+
toJSON() {
|
|
258
|
+
if (this.operator === "not") return {
|
|
259
|
+
type: "not",
|
|
260
|
+
value: this.operands[0].toJSON()
|
|
261
|
+
};
|
|
262
|
+
return {
|
|
263
|
+
type: this.operator,
|
|
264
|
+
operands: this.operands.map((op) => op.toJSON())
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
getAlias() {
|
|
268
|
+
if (this._alias) return this._alias;
|
|
269
|
+
if (this.operator === "not") return `not_${this.operands[0].getAlias()}`;
|
|
270
|
+
return this.operands.map((op) => op.getAlias()).join(`_${this.operator}_`);
|
|
271
|
+
}
|
|
272
|
+
clone() {
|
|
273
|
+
const cloned = new LogicalExpressionImpl(this.operator, this.operands);
|
|
274
|
+
cloned._alias = this._alias;
|
|
275
|
+
return cloned;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
var UnaryArithmeticExpressionImpl = class UnaryArithmeticExpressionImpl extends ExpressionImpl {
|
|
279
|
+
constructor(operator, value) {
|
|
280
|
+
super();
|
|
281
|
+
this.operator = operator;
|
|
282
|
+
this.value = value;
|
|
283
|
+
}
|
|
284
|
+
toJSON() {
|
|
285
|
+
return {
|
|
286
|
+
type: this.operator,
|
|
287
|
+
value: this.value.toJSON()
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
getAlias() {
|
|
291
|
+
return this._alias || `${this.operator}_${this.value.getAlias()}`;
|
|
292
|
+
}
|
|
293
|
+
clone() {
|
|
294
|
+
const cloned = new UnaryArithmeticExpressionImpl(this.operator, this.value);
|
|
295
|
+
cloned._alias = this._alias;
|
|
296
|
+
return cloned;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var NullCheckExpressionImpl = class NullCheckExpressionImpl extends ExpressionImpl {
|
|
300
|
+
constructor(operator, value) {
|
|
301
|
+
super();
|
|
302
|
+
this.operator = operator;
|
|
303
|
+
this.value = value;
|
|
304
|
+
}
|
|
305
|
+
toJSON() {
|
|
306
|
+
return {
|
|
307
|
+
type: this.operator,
|
|
308
|
+
value: this.value.toJSON()
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
getAlias() {
|
|
312
|
+
return this._alias || `${this.value.getAlias()}_${this.operator}`;
|
|
313
|
+
}
|
|
314
|
+
clone() {
|
|
315
|
+
const cloned = new NullCheckExpressionImpl(this.operator, this.value);
|
|
316
|
+
cloned._alias = this._alias;
|
|
317
|
+
return cloned;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var LiteralExpressionImpl = class LiteralExpressionImpl extends ExpressionImpl {
|
|
321
|
+
constructor(value) {
|
|
322
|
+
super();
|
|
323
|
+
this.value = value;
|
|
324
|
+
}
|
|
325
|
+
toJSON() {
|
|
326
|
+
return {
|
|
327
|
+
type: "const",
|
|
328
|
+
value: this.value
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
getAlias() {
|
|
332
|
+
return this._alias || this.generateDefaultAlias();
|
|
333
|
+
}
|
|
334
|
+
clone() {
|
|
335
|
+
const cloned = new LiteralExpressionImpl(this.value);
|
|
336
|
+
cloned._alias = this._alias;
|
|
337
|
+
return cloned;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get the literal value
|
|
341
|
+
*/
|
|
342
|
+
getValue() {
|
|
343
|
+
return this.value;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Generate a default alias based on the value
|
|
347
|
+
*/
|
|
348
|
+
generateDefaultAlias() {
|
|
349
|
+
if (this.value === null || this.value === void 0) return "null";
|
|
350
|
+
if (typeof this.value === "string") {
|
|
351
|
+
const safe = this.value.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
352
|
+
return safe.length > 20 ? safe.substring(0, 17) + "..." : safe;
|
|
353
|
+
}
|
|
354
|
+
if (typeof this.value === "boolean") return this.value ? "true" : "false";
|
|
355
|
+
if (typeof this.value === "number") return String(this.value);
|
|
356
|
+
if (Array.isArray(this.value)) return "array";
|
|
357
|
+
if (typeof this.value === "object") return "object";
|
|
358
|
+
return "literal";
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var FillNullExpressionImpl = class FillNullExpressionImpl extends ExpressionImpl {
|
|
362
|
+
constructor(expr, fillValue) {
|
|
363
|
+
super();
|
|
364
|
+
this.expr = expr;
|
|
365
|
+
this.fillValue = fillValue;
|
|
366
|
+
}
|
|
367
|
+
toJSON() {
|
|
368
|
+
return {
|
|
369
|
+
type: "fill_null",
|
|
370
|
+
input: this.expr.toJSON(),
|
|
371
|
+
fillValue: this.fillValue.toJSON()
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
getAlias() {
|
|
375
|
+
return this._alias || `${this.expr.getAlias()}_fill_null`;
|
|
376
|
+
}
|
|
377
|
+
clone() {
|
|
378
|
+
const cloned = new FillNullExpressionImpl(this.expr, this.fillValue);
|
|
379
|
+
cloned._alias = this._alias;
|
|
380
|
+
return cloned;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
var FillNaNExpressionImpl = class FillNaNExpressionImpl extends ExpressionImpl {
|
|
384
|
+
constructor(expr, fillValue) {
|
|
385
|
+
super();
|
|
386
|
+
this.expr = expr;
|
|
387
|
+
this.fillValue = fillValue;
|
|
388
|
+
}
|
|
389
|
+
toJSON() {
|
|
390
|
+
return {
|
|
391
|
+
type: "fill_nan",
|
|
392
|
+
input: this.expr.toJSON(),
|
|
393
|
+
fillValue: this.fillValue.toJSON()
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
getAlias() {
|
|
397
|
+
return this._alias || `${this.expr.getAlias()}_fill_nan`;
|
|
398
|
+
}
|
|
399
|
+
clone() {
|
|
400
|
+
const cloned = new FillNaNExpressionImpl(this.expr, this.fillValue);
|
|
401
|
+
cloned._alias = this._alias;
|
|
402
|
+
return cloned;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
var StringConcatExpressionImpl = class StringConcatExpressionImpl extends ExpressionImpl {
|
|
406
|
+
constructor(operands, delimiter = "") {
|
|
407
|
+
super();
|
|
408
|
+
this.operands = operands;
|
|
409
|
+
this.delimiter = delimiter;
|
|
410
|
+
}
|
|
411
|
+
toJSON() {
|
|
412
|
+
return {
|
|
413
|
+
type: "str_join",
|
|
414
|
+
operands: this.operands.map((o) => o.toJSON()),
|
|
415
|
+
delimiter: this.delimiter
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
getAlias() {
|
|
419
|
+
return this._alias || this.operands.map((o) => o.getAlias()).join("_");
|
|
420
|
+
}
|
|
421
|
+
clone() {
|
|
422
|
+
const cloned = new StringConcatExpressionImpl(this.operands);
|
|
423
|
+
cloned._alias = this._alias;
|
|
424
|
+
return cloned;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var SubstringExpressionImpl = class SubstringExpressionImpl extends ExpressionImpl {
|
|
428
|
+
constructor(expr, start, length) {
|
|
429
|
+
super();
|
|
430
|
+
this.expr = expr;
|
|
431
|
+
this.start = start;
|
|
432
|
+
this.length = length;
|
|
433
|
+
}
|
|
434
|
+
toJSON() {
|
|
435
|
+
return {
|
|
436
|
+
type: "substring",
|
|
437
|
+
value: this.expr.toJSON(),
|
|
438
|
+
start: {
|
|
439
|
+
type: "const",
|
|
440
|
+
value: this.start
|
|
441
|
+
},
|
|
442
|
+
length: this.length !== void 0 ? {
|
|
443
|
+
type: "const",
|
|
444
|
+
value: this.length
|
|
445
|
+
} : void 0
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
getAlias() {
|
|
449
|
+
return this._alias || `${this.expr.getAlias()}_substring`;
|
|
450
|
+
}
|
|
451
|
+
clone() {
|
|
452
|
+
const cloned = new SubstringExpressionImpl(this.expr, this.start, this.length);
|
|
453
|
+
cloned._alias = this._alias;
|
|
454
|
+
return cloned;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var StringReplaceExpressionImpl = class StringReplaceExpressionImpl extends ExpressionImpl {
|
|
458
|
+
constructor(expr, pattern, value, options) {
|
|
459
|
+
super();
|
|
460
|
+
this.expr = expr;
|
|
461
|
+
this.pattern = pattern;
|
|
462
|
+
this.value = value;
|
|
463
|
+
this.options = options;
|
|
464
|
+
}
|
|
465
|
+
toJSON() {
|
|
466
|
+
return {
|
|
467
|
+
type: "str_replace",
|
|
468
|
+
value: this.expr.toJSON(),
|
|
469
|
+
pattern: this.pattern,
|
|
470
|
+
replacement: this.value,
|
|
471
|
+
replaceAll: this.options?.replaceAll || false,
|
|
472
|
+
literal: this.options?.literal || false
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
getAlias() {
|
|
476
|
+
return this._alias || `${this.expr.getAlias()}_replace`;
|
|
477
|
+
}
|
|
478
|
+
clone() {
|
|
479
|
+
const cloned = new StringReplaceExpressionImpl(this.expr, this.pattern, this.value, this.options);
|
|
480
|
+
cloned._alias = this._alias;
|
|
481
|
+
return cloned;
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
var StringContainsExpressionImpl = class StringContainsExpressionImpl extends ExpressionImpl {
|
|
485
|
+
constructor(expr, pattern, literal, strict) {
|
|
486
|
+
super();
|
|
487
|
+
this.expr = expr;
|
|
488
|
+
this.pattern = pattern;
|
|
489
|
+
this.literal = literal;
|
|
490
|
+
this.strict = strict;
|
|
491
|
+
}
|
|
492
|
+
toJSON() {
|
|
493
|
+
return {
|
|
494
|
+
type: "str_contains",
|
|
495
|
+
value: this.expr.toJSON(),
|
|
496
|
+
pattern: this.pattern.toJSON(),
|
|
497
|
+
literal: this.literal || false,
|
|
498
|
+
strict: this.strict !== void 0 ? this.strict : true
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
getAlias() {
|
|
502
|
+
return this._alias || `${this.expr.getAlias()}_contains`;
|
|
503
|
+
}
|
|
504
|
+
clone() {
|
|
505
|
+
const cloned = new StringContainsExpressionImpl(this.expr, this.pattern, this.literal, this.strict);
|
|
506
|
+
cloned._alias = this._alias;
|
|
507
|
+
return cloned;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var StringCaseExpressionImpl = class StringCaseExpressionImpl extends ExpressionImpl {
|
|
511
|
+
constructor(operation, expr) {
|
|
512
|
+
super();
|
|
513
|
+
this.operation = operation;
|
|
514
|
+
this.expr = expr;
|
|
515
|
+
}
|
|
516
|
+
toJSON() {
|
|
517
|
+
return {
|
|
518
|
+
type: this.operation,
|
|
519
|
+
value: this.expr.toJSON()
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
getAlias() {
|
|
523
|
+
return this._alias || `${this.expr.getAlias()}_${this.operation}`;
|
|
524
|
+
}
|
|
525
|
+
clone() {
|
|
526
|
+
const cloned = new StringCaseExpressionImpl(this.operation, this.expr);
|
|
527
|
+
cloned._alias = this._alias;
|
|
528
|
+
return cloned;
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
var StringStartsWithExpressionImpl = class StringStartsWithExpressionImpl extends ExpressionImpl {
|
|
532
|
+
constructor(expr, pattern) {
|
|
533
|
+
super();
|
|
534
|
+
this.expr = expr;
|
|
535
|
+
this.pattern = pattern;
|
|
536
|
+
}
|
|
537
|
+
toJSON() {
|
|
538
|
+
return {
|
|
539
|
+
type: "str_starts_with",
|
|
540
|
+
value: this.expr.toJSON(),
|
|
541
|
+
prefix: this.pattern.toJSON()
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
getAlias() {
|
|
545
|
+
return this._alias || `${this.expr.getAlias()}_starts_with`;
|
|
546
|
+
}
|
|
547
|
+
clone() {
|
|
548
|
+
const cloned = new StringStartsWithExpressionImpl(this.expr, this.pattern);
|
|
549
|
+
cloned._alias = this._alias;
|
|
550
|
+
return cloned;
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
var StringEndsWithExpressionImpl = class StringEndsWithExpressionImpl extends ExpressionImpl {
|
|
554
|
+
constructor(expr, pattern) {
|
|
555
|
+
super();
|
|
556
|
+
this.expr = expr;
|
|
557
|
+
this.pattern = pattern;
|
|
558
|
+
}
|
|
559
|
+
toJSON() {
|
|
560
|
+
return {
|
|
561
|
+
type: "str_ends_with",
|
|
562
|
+
value: this.expr.toJSON(),
|
|
563
|
+
suffix: this.pattern.toJSON()
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
getAlias() {
|
|
567
|
+
return this._alias || `${this.expr.getAlias()}_ends_with`;
|
|
568
|
+
}
|
|
569
|
+
clone() {
|
|
570
|
+
const cloned = new StringEndsWithExpressionImpl(this.expr, this.pattern);
|
|
571
|
+
cloned._alias = this._alias;
|
|
572
|
+
return cloned;
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
var CumsumExpressionImpl = class CumsumExpressionImpl extends ExpressionImpl {
|
|
576
|
+
constructor(value, additionalOrderBy = [], partitionBy = [], descending) {
|
|
577
|
+
super();
|
|
578
|
+
this.value = value;
|
|
579
|
+
this.additionalOrderBy = additionalOrderBy;
|
|
580
|
+
this.partitionBy = partitionBy;
|
|
581
|
+
this.descending = descending;
|
|
582
|
+
}
|
|
583
|
+
toJSON() {
|
|
584
|
+
return {
|
|
585
|
+
type: "cumsum",
|
|
586
|
+
value: this.value.toJSON(),
|
|
587
|
+
additionalOrderBy: this.additionalOrderBy.map((expr) => expr.toJSON()),
|
|
588
|
+
partitionBy: this.partitionBy.map((expr) => expr.toJSON()),
|
|
589
|
+
descending: this.descending
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
getAlias() {
|
|
593
|
+
return this._alias || `cumsum_${this.value.getAlias()}`;
|
|
594
|
+
}
|
|
595
|
+
clone() {
|
|
596
|
+
const cloned = new CumsumExpressionImpl(this.value, this.additionalOrderBy, this.partitionBy, this.descending);
|
|
597
|
+
cloned._alias = this._alias;
|
|
598
|
+
return cloned;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
var AggregationExpressionImpl = class AggregationExpressionImpl extends ExpressionImpl {
|
|
602
|
+
constructor(operation, expr) {
|
|
603
|
+
super();
|
|
604
|
+
this.operation = operation;
|
|
605
|
+
this.expr = expr;
|
|
606
|
+
}
|
|
607
|
+
toJSON() {
|
|
608
|
+
return {
|
|
609
|
+
type: "aggregate",
|
|
610
|
+
aggregation: this.operation,
|
|
611
|
+
value: this.expr?.toJSON() || {
|
|
612
|
+
type: "const",
|
|
613
|
+
value: 1
|
|
614
|
+
},
|
|
615
|
+
partitionBy: []
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
getAlias() {
|
|
619
|
+
return this._alias || `${this.operation}${this.expr ? "_" + this.expr.getAlias() : ""}`;
|
|
620
|
+
}
|
|
621
|
+
clone() {
|
|
622
|
+
const cloned = new AggregationExpressionImpl(this.operation, this.expr);
|
|
623
|
+
cloned._alias = this._alias;
|
|
624
|
+
return cloned;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
var WindowExpressionImpl = class WindowExpressionImpl extends ExpressionImpl {
|
|
628
|
+
constructor(expr, aggregation, partitionBy) {
|
|
629
|
+
super();
|
|
630
|
+
this.expr = expr;
|
|
631
|
+
this.aggregation = aggregation;
|
|
632
|
+
this.partitionBy = partitionBy;
|
|
633
|
+
}
|
|
634
|
+
toJSON() {
|
|
635
|
+
return {
|
|
636
|
+
type: "aggregate",
|
|
637
|
+
aggregation: this.aggregation,
|
|
638
|
+
value: this.expr.toJSON(),
|
|
639
|
+
partitionBy: this.partitionBy.map((expr) => expr.toJSON())
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
getAlias() {
|
|
643
|
+
return this._alias || `${this.expr.getAlias()}_window`;
|
|
644
|
+
}
|
|
645
|
+
clone() {
|
|
646
|
+
const cloned = new WindowExpressionImpl(this.expr, this.aggregation, this.partitionBy);
|
|
647
|
+
cloned._alias = this._alias;
|
|
648
|
+
return cloned;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
var StringDistanceExpressionImpl = class StringDistanceExpressionImpl extends ExpressionImpl {
|
|
652
|
+
constructor(string1, string2, metric, returnSimilarity) {
|
|
653
|
+
super();
|
|
654
|
+
this.string1 = string1;
|
|
655
|
+
this.string2 = string2;
|
|
656
|
+
this.metric = metric;
|
|
657
|
+
this.returnSimilarity = returnSimilarity;
|
|
658
|
+
}
|
|
659
|
+
toJSON() {
|
|
660
|
+
return {
|
|
661
|
+
type: "string_distance",
|
|
662
|
+
metric: this.metric,
|
|
663
|
+
string1: this.string1.toJSON(),
|
|
664
|
+
string2: this.string2.toJSON(),
|
|
665
|
+
returnSimilarity: this.returnSimilarity || false
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
getAlias() {
|
|
669
|
+
return this._alias || `${this.string1.getAlias()}_distance_${this.string2.getAlias()}`;
|
|
670
|
+
}
|
|
671
|
+
clone() {
|
|
672
|
+
const cloned = new StringDistanceExpressionImpl(this.string1, this.string2, this.metric, this.returnSimilarity);
|
|
673
|
+
cloned._alias = this._alias;
|
|
674
|
+
return cloned;
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
var FuzzyStringFilterExpressionImpl = class FuzzyStringFilterExpressionImpl extends ExpressionImpl {
|
|
678
|
+
constructor(expr, pattern, metric, bound) {
|
|
679
|
+
super();
|
|
680
|
+
this.expr = expr;
|
|
681
|
+
this.pattern = pattern;
|
|
682
|
+
this.metric = metric;
|
|
683
|
+
this.bound = bound;
|
|
684
|
+
}
|
|
685
|
+
toJSON() {
|
|
686
|
+
return {
|
|
687
|
+
type: "fuzzy_string_filter",
|
|
688
|
+
metric: this.metric,
|
|
689
|
+
value: this.expr.toJSON(),
|
|
690
|
+
pattern: this.pattern.toJSON(),
|
|
691
|
+
bound: this.bound
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
getAlias() {
|
|
695
|
+
return this._alias || `${this.expr.getAlias()}_fuzzy_filter`;
|
|
696
|
+
}
|
|
697
|
+
clone() {
|
|
698
|
+
const cloned = new FuzzyStringFilterExpressionImpl(this.expr, this.pattern, this.metric, this.bound);
|
|
699
|
+
cloned._alias = this._alias;
|
|
700
|
+
return cloned;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
var RankExpressionImpl = class RankExpressionImpl extends ExpressionImpl {
|
|
704
|
+
constructor(orderBy, partitionBy, descending) {
|
|
705
|
+
super();
|
|
706
|
+
this.orderBy = orderBy;
|
|
707
|
+
this.partitionBy = partitionBy;
|
|
708
|
+
this.descending = descending;
|
|
709
|
+
}
|
|
710
|
+
toJSON() {
|
|
711
|
+
return {
|
|
712
|
+
type: "rank",
|
|
713
|
+
orderBy: this.orderBy.map((e) => e.toJSON()),
|
|
714
|
+
partitionBy: this.partitionBy.map((e) => e.toJSON()),
|
|
715
|
+
descending: this.descending || void 0
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
getAlias() {
|
|
719
|
+
const order = this.orderBy.map((e) => e.getAlias()).join("_");
|
|
720
|
+
const part = this.partitionBy.map((e) => e.getAlias()).join("_");
|
|
721
|
+
const dir = this.descending ? "desc" : "asc";
|
|
722
|
+
return this._alias || `rank_${order}${part ? `_over_${part}` : ""}_${dir}`;
|
|
723
|
+
}
|
|
724
|
+
clone() {
|
|
725
|
+
const cloned = new RankExpressionImpl(this.orderBy, this.partitionBy, this.descending);
|
|
726
|
+
cloned._alias = this._alias;
|
|
727
|
+
return cloned;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
var WhenThenOtherwiseExpressionImpl = class WhenThenOtherwiseExpressionImpl extends ExpressionImpl {
|
|
731
|
+
constructor(conditions, otherwiseValue) {
|
|
732
|
+
super();
|
|
733
|
+
this.conditions = conditions;
|
|
734
|
+
this.otherwiseValue = otherwiseValue;
|
|
735
|
+
}
|
|
736
|
+
toJSON() {
|
|
737
|
+
return {
|
|
738
|
+
type: "when_then_otherwise",
|
|
739
|
+
conditions: this.conditions.map((clause) => ({
|
|
740
|
+
when: clause.when.toJSON(),
|
|
741
|
+
then: clause.then.toJSON()
|
|
742
|
+
})),
|
|
743
|
+
otherwise: this.otherwiseValue.toJSON()
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
getAlias() {
|
|
747
|
+
return this._alias || "conditional";
|
|
748
|
+
}
|
|
749
|
+
clone() {
|
|
750
|
+
const cloned = new WhenThenOtherwiseExpressionImpl(this.conditions, this.otherwiseValue);
|
|
751
|
+
cloned._alias = this._alias;
|
|
752
|
+
return cloned;
|
|
753
|
+
}
|
|
754
|
+
};
|
|
838
755
|
|
|
756
|
+
//#endregion
|
|
839
757
|
export { AggregationExpressionImpl, ArithmeticExpressionImpl, ColumnExpressionImpl, ComparisonExpressionImpl, CumsumExpressionImpl, ExpressionImpl, FillNaNExpressionImpl, FillNullExpressionImpl, FuzzyStringFilterExpressionImpl, LiteralExpressionImpl, LogicalExpressionImpl, MinMaxExpressionImpl, NullCheckExpressionImpl, RankExpressionImpl, StringCaseExpressionImpl, StringConcatExpressionImpl, StringContainsExpressionImpl, StringDistanceExpressionImpl, StringEndsWithExpressionImpl, StringReplaceExpressionImpl, StringStartsWithExpressionImpl, SubstringExpressionImpl, UnaryArithmeticExpressionImpl, WhenThenOtherwiseExpressionImpl, WindowExpressionImpl, coerceToExpression };
|
|
840
|
-
//# sourceMappingURL=expressions.js.map
|
|
758
|
+
//# sourceMappingURL=expressions.js.map
|