@malloydata/malloy 0.0.182 → 0.0.183-dev240916205710
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.
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.DUCKDB_DIALECT_FUNCTIONS = void 0;
|
|
10
|
+
const dayname = {
|
|
11
|
+
takes: { 'date_value': ['date', 'timestamp'] },
|
|
12
|
+
returns: 'string',
|
|
13
|
+
impl: { function: 'DAYNAME' },
|
|
14
|
+
};
|
|
10
15
|
const to_timestamp = {
|
|
11
16
|
takes: { 'epoch_seconds': 'number' },
|
|
12
17
|
returns: 'timestamp',
|
|
@@ -60,6 +65,7 @@ const string_agg_distinct = {
|
|
|
60
65
|
};
|
|
61
66
|
exports.DUCKDB_DIALECT_FUNCTIONS = {
|
|
62
67
|
count_approx,
|
|
68
|
+
dayname,
|
|
63
69
|
to_timestamp,
|
|
64
70
|
string_agg,
|
|
65
71
|
string_agg_distinct,
|
|
@@ -7,16 +7,79 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.TRINO_DIALECT_FUNCTIONS = void 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// Aggregate functions:
|
|
11
|
+
// TODO: Approx percentile can be called with a third argument; we probably
|
|
12
|
+
// want to implement that at some point
|
|
13
|
+
// In Presto, this is an "error" parameter between 0 and 1
|
|
14
|
+
// In Trino, this is a "weight" parameter between 1 and 99
|
|
15
|
+
const approx_percentile = {
|
|
16
|
+
takes: { 'value': 'number', 'percentage': 'number' },
|
|
17
|
+
returns: { measure: 'number' },
|
|
18
|
+
impl: {
|
|
19
|
+
function: 'APPROX_PERCENTILE',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const arbitrary = {
|
|
23
|
+
generic: ['T', ['string', 'number', 'date', 'timestamp', 'boolean', 'json']],
|
|
24
|
+
takes: { 'value': { dimension: { generic: 'T' } } },
|
|
25
|
+
returns: { measure: { generic: 'T' } },
|
|
26
|
+
impl: { function: 'ARBITRARY' },
|
|
27
|
+
};
|
|
28
|
+
const bitwise_and_agg = {
|
|
29
|
+
takes: { 'value': { dimension: 'number' } },
|
|
30
|
+
returns: { measure: 'number' },
|
|
31
|
+
impl: { function: 'BITWISE_OR_AGG' },
|
|
32
|
+
};
|
|
33
|
+
const bitwise_or_agg = {
|
|
34
|
+
takes: { 'value': { dimension: 'number' } },
|
|
35
|
+
returns: { measure: 'number' },
|
|
36
|
+
impl: { function: 'BITWISE_AND_AGG' },
|
|
37
|
+
};
|
|
38
|
+
const bitwise_xor_agg = {
|
|
39
|
+
takes: { 'value': { dimension: 'number' } },
|
|
40
|
+
returns: { measure: 'number' },
|
|
41
|
+
impl: { function: 'BITWISE_XOR_AGG' },
|
|
42
|
+
};
|
|
43
|
+
const bool_and = {
|
|
44
|
+
takes: { 'value': { dimension: 'boolean' } },
|
|
45
|
+
returns: { measure: 'boolean' },
|
|
46
|
+
impl: { function: 'BOOL_AND' },
|
|
47
|
+
};
|
|
48
|
+
const bool_or = {
|
|
49
|
+
takes: { 'value': { dimension: 'boolean' } },
|
|
50
|
+
returns: { measure: 'boolean' },
|
|
51
|
+
impl: { function: 'BOOL_OR' },
|
|
52
|
+
};
|
|
53
|
+
const corr = {
|
|
54
|
+
takes: { 'y': { dimension: 'number' }, 'x': { dimension: 'number' } },
|
|
55
|
+
returns: { measure: 'number' },
|
|
56
|
+
impl: {
|
|
57
|
+
sql: 'CORR(${y}, ${x})',
|
|
58
|
+
},
|
|
14
59
|
};
|
|
15
60
|
const count_approx = {
|
|
16
61
|
takes: { 'value': { dimension: 'any' } },
|
|
17
62
|
returns: { measure: 'number' },
|
|
18
63
|
impl: { function: 'APPROX_DISTINCT' },
|
|
19
64
|
};
|
|
65
|
+
const max_by = {
|
|
66
|
+
generic: ['T', ['string', 'number', 'date', 'timestamp', 'boolean', 'json']],
|
|
67
|
+
takes: {
|
|
68
|
+
'value': { dimension: { generic: 'T' } },
|
|
69
|
+
'order_by_val': { dimension: 'any' },
|
|
70
|
+
},
|
|
71
|
+
returns: { measure: { generic: 'T' } },
|
|
72
|
+
impl: { function: 'MAX_BY' },
|
|
73
|
+
};
|
|
74
|
+
const min_by = {
|
|
75
|
+
generic: ['T', ['string', 'number', 'date', 'timestamp', 'boolean', 'json']],
|
|
76
|
+
takes: {
|
|
77
|
+
'value': { dimension: { generic: 'T' } },
|
|
78
|
+
'order_by_val': { dimension: 'any' },
|
|
79
|
+
},
|
|
80
|
+
returns: { measure: { generic: 'T' } },
|
|
81
|
+
impl: { function: 'MIN_BY' },
|
|
82
|
+
};
|
|
20
83
|
const string_agg = {
|
|
21
84
|
default_separator: {
|
|
22
85
|
takes: { 'value': { dimension: 'string' } },
|
|
@@ -54,10 +117,110 @@ const string_agg_distinct = {
|
|
|
54
117
|
},
|
|
55
118
|
},
|
|
56
119
|
};
|
|
120
|
+
const variance = {
|
|
121
|
+
takes: { 'value': { dimension: 'number' } },
|
|
122
|
+
returns: { measure: 'number' },
|
|
123
|
+
impl: { function: 'VARIANCE' },
|
|
124
|
+
};
|
|
125
|
+
// Scalar functions
|
|
126
|
+
const bitwise_and = {
|
|
127
|
+
takes: { 'val1': 'number', 'val2': 'number' },
|
|
128
|
+
returns: 'number',
|
|
129
|
+
impl: {
|
|
130
|
+
function: 'BITWISE_AND',
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const bitwise_or = {
|
|
134
|
+
takes: { 'val1': 'number', 'val2': 'number' },
|
|
135
|
+
returns: 'number',
|
|
136
|
+
impl: {
|
|
137
|
+
function: 'BITWISE_OR',
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
const date_format = {
|
|
141
|
+
takes: { 'ts_val': 'timestamp', 'format': 'string' },
|
|
142
|
+
returns: 'string',
|
|
143
|
+
impl: {
|
|
144
|
+
function: 'DATE_FORMAT',
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
const date_parse = {
|
|
148
|
+
takes: { 'ts_string': 'string', 'format': 'string' },
|
|
149
|
+
returns: 'timestamp',
|
|
150
|
+
impl: {
|
|
151
|
+
sql: 'DATE_PARSE(${ts_string}, ${format})',
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
const from_unixtime = {
|
|
155
|
+
takes: { 'unixtime': 'number' },
|
|
156
|
+
returns: 'timestamp',
|
|
157
|
+
impl: { function: 'FROM_UNIXTIME' },
|
|
158
|
+
};
|
|
159
|
+
// TODO: support Presto JSON types
|
|
160
|
+
// eventually, this should take 'json_val': ['string', 'json']
|
|
161
|
+
const json_extract_scalar = {
|
|
162
|
+
takes: { 'json_val': 'string', 'json_path': 'string' },
|
|
163
|
+
returns: 'string',
|
|
164
|
+
impl: { function: 'JSON_EXTRACT_SCALAR' },
|
|
165
|
+
};
|
|
166
|
+
const regexp_like = {
|
|
167
|
+
takes: { 'str': 'string', 'pattern': ['string', 'regular expression'] },
|
|
168
|
+
returns: 'boolean',
|
|
169
|
+
impl: { function: 'REGEXP_LIKE' },
|
|
170
|
+
};
|
|
171
|
+
const regexp_replace = {
|
|
172
|
+
remove_matches: {
|
|
173
|
+
takes: {
|
|
174
|
+
'input_val': 'string',
|
|
175
|
+
'regexp_pattern': ['string', 'regular expression'],
|
|
176
|
+
},
|
|
177
|
+
returns: 'string',
|
|
178
|
+
impl: {
|
|
179
|
+
function: 'REGEXP_REPLACE',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
replace_matches: {
|
|
183
|
+
takes: {
|
|
184
|
+
'input_val': 'string',
|
|
185
|
+
'regexp_pattern': ['string', 'regular expression'],
|
|
186
|
+
'replacement': 'string',
|
|
187
|
+
},
|
|
188
|
+
returns: 'string',
|
|
189
|
+
impl: {
|
|
190
|
+
function: 'REGEXP_REPLACE',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
const to_unixtime = {
|
|
195
|
+
takes: { 'ts_val': 'timestamp' },
|
|
196
|
+
returns: 'number',
|
|
197
|
+
impl: { function: 'TO_UNIXTIME' },
|
|
198
|
+
};
|
|
57
199
|
exports.TRINO_DIALECT_FUNCTIONS = {
|
|
200
|
+
// aggregate functions
|
|
201
|
+
approx_percentile,
|
|
202
|
+
arbitrary,
|
|
203
|
+
bitwise_and_agg,
|
|
204
|
+
bitwise_or_agg,
|
|
205
|
+
bitwise_xor_agg,
|
|
206
|
+
bool_and,
|
|
207
|
+
bool_or,
|
|
208
|
+
corr,
|
|
58
209
|
count_approx,
|
|
59
|
-
|
|
210
|
+
max_by,
|
|
211
|
+
min_by,
|
|
60
212
|
string_agg,
|
|
61
213
|
string_agg_distinct,
|
|
214
|
+
variance,
|
|
215
|
+
// scalar functions
|
|
216
|
+
bitwise_and,
|
|
217
|
+
bitwise_or,
|
|
218
|
+
date_format,
|
|
219
|
+
date_parse,
|
|
220
|
+
from_unixtime,
|
|
221
|
+
json_extract_scalar,
|
|
222
|
+
regexp_like,
|
|
223
|
+
regexp_replace,
|
|
224
|
+
to_unixtime,
|
|
62
225
|
};
|
|
63
226
|
//# sourceMappingURL=dialect_functions.js.map
|