@malloydata/malloy 0.0.225-dev241220203531 → 0.0.225-dev241221012915
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/dialect/duckdb/dialect_functions.js +3 -6
- package/dist/dialect/functions/malloy_standard_functions.d.ts +0 -1
- package/dist/dialect/functions/malloy_standard_functions.js +0 -6
- package/dist/dialect/functions/util.d.ts +23 -0
- package/dist/dialect/functions/util.js +79 -1
- package/dist/dialect/mysql/dialect_functions.js +3 -6
- package/dist/dialect/postgres/dialect_functions.js +3 -6
- package/dist/dialect/snowflake/dialect_functions.js +2 -6
- package/dist/dialect/standardsql/dialect_functions.js +3 -6
- package/dist/dialect/trino/dialect_functions.d.ts +9 -0
- package/dist/dialect/trino/dialect_functions.js +169 -323
- package/dist/dialect/trino/function_overrides.js +0 -3
- package/package.json +1 -1
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.DUCKDB_DIALECT_FUNCTIONS = void 0;
|
|
10
|
-
const
|
|
11
|
-
takes: { 'str': 'string', 'n': 'number' },
|
|
12
|
-
returns: 'string',
|
|
13
|
-
impl: { function: 'REPEAT' },
|
|
14
|
-
};
|
|
10
|
+
const util_1 = require("../functions/util");
|
|
15
11
|
const list_extract = {
|
|
16
12
|
takes: { 'value': { array: { generic: 'T' } }, 'index': 'number' },
|
|
17
13
|
generic: { 'T': ['any'] },
|
|
@@ -90,10 +86,11 @@ exports.DUCKDB_DIALECT_FUNCTIONS = {
|
|
|
90
86
|
count_approx,
|
|
91
87
|
dayname,
|
|
92
88
|
to_timestamp,
|
|
93
|
-
repeat,
|
|
94
89
|
string_agg,
|
|
95
90
|
string_agg_distinct,
|
|
96
91
|
to_seconds,
|
|
97
92
|
date_part,
|
|
93
|
+
...(0, util_1.def)('repeat', { 'str': 'string', 'n': 'number' }, 'string'),
|
|
94
|
+
...(0, util_1.def)('reverse', { 'str': 'string' }, 'string'),
|
|
98
95
|
};
|
|
99
96
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -215,11 +215,6 @@ const replace = {
|
|
|
215
215
|
impl: { function: 'REGEXP_REPLACE' },
|
|
216
216
|
},
|
|
217
217
|
};
|
|
218
|
-
const reverse = {
|
|
219
|
-
takes: { 'value': 'string' },
|
|
220
|
-
returns: 'string',
|
|
221
|
-
impl: { function: 'REVERSE' },
|
|
222
|
-
};
|
|
223
218
|
const round = {
|
|
224
219
|
'to_integer': {
|
|
225
220
|
takes: { 'value': 'number' },
|
|
@@ -560,7 +555,6 @@ exports.MALLOY_STANDARD_FUNCTIONS = {
|
|
|
560
555
|
rand,
|
|
561
556
|
regexp_extract,
|
|
562
557
|
replace,
|
|
563
|
-
reverse,
|
|
564
558
|
round,
|
|
565
559
|
rtrim,
|
|
566
560
|
sign,
|
|
@@ -142,4 +142,27 @@ export declare function expandBlueprintMap(blueprints: DefinitionBlueprintMap):
|
|
|
142
142
|
export declare function expandOverrideMapFromBase(base: DefinitionBlueprintMap, overrides: OverrideMap): {
|
|
143
143
|
[name: string]: DialectFunctionOverloadDef[];
|
|
144
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Shortcut for non overloaded functions definitions. Default implementation
|
|
147
|
+
* will be the function name turned to upper case. Default type for
|
|
148
|
+
* any generics encountered will be `['any']`. Both of these can be over-ridden
|
|
149
|
+
* in the `options` parameter.
|
|
150
|
+
*
|
|
151
|
+
* The two implict defaults (which can be over-ridden) are that the
|
|
152
|
+
* impl: will be the upper case version of the function name, and that
|
|
153
|
+
* any generic reference will be of type 'any'.
|
|
154
|
+
*
|
|
155
|
+
* USAGE:
|
|
156
|
+
*
|
|
157
|
+
* ...def('func_name', {'arg0': 'type0', 'arg1': 'type1'}, 'return-type')
|
|
158
|
+
*
|
|
159
|
+
* @param name name of function
|
|
160
|
+
* @param takes Record<Argument blueprint>
|
|
161
|
+
* @param returns Return Blueprint
|
|
162
|
+
* @param options Everything from a `DefinitionBlueprint` except `takes` and `returns`
|
|
163
|
+
* @returns dot dot dot able blueprint definition
|
|
164
|
+
*/
|
|
165
|
+
export declare function def(name: string, takes: Record<string, TypeDescBlueprint>, returns: TypeDescBlueprint, options?: Partial<Omit<DefinitionBlueprint, 'takes' | 'returns'>>): {
|
|
166
|
+
[x: string]: DefinitionBlueprint;
|
|
167
|
+
};
|
|
145
168
|
export {};
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.expandOverrideMapFromBase = exports.expandBlueprintMap = exports.overload = exports.minAnalytic = exports.minAggregate = exports.minScalar = exports.maxAnalytic = exports.maxUngroupedAggregate = exports.anyExprType = exports.maxAggregate = exports.maxScalar = exports.makeParam = exports.param = exports.variadicParam = exports.literal = exports.output = exports.constant = exports.sql = exports.spread = exports.arg = void 0;
|
|
26
|
+
exports.def = exports.expandOverrideMapFromBase = exports.expandBlueprintMap = exports.overload = exports.minAnalytic = exports.minAggregate = exports.minScalar = exports.maxAnalytic = exports.maxUngroupedAggregate = exports.anyExprType = exports.maxAggregate = exports.maxScalar = exports.makeParam = exports.param = exports.variadicParam = exports.literal = exports.output = exports.constant = exports.sql = exports.spread = exports.arg = void 0;
|
|
27
27
|
const malloy_types_1 = require("../../model/malloy_types");
|
|
28
28
|
function arg(name) {
|
|
29
29
|
return { node: 'function_parameter', name };
|
|
@@ -471,4 +471,82 @@ function expandOverrideMapFromBase(base, overrides) {
|
|
|
471
471
|
return map;
|
|
472
472
|
}
|
|
473
473
|
exports.expandOverrideMapFromBase = expandOverrideMapFromBase;
|
|
474
|
+
/**
|
|
475
|
+
* Walks a type and returns all the generic references
|
|
476
|
+
* @param tdbp A type
|
|
477
|
+
*/
|
|
478
|
+
function* findGenerics(tdbp) {
|
|
479
|
+
if (typeof tdbp !== 'string') {
|
|
480
|
+
if ('generic' in tdbp) {
|
|
481
|
+
yield tdbp;
|
|
482
|
+
}
|
|
483
|
+
else if ('record' in tdbp) {
|
|
484
|
+
for (const recType of Object.values(tdbp.record)) {
|
|
485
|
+
yield* findGenerics(recType);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
for (const leaflet of [
|
|
490
|
+
'array',
|
|
491
|
+
'literal',
|
|
492
|
+
'measure',
|
|
493
|
+
'dimension',
|
|
494
|
+
'measure',
|
|
495
|
+
'constant',
|
|
496
|
+
'cacluation',
|
|
497
|
+
]) {
|
|
498
|
+
if (leaflet in tdbp) {
|
|
499
|
+
yield* findGenerics(tdbp[leaflet]);
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Shortcut for non overloaded functions definitions. Default implementation
|
|
508
|
+
* will be the function name turned to upper case. Default type for
|
|
509
|
+
* any generics encountered will be `['any']`. Both of these can be over-ridden
|
|
510
|
+
* in the `options` parameter.
|
|
511
|
+
*
|
|
512
|
+
* The two implict defaults (which can be over-ridden) are that the
|
|
513
|
+
* impl: will be the upper case version of the function name, and that
|
|
514
|
+
* any generic reference will be of type 'any'.
|
|
515
|
+
*
|
|
516
|
+
* USAGE:
|
|
517
|
+
*
|
|
518
|
+
* ...def('func_name', {'arg0': 'type0', 'arg1': 'type1'}, 'return-type')
|
|
519
|
+
*
|
|
520
|
+
* @param name name of function
|
|
521
|
+
* @param takes Record<Argument blueprint>
|
|
522
|
+
* @param returns Return Blueprint
|
|
523
|
+
* @param options Everything from a `DefinitionBlueprint` except `takes` and `returns`
|
|
524
|
+
* @returns dot dot dot able blueprint definition
|
|
525
|
+
*/
|
|
526
|
+
function def(name, takes, returns, options = {}) {
|
|
527
|
+
let anyGenerics = false;
|
|
528
|
+
const generic = {};
|
|
529
|
+
for (const argType of Object.values(takes)) {
|
|
530
|
+
for (const genericRef of findGenerics(argType)) {
|
|
531
|
+
generic[genericRef.generic] = ['any'];
|
|
532
|
+
anyGenerics = true;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// We have found all the generic references and given them all
|
|
536
|
+
// T: ['any']. Use this as a default if the options section
|
|
537
|
+
// doesn't provide types for the generics.
|
|
538
|
+
if (anyGenerics) {
|
|
539
|
+
if (options.generic === undefined) {
|
|
540
|
+
options.generic = generic;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
const newDef = {
|
|
544
|
+
takes,
|
|
545
|
+
returns,
|
|
546
|
+
impl: { function: name.toUpperCase() },
|
|
547
|
+
...options,
|
|
548
|
+
};
|
|
549
|
+
return { [name]: newDef };
|
|
550
|
+
}
|
|
551
|
+
exports.def = def;
|
|
474
552
|
//# sourceMappingURL=util.js.map
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MYSQL_DIALECT_FUNCTIONS = void 0;
|
|
10
|
-
const
|
|
11
|
-
takes: { 'str': 'string', 'n': 'number' },
|
|
12
|
-
returns: 'string',
|
|
13
|
-
impl: { function: 'REPEAT' },
|
|
14
|
-
};
|
|
10
|
+
const util_1 = require("../functions/util");
|
|
15
11
|
const string_agg = {
|
|
16
12
|
default_separator: {
|
|
17
13
|
takes: { 'value': { dimension: 'string' } },
|
|
@@ -52,6 +48,7 @@ const string_agg_distinct = {
|
|
|
52
48
|
exports.MYSQL_DIALECT_FUNCTIONS = {
|
|
53
49
|
string_agg,
|
|
54
50
|
string_agg_distinct,
|
|
55
|
-
repeat,
|
|
51
|
+
...(0, util_1.def)('repeat', { 'str': 'string', 'n': 'number' }, 'string'),
|
|
52
|
+
...(0, util_1.def)('reverse', { 'str': 'string' }, 'string'),
|
|
56
53
|
};
|
|
57
54
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.POSTGRES_DIALECT_FUNCTIONS = void 0;
|
|
10
|
-
const
|
|
11
|
-
takes: { 'str': 'string', 'n': 'number' },
|
|
12
|
-
returns: 'string',
|
|
13
|
-
impl: { function: 'REPEAT' },
|
|
14
|
-
};
|
|
10
|
+
const util_1 = require("../functions/util");
|
|
15
11
|
const string_agg = {
|
|
16
12
|
default_separator: {
|
|
17
13
|
takes: { 'value': { dimension: 'string' } },
|
|
@@ -52,6 +48,7 @@ const string_agg_distinct = {
|
|
|
52
48
|
exports.POSTGRES_DIALECT_FUNCTIONS = {
|
|
53
49
|
string_agg,
|
|
54
50
|
string_agg_distinct,
|
|
55
|
-
repeat,
|
|
51
|
+
...(0, util_1.def)('repeat', { 'str': 'string', 'n': 'number' }, 'string'),
|
|
52
|
+
...(0, util_1.def)('reverse', { 'str': 'string' }, 'string'),
|
|
56
53
|
};
|
|
57
54
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -8,11 +8,6 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SNOWFLAKE_DIALECT_FUNCTIONS = void 0;
|
|
10
10
|
const util_1 = require("../functions/util");
|
|
11
|
-
const repeat = {
|
|
12
|
-
takes: { 'str': 'string', 'n': 'number' },
|
|
13
|
-
returns: 'string',
|
|
14
|
-
impl: { function: 'REPEAT' },
|
|
15
|
-
};
|
|
16
11
|
const order_by = {
|
|
17
12
|
node: 'aggregate_order_by',
|
|
18
13
|
prefix: ' WITHIN GROUP(',
|
|
@@ -58,6 +53,7 @@ const string_agg_distinct = {
|
|
|
58
53
|
exports.SNOWFLAKE_DIALECT_FUNCTIONS = {
|
|
59
54
|
string_agg,
|
|
60
55
|
string_agg_distinct,
|
|
61
|
-
repeat,
|
|
56
|
+
...(0, util_1.def)('repeat', { 'str': 'string', 'n': 'number' }, 'string'),
|
|
57
|
+
...(0, util_1.def)('reverse', { 'str': 'string' }, 'string'),
|
|
62
58
|
};
|
|
63
59
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.STANDARDSQL_DIALECT_FUNCTIONS = void 0;
|
|
10
|
-
const
|
|
11
|
-
takes: { 'str': 'string', 'n': 'number' },
|
|
12
|
-
returns: 'string',
|
|
13
|
-
impl: { function: 'REPEAT' },
|
|
14
|
-
};
|
|
10
|
+
const util_1 = require("../functions/util");
|
|
15
11
|
const date_from_unix_date = {
|
|
16
12
|
takes: { 'unix_date': 'number' },
|
|
17
13
|
returns: 'date',
|
|
@@ -66,6 +62,7 @@ exports.STANDARDSQL_DIALECT_FUNCTIONS = {
|
|
|
66
62
|
date_from_unix_date,
|
|
67
63
|
string_agg,
|
|
68
64
|
string_agg_distinct,
|
|
69
|
-
repeat,
|
|
65
|
+
...(0, util_1.def)('repeat', { 'str': 'string', 'n': 'number' }, 'string'),
|
|
66
|
+
...(0, util_1.def)('reverse', { 'str': 'string' }, 'string'),
|
|
70
67
|
};
|
|
71
68
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { DefinitionBlueprintMap } from '../functions/util';
|
|
2
|
+
/**
|
|
3
|
+
* This map is for functions which exist in both Presto and Trino.
|
|
4
|
+
* If you are adding functions which only exist in Presto, put them in
|
|
5
|
+
* to PRESTO_DIALECT_FUNCTIONS.
|
|
6
|
+
*
|
|
7
|
+
* If you have a function which works differently in each, add them to
|
|
8
|
+
* both.
|
|
9
|
+
*/
|
|
2
10
|
export declare const TRINO_DIALECT_FUNCTIONS: DefinitionBlueprintMap;
|
|
11
|
+
/******** Presto Only *********/
|
|
3
12
|
export declare const PRESTO_DIALECT_FUNCTIONS: DefinitionBlueprintMap;
|
|
@@ -7,120 +7,27 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.PRESTO_DIALECT_FUNCTIONS = exports.TRINO_DIALECT_FUNCTIONS = void 0;
|
|
10
|
+
const util_1 = require("../functions/util");
|
|
11
|
+
/*
|
|
12
|
+
* We are experimenting with the best way to make this file easy for someone
|
|
13
|
+
* to step in and modify, AND to make it easy to create a new dialect.
|
|
14
|
+
*
|
|
15
|
+
* So in this file we are experimenting with various ways to define things.
|
|
16
|
+
* The most general and powerful is to write a DefinitionBlueprint or
|
|
17
|
+
* OverloadedDefinitionBlueprint, naming it with the name of the function
|
|
18
|
+
* you want to add, and then to add that name to the dialcect function list.
|
|
19
|
+
*
|
|
20
|
+
* Experimentally, there is also a function def which creates a
|
|
21
|
+
* DefinitionBlueprint for you. For simple blueprints, you can use the wrapper
|
|
22
|
+
* definition generator def(), and there are examples in this file
|
|
23
|
+
* of how to do that, and def() has some hover-documentation.
|
|
24
|
+
*
|
|
25
|
+
* It is an experiment so please let us know if you like def(),
|
|
26
|
+
* or if you prefer editing the Blueprint data structures.
|
|
27
|
+
*/
|
|
28
|
+
// Cute shortcut So you can write things like: {array: T} and {dimension: T}
|
|
10
29
|
const T = { generic: 'T' };
|
|
11
30
|
// Aggregate functions:
|
|
12
|
-
// TODO: Approx percentile can be called with a third argument; we probably
|
|
13
|
-
// want to implement that at some point
|
|
14
|
-
// In Presto, this is an "error" parameter between 0 and 1
|
|
15
|
-
// In Trino, this is a "weight" parameter between 1 and 99
|
|
16
|
-
const approx_percentile = {
|
|
17
|
-
takes: { 'value': 'number', 'percentage': 'number' },
|
|
18
|
-
returns: { measure: 'number' },
|
|
19
|
-
impl: {
|
|
20
|
-
function: 'APPROX_PERCENTILE',
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
const arbitrary = {
|
|
24
|
-
generic: { 'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'] },
|
|
25
|
-
takes: { 'value': { dimension: T } },
|
|
26
|
-
returns: { measure: T },
|
|
27
|
-
impl: { function: 'ARBITRARY' },
|
|
28
|
-
};
|
|
29
|
-
const bitwise_and_agg = {
|
|
30
|
-
takes: { 'value': { dimension: 'number' } },
|
|
31
|
-
returns: { measure: 'number' },
|
|
32
|
-
impl: { function: 'BITWISE_OR_AGG' },
|
|
33
|
-
};
|
|
34
|
-
const bitwise_or_agg = {
|
|
35
|
-
takes: { 'value': { dimension: 'number' } },
|
|
36
|
-
returns: { measure: 'number' },
|
|
37
|
-
impl: { function: 'BITWISE_AND_AGG' },
|
|
38
|
-
};
|
|
39
|
-
const bitwise_xor_agg = {
|
|
40
|
-
takes: { 'value': { dimension: 'number' } },
|
|
41
|
-
returns: { measure: 'number' },
|
|
42
|
-
impl: { function: 'BITWISE_XOR_AGG' },
|
|
43
|
-
};
|
|
44
|
-
const bool_and = {
|
|
45
|
-
takes: { 'value': { dimension: 'boolean' } },
|
|
46
|
-
returns: { measure: 'boolean' },
|
|
47
|
-
impl: { function: 'BOOL_AND' },
|
|
48
|
-
};
|
|
49
|
-
const bool_or = {
|
|
50
|
-
takes: { 'value': { dimension: 'boolean' } },
|
|
51
|
-
returns: { measure: 'boolean' },
|
|
52
|
-
impl: { function: 'BOOL_OR' },
|
|
53
|
-
};
|
|
54
|
-
const corr = {
|
|
55
|
-
takes: { 'y': { dimension: 'number' }, 'x': { dimension: 'number' } },
|
|
56
|
-
returns: { measure: 'number' },
|
|
57
|
-
impl: {
|
|
58
|
-
sql: 'CORR(${y}, ${x})',
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
const count_approx = {
|
|
62
|
-
takes: { 'value': { dimension: 'any' } },
|
|
63
|
-
returns: { measure: 'number' },
|
|
64
|
-
impl: { function: 'APPROX_DISTINCT' },
|
|
65
|
-
isSymmetric: true,
|
|
66
|
-
};
|
|
67
|
-
const hll_accumulate = {
|
|
68
|
-
default: {
|
|
69
|
-
generic: {
|
|
70
|
-
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
71
|
-
},
|
|
72
|
-
takes: { 'value': { dimension: { generic: 'T' } } },
|
|
73
|
-
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
74
|
-
isSymmetric: true,
|
|
75
|
-
impl: {
|
|
76
|
-
function: 'APPROX_SET',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
with_percent: {
|
|
80
|
-
generic: {
|
|
81
|
-
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
82
|
-
},
|
|
83
|
-
takes: { 'value': { dimension: { generic: 'T' } }, 'accuracy': 'number' },
|
|
84
|
-
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
85
|
-
isSymmetric: true,
|
|
86
|
-
impl: {
|
|
87
|
-
function: 'APPROX_SET',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
const hll_combine = {
|
|
92
|
-
takes: {
|
|
93
|
-
'value': { sql_native: 'hyperloglog' },
|
|
94
|
-
},
|
|
95
|
-
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
96
|
-
impl: { function: 'MERGE' },
|
|
97
|
-
isSymmetric: true,
|
|
98
|
-
};
|
|
99
|
-
const hll_estimate = {
|
|
100
|
-
takes: {
|
|
101
|
-
'value': { sql_native: 'hyperloglog' },
|
|
102
|
-
},
|
|
103
|
-
returns: { dimension: 'number' },
|
|
104
|
-
impl: { function: 'CARDINALITY' },
|
|
105
|
-
};
|
|
106
|
-
const hll_export = {
|
|
107
|
-
takes: {
|
|
108
|
-
'value': { sql_native: 'hyperloglog' },
|
|
109
|
-
},
|
|
110
|
-
returns: { dimension: { sql_native: 'varbinary' } },
|
|
111
|
-
impl: {
|
|
112
|
-
sql: 'CAST(${value} AS VARBINARY)',
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
const hll_import = {
|
|
116
|
-
takes: {
|
|
117
|
-
'value': { sql_native: 'varbinary' },
|
|
118
|
-
},
|
|
119
|
-
returns: { dimension: { sql_native: 'hyperloglog' } },
|
|
120
|
-
impl: {
|
|
121
|
-
sql: 'CAST(${value} AS HyperLogLog)',
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
31
|
const max_by = {
|
|
125
32
|
generic: { 'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'] },
|
|
126
33
|
takes: {
|
|
@@ -178,33 +85,7 @@ const string_agg_distinct = {
|
|
|
178
85
|
},
|
|
179
86
|
},
|
|
180
87
|
};
|
|
181
|
-
const variance = {
|
|
182
|
-
takes: { 'value': { dimension: 'number' } },
|
|
183
|
-
returns: { measure: 'number' },
|
|
184
|
-
impl: { function: 'VARIANCE' },
|
|
185
|
-
};
|
|
186
88
|
// Scalar functions
|
|
187
|
-
const bitwise_and = {
|
|
188
|
-
takes: { 'val1': 'number', 'val2': 'number' },
|
|
189
|
-
returns: 'number',
|
|
190
|
-
impl: {
|
|
191
|
-
function: 'BITWISE_AND',
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
const bitwise_or = {
|
|
195
|
-
takes: { 'val1': 'number', 'val2': 'number' },
|
|
196
|
-
returns: 'number',
|
|
197
|
-
impl: {
|
|
198
|
-
function: 'BITWISE_OR',
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
const date_format = {
|
|
202
|
-
takes: { 'ts_val': 'timestamp', 'format': 'string' },
|
|
203
|
-
returns: 'string',
|
|
204
|
-
impl: {
|
|
205
|
-
function: 'DATE_FORMAT',
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
89
|
const date_parse = {
|
|
209
90
|
takes: { 'ts_string': 'string', 'format': 'string' },
|
|
210
91
|
returns: 'timestamp',
|
|
@@ -212,11 +93,6 @@ const date_parse = {
|
|
|
212
93
|
sql: 'DATE_PARSE(${ts_string}, ${format})',
|
|
213
94
|
},
|
|
214
95
|
};
|
|
215
|
-
const from_unixtime = {
|
|
216
|
-
takes: { 'unixtime': 'number' },
|
|
217
|
-
returns: 'timestamp',
|
|
218
|
-
impl: { function: 'FROM_UNIXTIME' },
|
|
219
|
-
};
|
|
220
96
|
// TODO: support Presto JSON types
|
|
221
97
|
// eventually, this should take 'json_val': ['string', 'json']
|
|
222
98
|
const json_extract_scalar = {
|
|
@@ -252,55 +128,15 @@ const regexp_replace = {
|
|
|
252
128
|
},
|
|
253
129
|
},
|
|
254
130
|
};
|
|
255
|
-
const to_unixtime = {
|
|
256
|
-
takes: { 'ts_val': 'timestamp' },
|
|
257
|
-
returns: 'number',
|
|
258
|
-
impl: { function: 'TO_UNIXTIME' },
|
|
259
|
-
};
|
|
260
131
|
const percent_rank = {
|
|
261
132
|
takes: {},
|
|
262
133
|
returns: { calculation: 'number' },
|
|
263
134
|
impl: { function: 'PERCENT_RANK', needsWindowOrderBy: true },
|
|
264
135
|
};
|
|
265
|
-
const url_extract_fragment = {
|
|
266
|
-
takes: { 'url': 'string' },
|
|
267
|
-
returns: 'string',
|
|
268
|
-
impl: { function: 'URL_EXTRACT_FRAGMENT' },
|
|
269
|
-
};
|
|
270
|
-
const url_extract_host = {
|
|
271
|
-
takes: { 'url': 'string' },
|
|
272
|
-
returns: 'string',
|
|
273
|
-
impl: { function: 'URL_EXTRACT_HOST' },
|
|
274
|
-
};
|
|
275
|
-
const url_extract_parameter = {
|
|
276
|
-
takes: { 'url': 'string', 'parameter': 'string' },
|
|
277
|
-
returns: 'string',
|
|
278
|
-
impl: { function: 'URL_EXTRACT_PARAMETER' },
|
|
279
|
-
};
|
|
280
|
-
const url_extract_path = {
|
|
281
|
-
takes: { 'url': 'string' },
|
|
282
|
-
returns: 'string',
|
|
283
|
-
impl: { function: 'URL_EXTRACT_PATH' },
|
|
284
|
-
};
|
|
285
|
-
const url_extract_port = {
|
|
286
|
-
takes: { 'url': 'string' },
|
|
287
|
-
returns: 'number',
|
|
288
|
-
impl: { function: 'URL_EXTRACT_PORT' },
|
|
289
|
-
};
|
|
290
|
-
const url_extract_protocol = {
|
|
291
|
-
takes: { 'url': 'string' },
|
|
292
|
-
returns: 'string',
|
|
293
|
-
impl: { function: 'URL_EXTRACT_PROTOCOL' },
|
|
294
|
-
};
|
|
295
|
-
const url_extract_query = {
|
|
296
|
-
takes: { 'url': 'string' },
|
|
297
|
-
returns: 'string',
|
|
298
|
-
impl: { function: 'URL_EXTRACT_QUERY' },
|
|
299
|
-
};
|
|
300
136
|
const array_join = {
|
|
301
137
|
skip_nulls: {
|
|
302
138
|
takes: {
|
|
303
|
-
'
|
|
139
|
+
'array_v': { array: T },
|
|
304
140
|
'sep': 'string',
|
|
305
141
|
},
|
|
306
142
|
generic: { T: ['any'] },
|
|
@@ -309,7 +145,7 @@ const array_join = {
|
|
|
309
145
|
},
|
|
310
146
|
null_aware: {
|
|
311
147
|
takes: {
|
|
312
|
-
'
|
|
148
|
+
'array_v': T,
|
|
313
149
|
'sep': 'string',
|
|
314
150
|
'nullStr': 'string',
|
|
315
151
|
},
|
|
@@ -321,179 +157,189 @@ const array_join = {
|
|
|
321
157
|
const sequence = {
|
|
322
158
|
num_to_num: {
|
|
323
159
|
takes: { 'start': 'number', 'stop': 'number' },
|
|
324
|
-
generic: { 'T': ['any'] },
|
|
325
160
|
returns: { array: 'number' },
|
|
326
161
|
impl: { function: 'SEQUENCE' },
|
|
327
162
|
},
|
|
328
163
|
num_to_num_step: {
|
|
329
164
|
takes: { 'start': 'number', 'stop': 'number', 'step': 'number' },
|
|
330
|
-
generic: { 'T': ['any'] },
|
|
331
165
|
returns: { array: 'number' },
|
|
332
166
|
impl: { function: 'SEQUENCE' },
|
|
333
167
|
},
|
|
334
168
|
date_to_date: {
|
|
335
169
|
takes: { 'start': 'date', 'stop': 'date' },
|
|
336
|
-
generic: { 'T': ['any'] },
|
|
337
170
|
returns: { array: 'date' },
|
|
338
171
|
impl: { function: 'SEQUENCE' },
|
|
339
172
|
},
|
|
340
|
-
// mtoy todo document missing sequence
|
|
341
173
|
};
|
|
174
|
+
const string_reverse = {
|
|
175
|
+
takes: { 'str': 'string' },
|
|
176
|
+
returns: 'string',
|
|
177
|
+
impl: { sql: 'REVERSE(CAST(${str} AS VARCHAR))' },
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* This map is for functions which exist in both Presto and Trino.
|
|
181
|
+
* If you are adding functions which only exist in Presto, put them in
|
|
182
|
+
* to PRESTO_DIALECT_FUNCTIONS.
|
|
183
|
+
*
|
|
184
|
+
* If you have a function which works differently in each, add them to
|
|
185
|
+
* both.
|
|
186
|
+
*/
|
|
342
187
|
exports.TRINO_DIALECT_FUNCTIONS = {
|
|
188
|
+
// string functions
|
|
189
|
+
reverse: string_reverse,
|
|
343
190
|
// aggregate functions
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
191
|
+
// TODO: Approx percentile can be called with a third argument; we probably
|
|
192
|
+
// want to implement that at some point
|
|
193
|
+
// In Presto, this is an "error" parameter between 0 and 1
|
|
194
|
+
// In Trino, this is a "weight" parameter between 1 and 99
|
|
195
|
+
...(0, util_1.def)('approx_percentile', { 'value': 'number', 'percentage': 'number' }, { measure: 'number' }),
|
|
196
|
+
...(0, util_1.def)('arbitrary', { 'value': { dimension: T } }, { measure: T }, {
|
|
197
|
+
generic: {
|
|
198
|
+
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
...(0, util_1.def)('bitwise_and_agg', { 'value': { dimension: 'number' } }, { measure: 'number' }, { isSymmetric: true }),
|
|
202
|
+
...(0, util_1.def)('bitwise_or_agg', { 'value': { dimension: 'number' } }, { measure: 'number' }, { isSymmetric: true }),
|
|
203
|
+
...(0, util_1.def)('bitwise_xor_agg', { 'value': { dimension: 'number' } }, { measure: 'number' }, { isSymmetric: true }),
|
|
204
|
+
...(0, util_1.def)('bool_and', { 'value': { dimension: 'boolean' } }, { measure: 'boolean' }),
|
|
205
|
+
...(0, util_1.def)('bool_or', { 'value': { dimension: 'boolean' } }, { measure: 'boolean' }),
|
|
206
|
+
...(0, util_1.def)('corr', { 'y': { dimension: 'number' }, 'x': { dimension: 'number' } }, { measure: 'number' }),
|
|
207
|
+
...(0, util_1.def)('count_approx', { 'value': { dimension: 'any' } }, { measure: 'number' }, {
|
|
208
|
+
impl: { function: 'APPROX_DISTINCT' },
|
|
209
|
+
isSymmetric: true,
|
|
210
|
+
}),
|
|
211
|
+
hll_accumulate: {
|
|
212
|
+
default: {
|
|
213
|
+
takes: { 'value': { dimension: T } },
|
|
214
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
215
|
+
generic: {
|
|
216
|
+
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
217
|
+
},
|
|
218
|
+
isSymmetric: true,
|
|
219
|
+
impl: { function: 'APPROX_SET' },
|
|
220
|
+
},
|
|
221
|
+
with_percent: {
|
|
222
|
+
takes: { 'value': { dimension: T }, 'accuracy': 'number' },
|
|
223
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
224
|
+
generic: {
|
|
225
|
+
'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
|
|
226
|
+
},
|
|
227
|
+
isSymmetric: true,
|
|
228
|
+
impl: { function: 'APPROX_SET' },
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
hll_combine: {
|
|
232
|
+
takes: { 'value': { sql_native: 'hyperloglog' } },
|
|
233
|
+
returns: { measure: { sql_native: 'hyperloglog' } },
|
|
234
|
+
impl: { function: 'MERGE' },
|
|
235
|
+
isSymmetric: true,
|
|
236
|
+
},
|
|
237
|
+
hll_estimate: {
|
|
238
|
+
takes: { 'value': { sql_native: 'hyperloglog' } },
|
|
239
|
+
returns: { dimension: 'number' },
|
|
240
|
+
impl: { function: 'CARDINALITY' },
|
|
241
|
+
},
|
|
242
|
+
hll_export: {
|
|
243
|
+
takes: { 'value': { sql_native: 'hyperloglog' } },
|
|
244
|
+
returns: { dimension: { sql_native: 'varbinary' } },
|
|
245
|
+
impl: { sql: 'CAST(${value} AS VARBINARY)' },
|
|
246
|
+
},
|
|
247
|
+
hll_import: {
|
|
248
|
+
takes: { 'value': { sql_native: 'varbinary' } },
|
|
249
|
+
returns: { dimension: { sql_native: 'hyperloglog' } },
|
|
250
|
+
impl: { sql: 'CAST(${value} AS HyperLogLog)' },
|
|
251
|
+
},
|
|
355
252
|
max_by,
|
|
356
253
|
min_by,
|
|
357
254
|
string_agg,
|
|
358
255
|
string_agg_distinct,
|
|
359
|
-
variance,
|
|
256
|
+
...(0, util_1.def)('variance', { 'n': 'number' }, { measure: 'number' }),
|
|
360
257
|
// scalar functions
|
|
361
|
-
bitwise_and,
|
|
362
|
-
bitwise_or,
|
|
363
|
-
date_format,
|
|
258
|
+
...(0, util_1.def)('bitwise_and', { 'val1': 'number', 'val2': 'number' }, 'number'),
|
|
259
|
+
...(0, util_1.def)('bitwise_or', { 'val1': 'number', 'val2': 'number' }, 'number'),
|
|
260
|
+
...(0, util_1.def)('date_format', { 'ts_val': 'timestamp', 'format': 'string' }, 'string'),
|
|
364
261
|
date_parse,
|
|
365
|
-
from_unixtime,
|
|
366
|
-
hll_estimate,
|
|
367
|
-
hll_export,
|
|
368
|
-
hll_import,
|
|
262
|
+
...(0, util_1.def)('from_unixtime', { 'unixtime': 'number' }, 'timestamp'),
|
|
369
263
|
json_extract_scalar,
|
|
370
264
|
regexp_like,
|
|
371
265
|
regexp_replace,
|
|
372
|
-
to_unixtime,
|
|
373
|
-
url_extract_fragment,
|
|
374
|
-
url_extract_host,
|
|
375
|
-
url_extract_parameter,
|
|
376
|
-
url_extract_path,
|
|
377
|
-
url_extract_port,
|
|
378
|
-
url_extract_protocol,
|
|
379
|
-
url_extract_query,
|
|
266
|
+
...(0, util_1.def)('to_unixtime', { 'ts_val': 'timestamp' }, 'number'),
|
|
267
|
+
...(0, util_1.def)('url_extract_fragment', { 'url': 'string' }, 'string'),
|
|
268
|
+
...(0, util_1.def)('url_extract_host', { 'url': 'string' }, 'string'),
|
|
269
|
+
...(0, util_1.def)('url_extract_parameter', { 'url': 'string', 'parameter': 'string' }, 'string'),
|
|
270
|
+
...(0, util_1.def)('url_extract_path', { 'url': 'string' }, 'string'),
|
|
271
|
+
...(0, util_1.def)('url_extract_port', { 'url': 'string' }, 'number'),
|
|
272
|
+
...(0, util_1.def)('url_extract_protocol', { 'url': 'string' }, 'string'),
|
|
273
|
+
...(0, util_1.def)('url_extract_query', { 'url': 'string' }, 'string'),
|
|
380
274
|
// window functions
|
|
381
275
|
percent_rank,
|
|
382
|
-
// array
|
|
276
|
+
// array function
|
|
383
277
|
array_join,
|
|
384
278
|
sequence,
|
|
279
|
+
...(0, util_1.def)('array_distinct', { 'x': { array: T } }, { array: T }),
|
|
280
|
+
...(0, util_1.def)('array_except', { 'x': { array: T }, 'y': { array: T } }, { array: T }),
|
|
281
|
+
...(0, util_1.def)('array_intersect', { 'x': { array: T }, 'y': { array: T } }, { array: T }),
|
|
282
|
+
...(0, util_1.def)('array_max', { 'x': { array: T } }, T),
|
|
283
|
+
...(0, util_1.def)('array_min', { 'x': { array: T } }, T),
|
|
284
|
+
...(0, util_1.def)('array_normalize', { 'x': { array: T }, 'p': 'number' }, { array: T }),
|
|
285
|
+
...(0, util_1.def)('array_remove', { 'x': { array: T }, 'element': T }, { array: T }),
|
|
286
|
+
...(0, util_1.def)('array_sort', { 'x': { array: T } }, { array: T }),
|
|
287
|
+
...(0, util_1.def)('arrays_overlap', { 'x': { array: T }, 'y': { array: T } }, 'boolean'),
|
|
288
|
+
...(0, util_1.def)('array_union', { 'x': { array: T }, 'y': { array: T } }, { array: T }),
|
|
289
|
+
...(0, util_1.def)('cardinality', { 'x': { array: T } }, 'number'),
|
|
290
|
+
...(0, util_1.def)('shuffle', { 'x': { array: T } }, { array: T }),
|
|
291
|
+
...(0, util_1.def)('combinations', { 'x': { array: T }, 'n': 'number' }, { array: { array: T } }),
|
|
292
|
+
...(0, util_1.def)('contains', { 'x': { array: T }, 'element': T }, 'boolean'),
|
|
293
|
+
...(0, util_1.def)('element_at', { 'x': { array: T }, 'oridnal': 'number' }, T),
|
|
294
|
+
...(0, util_1.def)('flatten', { 'x': { array: { array: T } } }, { array: T }),
|
|
295
|
+
...(0, util_1.def)('ngrams', { 'x': { array: T }, 'n': 'number' }, { array: { array: T } }),
|
|
296
|
+
...(0, util_1.def)('repeat', { 'x': T, 'n': 'number' }, { array: T }),
|
|
297
|
+
...(0, util_1.def)('slice', { 'x': { array: T }, 'start': 'number', 'len': 'number' }, { array: T }),
|
|
298
|
+
...(0, util_1.def)('split', { to_split: 'string', seperator: 'string' }, { array: 'string' }),
|
|
299
|
+
...(0, util_1.def)('trim_array', { 'x': { array: T }, 'n': 'number' }, { array: T }),
|
|
300
|
+
...(0, util_1.def)('array_split_into_chunks', { 'x': { array: T }, 'n': 'number' }, { array: { array: T } }),
|
|
385
301
|
};
|
|
386
|
-
/**
|
|
387
|
-
* Lazy function to add wrapper blueprint definition for non overloaded functions
|
|
388
|
-
* which have generic array in their parameter list or return value
|
|
389
|
-
* @param name function name
|
|
390
|
-
* @param types list of types, last is return type
|
|
391
|
-
*/
|
|
392
|
-
function define(name, takes, returns) {
|
|
393
|
-
const newDef = {
|
|
394
|
-
takes,
|
|
395
|
-
generic: { 'T': ['any'] },
|
|
396
|
-
returns,
|
|
397
|
-
impl: { function: name.toUpperCase() },
|
|
398
|
-
};
|
|
399
|
-
exports.TRINO_DIALECT_FUNCTIONS[name] = newDef;
|
|
400
|
-
}
|
|
401
|
-
define('array_distinct', { x: { array: T } }, { array: T });
|
|
402
|
-
define('array_except', { x: { array: T }, y: { array: T } }, { array: T });
|
|
403
|
-
define('array_intersect', { x: { array: T }, y: { array: T } }, { array: T });
|
|
404
|
-
define('array_max', { x: { array: T } }, T);
|
|
405
|
-
define('array_min', { x: { array: T } }, T);
|
|
406
|
-
define('array_normalize', { x: { array: T }, p: 'number' }, { array: T });
|
|
407
|
-
define('array_remove', { x: { array: T }, element: T }, { array: T });
|
|
408
|
-
// mtoy todo document missing lambda sort
|
|
409
|
-
define('array_sort', { x: { array: T } }, { array: T });
|
|
410
|
-
define('array_split_into_chunks', { x: { array: T }, n: 'number' }, { array: { array: T } });
|
|
411
|
-
define('arrays_overlap', { x: { array: T }, y: { array: T } }, 'boolean');
|
|
412
|
-
define('array_union', { x: { array: T }, y: { array: T } }, { array: T });
|
|
413
|
-
define('cardinality', { x: { array: T } }, 'number');
|
|
414
|
-
// mtoy todo move overload version?
|
|
415
|
-
// define('reverse', {x: {array: T}}, {array: T});
|
|
416
|
-
define('shuffle', { x: { array: T } }, { array: T });
|
|
417
|
-
define('combinations', { x: { array: T }, n: 'number' }, { array: { array: T } });
|
|
418
|
-
define('contains', { x: { array: T }, element: T }, 'boolean');
|
|
419
|
-
define('element_at', { x: { array: T }, oridnal: 'number' }, T);
|
|
420
|
-
// hard to believe, but this is what flatten does
|
|
421
|
-
define('flatten', { x: { array: { array: T } } }, { array: T });
|
|
422
|
-
define('ngrams', { x: { array: T }, n: 'number' }, { array: { array: T } });
|
|
423
|
-
define('repeat', { x: T, n: 'number' }, { array: T });
|
|
424
|
-
define('slice', { x: { array: T }, start: 'number', len: 'number' }, { array: T });
|
|
425
|
-
define('split', { to_split: 'string', seperator: 'string' }, { array: 'string' });
|
|
426
|
-
define('trim_array', { x: { array: T }, n: 'number' }, { array: T });
|
|
427
302
|
/******** Presto Only *********/
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
generic: { T: ['any'] },
|
|
438
|
-
returns: 'number',
|
|
439
|
-
impl: { function: 'ARRAY_POSITION' },
|
|
440
|
-
},
|
|
441
|
-
};
|
|
442
|
-
const array_intersect = {
|
|
443
|
-
two_arrays: {
|
|
444
|
-
takes: {
|
|
445
|
-
'a': { array: T },
|
|
446
|
-
'b': { array: T },
|
|
303
|
+
exports.PRESTO_DIALECT_FUNCTIONS = {
|
|
304
|
+
...exports.TRINO_DIALECT_FUNCTIONS,
|
|
305
|
+
array_intersect: {
|
|
306
|
+
...(0, util_1.def)('array_intersect', { 'x': { array: T }, 'y': { array: T } }, { array: T }),
|
|
307
|
+
nested_array: {
|
|
308
|
+
takes: { 'x': { array: { array: T } } },
|
|
309
|
+
generic: { 'T': ['any'] },
|
|
310
|
+
returns: { array: T },
|
|
311
|
+
impl: { function: 'ARRAY_INTERSECT' },
|
|
447
312
|
},
|
|
448
|
-
generic: { 'T': ['any'] },
|
|
449
|
-
returns: { array: T },
|
|
450
|
-
impl: { function: 'ARRAY_INTERSECT' },
|
|
451
313
|
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
array_only: {
|
|
461
|
-
takes: { 'theArray': { array: T } },
|
|
462
|
-
generic: { 'T': ['any'] },
|
|
463
|
-
returns: { array: T },
|
|
464
|
-
impl: { function: 'ARRAY_LEAST_FREQUENT' },
|
|
314
|
+
array_least_frequent: {
|
|
315
|
+
...(0, util_1.def)('array_least_frequent', { 'x': { array: T } }, { array: T }),
|
|
316
|
+
bottom_n: {
|
|
317
|
+
takes: { 'array_v': { array: T }, 'n': 'number' },
|
|
318
|
+
returns: { array: T },
|
|
319
|
+
generic: { 'T': ['any'] },
|
|
320
|
+
impl: { function: 'ARRAY_LEAST_FREQUENT' },
|
|
321
|
+
},
|
|
465
322
|
},
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
'
|
|
323
|
+
array_position: {
|
|
324
|
+
...(0, util_1.def)('array_position', { 'x': { array: T }, 'el': T }, 'number'),
|
|
325
|
+
nth_instance: {
|
|
326
|
+
takes: { 'x': { array: T }, 'el': T, 'instance': 'number' },
|
|
327
|
+
generic: { 'T': ['any'] },
|
|
328
|
+
returns: 'number',
|
|
329
|
+
impl: { function: 'ARRAY_POSITION' },
|
|
470
330
|
},
|
|
471
|
-
generic: { 'T': ['any'] },
|
|
472
|
-
returns: { array: T },
|
|
473
|
-
impl: { function: 'ARRAY_LEAST_FREQUENT' },
|
|
474
331
|
},
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
...
|
|
487
|
-
array_intersect,
|
|
488
|
-
array_least_frequent,
|
|
489
|
-
array_position,
|
|
490
|
-
...def('array_average', { x: { array: T } }, 'number'),
|
|
491
|
-
...def('array_has_duplicates', { x: { array: T } }, 'boolean'),
|
|
492
|
-
...def('array_cum_sum', { numeric_array: { array: T } }, { array: 'number' }),
|
|
493
|
-
...def('array_duplicates', { x: { array: T } }, { array: T }),
|
|
494
|
-
...def('array_sum', { x: { array: T } }, 'number'),
|
|
495
|
-
...def('array_sort_desc', { x: { array: T } }, { array: T }),
|
|
496
|
-
...def('remove_nulls', { x: { array: T } }, { array: T }),
|
|
497
|
-
...def('array_top_n', { x: { array: T }, n: 'number' }, { array: T }),
|
|
332
|
+
reverse: {
|
|
333
|
+
string_reverse,
|
|
334
|
+
...(0, util_1.def)('reverse', { 'x': { array: T } }, { array: T }),
|
|
335
|
+
},
|
|
336
|
+
...(0, util_1.def)('array_average', { 'x': { array: T } }, 'number'),
|
|
337
|
+
...(0, util_1.def)('array_has_duplicates', { 'x': { array: T } }, 'boolean'),
|
|
338
|
+
...(0, util_1.def)('array_cum_sum', { numeric_array: { array: T } }, { array: 'number' }),
|
|
339
|
+
...(0, util_1.def)('array_duplicates', { 'x': { array: T } }, { array: T }),
|
|
340
|
+
...(0, util_1.def)('array_sum', { 'x': { array: T } }, 'number'),
|
|
341
|
+
...(0, util_1.def)('array_sort_desc', { 'x': { array: T } }, { array: T }),
|
|
342
|
+
...(0, util_1.def)('remove_nulls', { 'x': { array: T } }, { array: T }),
|
|
343
|
+
...(0, util_1.def)('array_top_n', { 'x': { array: T }, 'n': 'number' }, { array: T }),
|
|
498
344
|
};
|
|
499
345
|
//# sourceMappingURL=dialect_functions.js.map
|
|
@@ -28,9 +28,6 @@ exports.TRINO_MALLOY_STANDARD_OVERLOADS = {
|
|
|
28
28
|
string_repeat: {
|
|
29
29
|
sql: "ARRAY_JOIN(REPEAT(${value}, CASE WHEN ${value} IS NOT NULL THEN ${count} END),'')",
|
|
30
30
|
},
|
|
31
|
-
reverse: {
|
|
32
|
-
sql: 'REVERSE(CAST(${value} AS VARCHAR))',
|
|
33
|
-
},
|
|
34
31
|
starts_with: { sql: 'COALESCE(STARTS_WITH(${value}, ${prefix}), false)' },
|
|
35
32
|
ends_with: {
|
|
36
33
|
sql: 'COALESCE(STARTS_WITH(REVERSE(CAST(${value} AS VARCHAR)), REVERSE(CAST(${suffix} AS VARCHAR))), false)',
|