@malloydata/malloy 0.0.182-dev240911142514 → 0.0.182-dev240911163224
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/dialect.d.ts +3 -1
- package/dist/dialect/dialect_map.d.ts +1 -2
- package/dist/dialect/dialect_map.js +5 -74
- package/dist/dialect/duckdb/dialect_functions.d.ts +2 -0
- package/dist/dialect/duckdb/dialect_functions.js +67 -0
- package/dist/dialect/duckdb/duckdb.d.ts +3 -1
- package/dist/dialect/duckdb/duckdb.js +6 -5
- package/dist/dialect/duckdb/function_overrides.d.ts +2 -0
- package/dist/dialect/duckdb/function_overrides.js +55 -0
- package/dist/dialect/functions/index.d.ts +3 -1
- package/dist/dialect/functions/index.js +6 -3
- package/dist/dialect/functions/malloy_standard_functions.d.ts +134 -0
- package/dist/dialect/functions/malloy_standard_functions.js +612 -0
- package/dist/dialect/functions/util.d.ts +78 -2
- package/dist/dialect/functions/util.js +257 -3
- package/dist/dialect/index.d.ts +5 -4
- package/dist/dialect/index.js +3 -4
- package/dist/dialect/postgres/dialect_functions.d.ts +2 -0
- package/dist/dialect/postgres/dialect_functions.js +51 -0
- package/dist/dialect/postgres/function_overrides.d.ts +2 -0
- package/dist/dialect/postgres/function_overrides.js +73 -0
- package/dist/dialect/postgres/postgres.d.ts +3 -2
- package/dist/dialect/postgres/postgres.js +6 -6
- package/dist/dialect/snowflake/dialect_functions.d.ts +2 -0
- package/dist/dialect/snowflake/dialect_functions.js +57 -0
- package/dist/dialect/snowflake/function_overrides.d.ts +2 -0
- package/dist/dialect/snowflake/function_overrides.js +39 -0
- package/dist/dialect/snowflake/snowflake.d.ts +3 -2
- package/dist/dialect/snowflake/snowflake.js +6 -6
- package/dist/dialect/standardsql/dialect_functions.d.ts +2 -0
- package/dist/dialect/standardsql/dialect_functions.js +65 -0
- package/dist/dialect/standardsql/function_overrides.d.ts +2 -0
- package/dist/dialect/standardsql/function_overrides.js +17 -0
- package/dist/dialect/standardsql/standardsql.d.ts +3 -1
- package/dist/dialect/standardsql/standardsql.js +6 -5
- package/dist/dialect/trino/dialect_functions.d.ts +2 -0
- package/dist/dialect/trino/dialect_functions.js +63 -0
- package/dist/dialect/trino/function_overrides.d.ts +2 -0
- package/dist/dialect/trino/function_overrides.js +50 -0
- package/dist/dialect/trino/trino.d.ts +3 -1
- package/dist/dialect/trino/trino.js +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -4
- package/dist/lang/ast/expressions/expr-func.js +25 -29
- package/dist/lang/ast/types/dialect-name-space.js +5 -5
- package/dist/lang/ast/types/global-name-space.d.ts +4 -2
- package/dist/lang/ast/types/global-name-space.js +59 -6
- package/dist/model/malloy_query.d.ts +1 -1
- package/dist/model/malloy_query.js +7 -6
- package/dist/model/malloy_types.d.ts +7 -7
- package/package.json +1 -1
- package/dist/dialect/duckdb/functions/byte_length.d.ts +0 -2
- package/dist/dialect/duckdb/functions/byte_length.js +0 -33
- package/dist/dialect/duckdb/functions/count_approx.d.ts +0 -2
- package/dist/dialect/duckdb/functions/count_approx.js +0 -20
- package/dist/dialect/duckdb/functions/dialect_functions.d.ts +0 -4
- package/dist/dialect/duckdb/functions/dialect_functions.js +0 -16
- package/dist/dialect/duckdb/functions/div.d.ts +0 -2
- package/dist/dialect/duckdb/functions/div.js +0 -38
- package/dist/dialect/duckdb/functions/duckdb_functions.d.ts +0 -1
- package/dist/dialect/duckdb/functions/duckdb_functions.js +0 -54
- package/dist/dialect/duckdb/functions/ends_with.d.ts +0 -2
- package/dist/dialect/duckdb/functions/ends_with.js +0 -35
- package/dist/dialect/duckdb/functions/greatest_and_least.d.ts +0 -3
- package/dist/dialect/duckdb/functions/greatest_and_least.js +0 -51
- package/dist/dialect/duckdb/functions/index.d.ts +0 -1
- package/dist/dialect/duckdb/functions/index.js +0 -28
- package/dist/dialect/duckdb/functions/is_inf.d.ts +0 -2
- package/dist/dialect/duckdb/functions/is_inf.js +0 -33
- package/dist/dialect/duckdb/functions/is_nan.d.ts +0 -2
- package/dist/dialect/duckdb/functions/is_nan.js +0 -33
- package/dist/dialect/duckdb/functions/log.d.ts +0 -2
- package/dist/dialect/duckdb/functions/log.js +0 -38
- package/dist/dialect/duckdb/functions/rand.d.ts +0 -2
- package/dist/dialect/duckdb/functions/rand.js +0 -31
- package/dist/dialect/duckdb/functions/replace.d.ts +0 -2
- package/dist/dialect/duckdb/functions/replace.js +0 -40
- package/dist/dialect/duckdb/functions/trunc.d.ts +0 -2
- package/dist/dialect/duckdb/functions/trunc.js +0 -39
- package/dist/dialect/duckdb/functions/unicode.d.ts +0 -2
- package/dist/dialect/duckdb/functions/unicode.js +0 -35
- package/dist/dialect/functions/all_functions.d.ts +0 -8
- package/dist/dialect/functions/all_functions.js +0 -146
- package/dist/dialect/functions/atan2.d.ts +0 -2
- package/dist/dialect/functions/atan2.js +0 -33
- package/dist/dialect/functions/avg_moving.d.ts +0 -2
- package/dist/dialect/functions/avg_moving.js +0 -46
- package/dist/dialect/functions/chr.d.ts +0 -4
- package/dist/dialect/functions/chr.js +0 -45
- package/dist/dialect/functions/coalesce.d.ts +0 -2
- package/dist/dialect/functions/coalesce.js +0 -38
- package/dist/dialect/functions/concat.d.ts +0 -2
- package/dist/dialect/functions/concat.js +0 -38
- package/dist/dialect/functions/div.d.ts +0 -2
- package/dist/dialect/functions/div.js +0 -36
- package/dist/dialect/functions/first_value_window.d.ts +0 -3
- package/dist/dialect/functions/first_value_window.js +0 -49
- package/dist/dialect/functions/function_map.d.ts +0 -16
- package/dist/dialect/functions/function_map.js +0 -72
- package/dist/dialect/functions/greatest_and_least.d.ts +0 -3
- package/dist/dialect/functions/greatest_and_least.js +0 -44
- package/dist/dialect/functions/ifnull.d.ts +0 -2
- package/dist/dialect/functions/ifnull.js +0 -38
- package/dist/dialect/functions/is_inf.d.ts +0 -2
- package/dist/dialect/functions/is_inf.js +0 -33
- package/dist/dialect/functions/is_nan.d.ts +0 -2
- package/dist/dialect/functions/is_nan.js +0 -33
- package/dist/dialect/functions/lag.d.ts +0 -2
- package/dist/dialect/functions/lag.js +0 -53
- package/dist/dialect/functions/lead.d.ts +0 -2
- package/dist/dialect/functions/lead.js +0 -50
- package/dist/dialect/functions/length.d.ts +0 -3
- package/dist/dialect/functions/length.js +0 -40
- package/dist/dialect/functions/log.d.ts +0 -2
- package/dist/dialect/functions/log.js +0 -35
- package/dist/dialect/functions/lower.d.ts +0 -2
- package/dist/dialect/functions/lower.js +0 -34
- package/dist/dialect/functions/nullif.d.ts +0 -2
- package/dist/dialect/functions/nullif.js +0 -42
- package/dist/dialect/functions/pi.d.ts +0 -2
- package/dist/dialect/functions/pi.js +0 -31
- package/dist/dialect/functions/pow.d.ts +0 -2
- package/dist/dialect/functions/pow.js +0 -35
- package/dist/dialect/functions/rand.d.ts +0 -2
- package/dist/dialect/functions/rand.js +0 -31
- package/dist/dialect/functions/rank.d.ts +0 -2
- package/dist/dialect/functions/rank.js +0 -36
- package/dist/dialect/functions/regexp_extract.d.ts +0 -2
- package/dist/dialect/functions/regexp_extract.js +0 -41
- package/dist/dialect/functions/repeat.d.ts +0 -2
- package/dist/dialect/functions/repeat.js +0 -35
- package/dist/dialect/functions/replace.d.ts +0 -2
- package/dist/dialect/functions/replace.js +0 -42
- package/dist/dialect/functions/reverse.d.ts +0 -2
- package/dist/dialect/functions/reverse.js +0 -34
- package/dist/dialect/functions/round.d.ts +0 -2
- package/dist/dialect/functions/round.js +0 -40
- package/dist/dialect/functions/row_number.d.ts +0 -2
- package/dist/dialect/functions/row_number.js +0 -40
- package/dist/dialect/functions/simple_numeric_functions.d.ts +0 -15
- package/dist/dialect/functions/simple_numeric_functions.js +0 -60
- package/dist/dialect/functions/sql.d.ts +0 -6
- package/dist/dialect/functions/sql.js +0 -52
- package/dist/dialect/functions/starts_ends_with.d.ts +0 -3
- package/dist/dialect/functions/starts_ends_with.js +0 -43
- package/dist/dialect/functions/stddev.d.ts +0 -2
- package/dist/dialect/functions/stddev.js +0 -34
- package/dist/dialect/functions/string_agg.d.ts +0 -3
- package/dist/dialect/functions/string_agg.js +0 -55
- package/dist/dialect/functions/strpos.d.ts +0 -2
- package/dist/dialect/functions/strpos.js +0 -35
- package/dist/dialect/functions/substr.d.ts +0 -2
- package/dist/dialect/functions/substr.js +0 -37
- package/dist/dialect/functions/sum_min_max_window.d.ts +0 -7
- package/dist/dialect/functions/sum_min_max_window.js +0 -94
- package/dist/dialect/functions/sum_moving.d.ts +0 -2
- package/dist/dialect/functions/sum_moving.js +0 -43
- package/dist/dialect/functions/trim_functions.d.ts +0 -4
- package/dist/dialect/functions/trim_functions.js +0 -42
- package/dist/dialect/functions/trunc.d.ts +0 -2
- package/dist/dialect/functions/trunc.js +0 -38
- package/dist/dialect/functions/upper.d.ts +0 -2
- package/dist/dialect/functions/upper.js +0 -34
- package/dist/dialect/postgres/functions/byte_length.d.ts +0 -2
- package/dist/dialect/postgres/functions/byte_length.js +0 -33
- package/dist/dialect/postgres/functions/dialect_functions.d.ts +0 -4
- package/dist/dialect/postgres/functions/dialect_functions.js +0 -11
- package/dist/dialect/postgres/functions/ends_with.d.ts +0 -2
- package/dist/dialect/postgres/functions/ends_with.js +0 -38
- package/dist/dialect/postgres/functions/greatest_and_least.d.ts +0 -3
- package/dist/dialect/postgres/functions/greatest_and_least.js +0 -43
- package/dist/dialect/postgres/functions/ifnull.d.ts +0 -2
- package/dist/dialect/postgres/functions/ifnull.js +0 -40
- package/dist/dialect/postgres/functions/index.d.ts +0 -1
- package/dist/dialect/postgres/functions/index.js +0 -28
- package/dist/dialect/postgres/functions/is_inf.d.ts +0 -2
- package/dist/dialect/postgres/functions/is_inf.js +0 -34
- package/dist/dialect/postgres/functions/is_nan.d.ts +0 -2
- package/dist/dialect/postgres/functions/is_nan.js +0 -33
- package/dist/dialect/postgres/functions/log.d.ts +0 -2
- package/dist/dialect/postgres/functions/log.js +0 -37
- package/dist/dialect/postgres/functions/postgres_functions.d.ts +0 -1
- package/dist/dialect/postgres/functions/postgres_functions.js +0 -63
- package/dist/dialect/postgres/functions/rand.d.ts +0 -2
- package/dist/dialect/postgres/functions/rand.js +0 -31
- package/dist/dialect/postgres/functions/regexp_extract.d.ts +0 -2
- package/dist/dialect/postgres/functions/regexp_extract.js +0 -35
- package/dist/dialect/postgres/functions/replace.d.ts +0 -2
- package/dist/dialect/postgres/functions/replace.js +0 -40
- package/dist/dialect/postgres/functions/round.d.ts +0 -2
- package/dist/dialect/postgres/functions/round.js +0 -39
- package/dist/dialect/postgres/functions/stddev.d.ts +0 -2
- package/dist/dialect/postgres/functions/stddev.js +0 -37
- package/dist/dialect/postgres/functions/string_agg.d.ts +0 -3
- package/dist/dialect/postgres/functions/string_agg.js +0 -55
- package/dist/dialect/postgres/functions/substr.d.ts +0 -2
- package/dist/dialect/postgres/functions/substr.js +0 -38
- package/dist/dialect/postgres/functions/trunc.d.ts +0 -2
- package/dist/dialect/postgres/functions/trunc.js +0 -40
- package/dist/dialect/postgres/functions/unicode.d.ts +0 -2
- package/dist/dialect/postgres/functions/unicode.js +0 -34
- package/dist/dialect/snowflake/functions/chr.d.ts +0 -2
- package/dist/dialect/snowflake/functions/chr.js +0 -36
- package/dist/dialect/snowflake/functions/dialect_functions.d.ts +0 -4
- package/dist/dialect/snowflake/functions/dialect_functions.js +0 -11
- package/dist/dialect/snowflake/functions/div.d.ts +0 -2
- package/dist/dialect/snowflake/functions/div.js +0 -37
- package/dist/dialect/snowflake/functions/index.d.ts +0 -1
- package/dist/dialect/snowflake/functions/index.js +0 -28
- package/dist/dialect/snowflake/functions/is_inf.d.ts +0 -2
- package/dist/dialect/snowflake/functions/is_inf.js +0 -34
- package/dist/dialect/snowflake/functions/is_nan.d.ts +0 -2
- package/dist/dialect/snowflake/functions/is_nan.js +0 -33
- package/dist/dialect/snowflake/functions/length.d.ts +0 -3
- package/dist/dialect/snowflake/functions/length.js +0 -39
- package/dist/dialect/snowflake/functions/log.d.ts +0 -2
- package/dist/dialect/snowflake/functions/log.js +0 -37
- package/dist/dialect/snowflake/functions/rand.d.ts +0 -2
- package/dist/dialect/snowflake/functions/rand.js +0 -33
- package/dist/dialect/snowflake/functions/regexp_extract.d.ts +0 -2
- package/dist/dialect/snowflake/functions/regexp_extract.js +0 -35
- package/dist/dialect/snowflake/functions/snowflake_functions.d.ts +0 -1
- package/dist/dialect/snowflake/functions/snowflake_functions.js +0 -56
- package/dist/dialect/snowflake/functions/starts_ends_with.d.ts +0 -3
- package/dist/dialect/snowflake/functions/starts_ends_with.js +0 -43
- package/dist/dialect/snowflake/functions/string_agg.d.ts +0 -3
- package/dist/dialect/snowflake/functions/string_agg.js +0 -55
- package/dist/dialect/snowflake/functions/strpos.d.ts +0 -2
- package/dist/dialect/snowflake/functions/strpos.js +0 -35
- package/dist/dialect/snowflake/functions/trunc.d.ts +0 -2
- package/dist/dialect/snowflake/functions/trunc.js +0 -39
- package/dist/dialect/standardsql/functions/chr.d.ts +0 -2
- package/dist/dialect/standardsql/functions/chr.js +0 -37
- package/dist/dialect/standardsql/functions/dialect_functions.d.ts +0 -4
- package/dist/dialect/standardsql/functions/dialect_functions.js +0 -16
- package/dist/dialect/standardsql/functions/index.d.ts +0 -1
- package/dist/dialect/standardsql/functions/index.js +0 -28
- package/dist/dialect/standardsql/functions/pi.d.ts +0 -2
- package/dist/dialect/standardsql/functions/pi.js +0 -32
- package/dist/dialect/standardsql/functions/standardsql_functions.d.ts +0 -1
- package/dist/dialect/standardsql/functions/standardsql_functions.js +0 -36
- package/dist/dialect/standardsql/functions/string_agg.d.ts +0 -3
- package/dist/dialect/standardsql/functions/string_agg.js +0 -59
- package/dist/dialect/trino/functions/byte_length.d.ts +0 -2
- package/dist/dialect/trino/functions/byte_length.js +0 -33
- package/dist/dialect/trino/functions/chr.d.ts +0 -4
- package/dist/dialect/trino/functions/chr.js +0 -45
- package/dist/dialect/trino/functions/concat.d.ts +0 -2
- package/dist/dialect/trino/functions/concat.js +0 -38
- package/dist/dialect/trino/functions/count_approx.d.ts +0 -2
- package/dist/dialect/trino/functions/count_approx.js +0 -20
- package/dist/dialect/trino/functions/dialect_functions.d.ts +0 -4
- package/dist/dialect/trino/functions/dialect_functions.js +0 -16
- package/dist/dialect/trino/functions/div.d.ts +0 -2
- package/dist/dialect/trino/functions/div.js +0 -36
- package/dist/dialect/trino/functions/ifnull.d.ts +0 -2
- package/dist/dialect/trino/functions/ifnull.js +0 -40
- package/dist/dialect/trino/functions/index.d.ts +0 -1
- package/dist/dialect/trino/functions/index.js +0 -28
- package/dist/dialect/trino/functions/is_inf.d.ts +0 -2
- package/dist/dialect/trino/functions/is_inf.js +0 -33
- package/dist/dialect/trino/functions/log.d.ts +0 -2
- package/dist/dialect/trino/functions/log.js +0 -37
- package/dist/dialect/trino/functions/repeat.d.ts +0 -2
- package/dist/dialect/trino/functions/repeat.js +0 -35
- package/dist/dialect/trino/functions/reverse.d.ts +0 -2
- package/dist/dialect/trino/functions/reverse.js +0 -34
- package/dist/dialect/trino/functions/starts_ends_with.d.ts +0 -3
- package/dist/dialect/trino/functions/starts_ends_with.js +0 -43
- package/dist/dialect/trino/functions/string_agg.d.ts +0 -3
- package/dist/dialect/trino/functions/string_agg.js +0 -55
- package/dist/dialect/trino/functions/trino_functions.d.ts +0 -1
- package/dist/dialect/trino/functions/trino_functions.js +0 -59
- package/dist/dialect/trino/functions/trunc.d.ts +0 -2
- package/dist/dialect/trino/functions/trunc.js +0 -39
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.expandOverrideMap = exports.getMalloyStandardFunctions = exports.MALLOY_STANDARD_FUNCTIONS = void 0;
|
|
10
|
+
const util_1 = require("./util");
|
|
11
|
+
const abs = {
|
|
12
|
+
takes: { 'value': 'number' },
|
|
13
|
+
returns: 'number',
|
|
14
|
+
impl: { function: 'ABS' },
|
|
15
|
+
};
|
|
16
|
+
const acos = {
|
|
17
|
+
takes: { 'value': 'number' },
|
|
18
|
+
returns: 'number',
|
|
19
|
+
impl: { function: 'ACOS' },
|
|
20
|
+
};
|
|
21
|
+
const ascii = {
|
|
22
|
+
takes: { 'value': 'string' },
|
|
23
|
+
returns: 'number',
|
|
24
|
+
impl: { function: 'ASCII' },
|
|
25
|
+
};
|
|
26
|
+
const asin = {
|
|
27
|
+
takes: { 'value': 'number' },
|
|
28
|
+
returns: 'number',
|
|
29
|
+
impl: { function: 'ASIN' },
|
|
30
|
+
};
|
|
31
|
+
const atan2 = {
|
|
32
|
+
takes: { 'y': 'number', 'x': 'number' },
|
|
33
|
+
returns: 'number',
|
|
34
|
+
impl: { function: 'ATAN2' },
|
|
35
|
+
};
|
|
36
|
+
const atan = {
|
|
37
|
+
takes: { 'value': 'number' },
|
|
38
|
+
returns: 'number',
|
|
39
|
+
impl: { function: 'ATAN' },
|
|
40
|
+
};
|
|
41
|
+
const byte_length = {
|
|
42
|
+
takes: { 'value': 'string' },
|
|
43
|
+
returns: 'number',
|
|
44
|
+
impl: { function: 'BYTE_LENGTH' },
|
|
45
|
+
};
|
|
46
|
+
const ceil = {
|
|
47
|
+
takes: { 'value': 'number' },
|
|
48
|
+
returns: 'number',
|
|
49
|
+
impl: { function: 'CEIL' },
|
|
50
|
+
};
|
|
51
|
+
const chr = {
|
|
52
|
+
takes: { 'value': 'number' },
|
|
53
|
+
returns: 'string',
|
|
54
|
+
impl: { sql: "CASE WHEN ${value} = 0 THEN '' ELSE CHR(${value}) END" },
|
|
55
|
+
};
|
|
56
|
+
const coalesce = {
|
|
57
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
58
|
+
takes: { 'value': { variadic: { generic: 'T' } } },
|
|
59
|
+
returns: { generic: 'T' },
|
|
60
|
+
impl: { function: 'COALESCE' },
|
|
61
|
+
};
|
|
62
|
+
const concat = {
|
|
63
|
+
'empty': {
|
|
64
|
+
takes: {},
|
|
65
|
+
returns: 'string',
|
|
66
|
+
impl: { expr: { node: 'stringLiteral', literal: '' } },
|
|
67
|
+
},
|
|
68
|
+
'variadic': {
|
|
69
|
+
takes: {
|
|
70
|
+
'values': {
|
|
71
|
+
variadic: ['string', 'number', 'date', 'timestamp', 'boolean'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
returns: 'string',
|
|
75
|
+
impl: { function: 'CONCAT' },
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const cos = {
|
|
79
|
+
takes: { 'value': 'number' },
|
|
80
|
+
returns: 'number',
|
|
81
|
+
impl: { function: 'COS' },
|
|
82
|
+
};
|
|
83
|
+
const div = {
|
|
84
|
+
takes: { 'dividend': 'number', 'divisor': 'number' },
|
|
85
|
+
returns: 'number',
|
|
86
|
+
impl: { function: 'DIV' },
|
|
87
|
+
};
|
|
88
|
+
const ends_with = {
|
|
89
|
+
takes: { 'value': 'string', 'suffix': 'string' },
|
|
90
|
+
returns: 'boolean',
|
|
91
|
+
impl: { sql: 'COALESCE(ENDS_WITH(${value}, ${suffix}), false)' },
|
|
92
|
+
};
|
|
93
|
+
const exp = {
|
|
94
|
+
takes: { 'value': 'number' },
|
|
95
|
+
returns: 'number',
|
|
96
|
+
impl: { function: 'EXP' },
|
|
97
|
+
};
|
|
98
|
+
const floor = {
|
|
99
|
+
takes: { 'value': 'number' },
|
|
100
|
+
returns: 'number',
|
|
101
|
+
impl: { function: 'FLOOR' },
|
|
102
|
+
};
|
|
103
|
+
const greatest = {
|
|
104
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
105
|
+
takes: { 'values': { variadic: { generic: 'T' } } },
|
|
106
|
+
returns: { generic: 'T' },
|
|
107
|
+
impl: { function: 'GREATEST' },
|
|
108
|
+
};
|
|
109
|
+
const ifnull = {
|
|
110
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
111
|
+
takes: { 'value': { generic: 'T' }, 'default': { generic: 'T' } },
|
|
112
|
+
returns: { generic: 'T' },
|
|
113
|
+
impl: { function: 'IFNULL' },
|
|
114
|
+
};
|
|
115
|
+
const is_inf = {
|
|
116
|
+
takes: { 'value': 'number' },
|
|
117
|
+
returns: 'boolean',
|
|
118
|
+
impl: { sql: 'COALESCE(IS_INF(${value}), false)' },
|
|
119
|
+
};
|
|
120
|
+
const is_nan = {
|
|
121
|
+
takes: { 'value': 'number' },
|
|
122
|
+
returns: 'boolean',
|
|
123
|
+
impl: { sql: 'COALESCE(IS_NAN(${value}), false)' },
|
|
124
|
+
};
|
|
125
|
+
const least = {
|
|
126
|
+
...greatest,
|
|
127
|
+
impl: { function: 'LEAST' },
|
|
128
|
+
};
|
|
129
|
+
const length = {
|
|
130
|
+
takes: { 'value': 'string' },
|
|
131
|
+
returns: 'number',
|
|
132
|
+
impl: { function: 'LENGTH' },
|
|
133
|
+
};
|
|
134
|
+
const ln = {
|
|
135
|
+
takes: { 'value': 'number' },
|
|
136
|
+
returns: 'number',
|
|
137
|
+
impl: { function: 'LN' },
|
|
138
|
+
};
|
|
139
|
+
const log = {
|
|
140
|
+
takes: {
|
|
141
|
+
'value': 'number',
|
|
142
|
+
'base': 'number',
|
|
143
|
+
},
|
|
144
|
+
returns: 'number',
|
|
145
|
+
impl: { function: 'LOG' },
|
|
146
|
+
};
|
|
147
|
+
const lower = {
|
|
148
|
+
takes: { 'value': 'string' },
|
|
149
|
+
returns: 'string',
|
|
150
|
+
impl: { function: 'LOWER' },
|
|
151
|
+
};
|
|
152
|
+
const ltrim = {
|
|
153
|
+
'whitespace': {
|
|
154
|
+
takes: { 'value': 'string' },
|
|
155
|
+
returns: 'string',
|
|
156
|
+
impl: { function: 'LTRIM' },
|
|
157
|
+
},
|
|
158
|
+
'characters': {
|
|
159
|
+
takes: { 'value': 'string', 'trim_characters': 'string' },
|
|
160
|
+
returns: 'string',
|
|
161
|
+
impl: { function: 'LTRIM' },
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
const nullif = {
|
|
165
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
166
|
+
takes: { 'value1': { generic: 'T' }, 'value2': { generic: 'T' } },
|
|
167
|
+
returns: { generic: 'T' },
|
|
168
|
+
impl: { function: 'NULLIF' },
|
|
169
|
+
};
|
|
170
|
+
const pi = {
|
|
171
|
+
takes: {},
|
|
172
|
+
returns: 'number',
|
|
173
|
+
impl: { function: 'PI' },
|
|
174
|
+
};
|
|
175
|
+
const pow = {
|
|
176
|
+
takes: { 'base': 'number', 'exponent': 'number' },
|
|
177
|
+
returns: 'number',
|
|
178
|
+
impl: { function: 'POW' },
|
|
179
|
+
};
|
|
180
|
+
const rand = {
|
|
181
|
+
takes: {},
|
|
182
|
+
returns: 'number',
|
|
183
|
+
impl: { function: 'RAND' },
|
|
184
|
+
};
|
|
185
|
+
const regexp_extract = {
|
|
186
|
+
// TODO consider supporting these parameters
|
|
187
|
+
// 'position': 'number',
|
|
188
|
+
// 'occurrence': 'number',
|
|
189
|
+
takes: { 'value': 'string', 'pattern': 'regular expression' },
|
|
190
|
+
returns: 'string',
|
|
191
|
+
impl: { function: 'REGEXP_EXTRACT' },
|
|
192
|
+
};
|
|
193
|
+
const repeat = {
|
|
194
|
+
takes: { 'value': 'string', 'count': 'number' },
|
|
195
|
+
returns: 'string',
|
|
196
|
+
impl: { function: 'REPEAT' },
|
|
197
|
+
};
|
|
198
|
+
// TODO maybe we need to have a parameter to say whether it's a global replacement or not...
|
|
199
|
+
const replace = {
|
|
200
|
+
'string': {
|
|
201
|
+
takes: { 'value': 'string', 'pattern': 'string', 'replacement': 'string' },
|
|
202
|
+
returns: 'string',
|
|
203
|
+
impl: { function: 'REPLACE' },
|
|
204
|
+
},
|
|
205
|
+
// TODO perhaps this should be a separate `regexp_replace` function.
|
|
206
|
+
// Which would better match BQ, but I think it should be just a different
|
|
207
|
+
// overload of `replace` (how it is here):
|
|
208
|
+
'regular_expression': {
|
|
209
|
+
takes: {
|
|
210
|
+
'value': 'string',
|
|
211
|
+
'pattern': 'regular expression',
|
|
212
|
+
'replacement': 'string',
|
|
213
|
+
},
|
|
214
|
+
returns: 'string',
|
|
215
|
+
impl: { function: 'REGEXP_REPLACE' },
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
const reverse = {
|
|
219
|
+
takes: { 'value': 'string' },
|
|
220
|
+
returns: 'string',
|
|
221
|
+
impl: { function: 'REVERSE' },
|
|
222
|
+
};
|
|
223
|
+
const round = {
|
|
224
|
+
'to_integer': {
|
|
225
|
+
takes: { 'value': 'number' },
|
|
226
|
+
returns: 'number',
|
|
227
|
+
impl: { function: 'ROUND' },
|
|
228
|
+
},
|
|
229
|
+
// TODO Consider adding a third overload for round(x, y, mode), where
|
|
230
|
+
// "mode" is "ROUND_HALF_AWAY_FROM_ZERO" or "ROUND_HALF_EVEN"
|
|
231
|
+
// TODO precision should only accept integers, but we don't have a good
|
|
232
|
+
// way of expressing that constraint at the moment
|
|
233
|
+
'to_precision': {
|
|
234
|
+
takes: { 'value': 'number', 'precision': 'number' },
|
|
235
|
+
returns: 'number',
|
|
236
|
+
impl: { function: 'ROUND' },
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
const rtrim = {
|
|
240
|
+
'whitespace': {
|
|
241
|
+
...ltrim['whitespace'],
|
|
242
|
+
impl: { function: 'RTRIM' },
|
|
243
|
+
},
|
|
244
|
+
'characters': {
|
|
245
|
+
...ltrim['characters'],
|
|
246
|
+
impl: { function: 'RTRIM' },
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
const sign = {
|
|
250
|
+
takes: { 'value': 'number' },
|
|
251
|
+
returns: 'number',
|
|
252
|
+
impl: { function: 'SIGN' },
|
|
253
|
+
};
|
|
254
|
+
const sin = {
|
|
255
|
+
takes: { 'value': 'number' },
|
|
256
|
+
returns: 'number',
|
|
257
|
+
impl: { function: 'SIN' },
|
|
258
|
+
};
|
|
259
|
+
const sqrt = {
|
|
260
|
+
takes: { 'value': 'number' },
|
|
261
|
+
returns: 'number',
|
|
262
|
+
impl: { function: 'SQRT' },
|
|
263
|
+
};
|
|
264
|
+
const starts_with = {
|
|
265
|
+
takes: { 'value': 'string', 'prefix': 'string' },
|
|
266
|
+
returns: 'boolean',
|
|
267
|
+
impl: { sql: 'COALESCE(STARTS_WITH(${value}, ${prefix}), false)' },
|
|
268
|
+
};
|
|
269
|
+
const strpos = {
|
|
270
|
+
takes: { 'test_string': 'string', 'search_string': 'string' },
|
|
271
|
+
returns: 'number',
|
|
272
|
+
impl: { function: 'STRPOS' },
|
|
273
|
+
};
|
|
274
|
+
const substr = {
|
|
275
|
+
'position_only': {
|
|
276
|
+
takes: { 'value': 'string', 'position': 'number' },
|
|
277
|
+
returns: 'string',
|
|
278
|
+
impl: { function: 'SUBSTR' },
|
|
279
|
+
},
|
|
280
|
+
'with_length': {
|
|
281
|
+
takes: { 'value': 'string', 'position': 'number', 'length': 'number' },
|
|
282
|
+
returns: 'string',
|
|
283
|
+
impl: { function: 'SUBSTR' },
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
const tan = {
|
|
287
|
+
takes: { 'value': 'number' },
|
|
288
|
+
returns: 'number',
|
|
289
|
+
impl: { function: 'TAN' },
|
|
290
|
+
};
|
|
291
|
+
const trim = {
|
|
292
|
+
'whitespace': {
|
|
293
|
+
...ltrim['whitespace'],
|
|
294
|
+
impl: { function: 'TRIM' },
|
|
295
|
+
},
|
|
296
|
+
'characters': {
|
|
297
|
+
...ltrim['characters'],
|
|
298
|
+
impl: { function: 'TRIM' },
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
const trunc = {
|
|
302
|
+
'to_integer': {
|
|
303
|
+
takes: { 'value': 'number' },
|
|
304
|
+
returns: 'number',
|
|
305
|
+
impl: { function: 'TRUNC' },
|
|
306
|
+
},
|
|
307
|
+
// TODO precision should only accept integers, but we don't have a good
|
|
308
|
+
// way of expressing that constraint at the moment
|
|
309
|
+
'to_precision': {
|
|
310
|
+
takes: { 'value': 'number', 'precision': 'number' },
|
|
311
|
+
returns: 'number',
|
|
312
|
+
impl: { function: 'TRUNC' },
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
const unicode = {
|
|
316
|
+
takes: { 'value': 'string' },
|
|
317
|
+
returns: 'number',
|
|
318
|
+
impl: { function: 'UNICODE' },
|
|
319
|
+
};
|
|
320
|
+
const upper = {
|
|
321
|
+
takes: { 'value': 'string' },
|
|
322
|
+
returns: 'string',
|
|
323
|
+
impl: { function: 'UPPER' },
|
|
324
|
+
};
|
|
325
|
+
// Aggregate functions
|
|
326
|
+
const stddev = {
|
|
327
|
+
takes: { 'value': { dimension: 'number' } },
|
|
328
|
+
returns: { measure: 'number' },
|
|
329
|
+
impl: { function: 'STDDEV' },
|
|
330
|
+
};
|
|
331
|
+
// Analytic functions
|
|
332
|
+
const avg_moving = {
|
|
333
|
+
'preceding': {
|
|
334
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
335
|
+
takes: {
|
|
336
|
+
'value': { measure: { generic: 'T' } },
|
|
337
|
+
'preceding': { literal: 'number' },
|
|
338
|
+
},
|
|
339
|
+
returns: { calculation: { generic: 'T' } },
|
|
340
|
+
impl: {
|
|
341
|
+
sql: 'AVG(${value})',
|
|
342
|
+
needsWindowOrderBy: true,
|
|
343
|
+
between: { preceding: 'preceding', following: 0 },
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
'following': {
|
|
347
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
348
|
+
takes: {
|
|
349
|
+
'value': { measure: { generic: 'T' } },
|
|
350
|
+
'preceding': { literal: 'number' },
|
|
351
|
+
'following': { literal: 'number' },
|
|
352
|
+
},
|
|
353
|
+
returns: { calculation: { generic: 'T' } },
|
|
354
|
+
impl: {
|
|
355
|
+
sql: 'AVG(${value})',
|
|
356
|
+
needsWindowOrderBy: true,
|
|
357
|
+
between: { preceding: 'preceding', following: 'following' },
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
const first_value = {
|
|
362
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
363
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
364
|
+
returns: { calculation: { generic: 'T' } },
|
|
365
|
+
impl: { function: 'FIRST_VALUE', needsWindowOrderBy: true },
|
|
366
|
+
};
|
|
367
|
+
const LAG_TYPES = [
|
|
368
|
+
'string',
|
|
369
|
+
'number',
|
|
370
|
+
'timestamp',
|
|
371
|
+
'date',
|
|
372
|
+
'json',
|
|
373
|
+
'boolean',
|
|
374
|
+
];
|
|
375
|
+
const lag = {
|
|
376
|
+
'bare': {
|
|
377
|
+
generic: ['T', LAG_TYPES],
|
|
378
|
+
takes: {
|
|
379
|
+
'value': { measure: { generic: 'T' } },
|
|
380
|
+
},
|
|
381
|
+
returns: { calculation: { generic: 'T' } },
|
|
382
|
+
impl: { function: 'LAG', needsWindowOrderBy: true },
|
|
383
|
+
},
|
|
384
|
+
'with_offset': {
|
|
385
|
+
generic: ['T', LAG_TYPES],
|
|
386
|
+
takes: {
|
|
387
|
+
'value': { measure: { generic: 'T' } },
|
|
388
|
+
'offset': { literal: 'number' },
|
|
389
|
+
},
|
|
390
|
+
returns: { calculation: { generic: 'T' } },
|
|
391
|
+
impl: { function: 'LAG', needsWindowOrderBy: true },
|
|
392
|
+
},
|
|
393
|
+
'with_default': {
|
|
394
|
+
generic: ['T', LAG_TYPES],
|
|
395
|
+
takes: {
|
|
396
|
+
'value': { measure: { generic: 'T' } },
|
|
397
|
+
'offset': { literal: 'number' },
|
|
398
|
+
'default': { constant: { generic: 'T' } }, // TODO needs to be constant max aggregate?
|
|
399
|
+
},
|
|
400
|
+
returns: { calculation: { generic: 'T' } },
|
|
401
|
+
impl: { function: 'LAG', needsWindowOrderBy: true },
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
const last_value = {
|
|
405
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date', 'json']],
|
|
406
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
407
|
+
returns: { calculation: { generic: 'T' } },
|
|
408
|
+
impl: {
|
|
409
|
+
function: 'LAST_VALUE',
|
|
410
|
+
needsWindowOrderBy: true,
|
|
411
|
+
between: { preceding: -1, following: -1 },
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
const lead = {
|
|
415
|
+
'bare': {
|
|
416
|
+
...lag['bare'],
|
|
417
|
+
impl: { function: 'LEAD', needsWindowOrderBy: true },
|
|
418
|
+
},
|
|
419
|
+
'with_offset': {
|
|
420
|
+
...lag['with_offset'],
|
|
421
|
+
impl: { function: 'LEAD', needsWindowOrderBy: true },
|
|
422
|
+
},
|
|
423
|
+
'with_default': {
|
|
424
|
+
...lag['with_default'],
|
|
425
|
+
impl: { function: 'LEAD', needsWindowOrderBy: true },
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
const max_cumulative = {
|
|
429
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
430
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
431
|
+
returns: { calculation: { generic: 'T' } },
|
|
432
|
+
impl: { function: 'MAX', needsWindowOrderBy: true },
|
|
433
|
+
};
|
|
434
|
+
const max_window = {
|
|
435
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
436
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
437
|
+
returns: { calculation: { generic: 'T' } },
|
|
438
|
+
impl: { function: 'MAX', needsWindowOrderBy: false },
|
|
439
|
+
};
|
|
440
|
+
const min_cumulative = {
|
|
441
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
442
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
443
|
+
returns: { calculation: { generic: 'T' } },
|
|
444
|
+
impl: { function: 'MIN', needsWindowOrderBy: true },
|
|
445
|
+
};
|
|
446
|
+
const min_window = {
|
|
447
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
448
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
449
|
+
returns: { calculation: { generic: 'T' } },
|
|
450
|
+
impl: { function: 'MIN', needsWindowOrderBy: false },
|
|
451
|
+
};
|
|
452
|
+
// TODO would you ever want to rank by a different thing than the order by?
|
|
453
|
+
const rank = {
|
|
454
|
+
takes: {},
|
|
455
|
+
returns: { calculation: 'number' },
|
|
456
|
+
impl: { function: 'RANK', needsWindowOrderBy: true },
|
|
457
|
+
};
|
|
458
|
+
const row_number = {
|
|
459
|
+
takes: {},
|
|
460
|
+
returns: { calculation: 'number' },
|
|
461
|
+
impl: { function: 'ROW_NUMBER', needsWindowOrderBy: true },
|
|
462
|
+
};
|
|
463
|
+
const sum_cumulative = {
|
|
464
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
465
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
466
|
+
returns: { calculation: { generic: 'T' } },
|
|
467
|
+
impl: { function: 'SUM', needsWindowOrderBy: true },
|
|
468
|
+
};
|
|
469
|
+
const sum_moving = {
|
|
470
|
+
'preceding': {
|
|
471
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
472
|
+
takes: {
|
|
473
|
+
'value': { measure: { generic: 'T' } },
|
|
474
|
+
'preceding': { literal: 'number' },
|
|
475
|
+
},
|
|
476
|
+
returns: { calculation: { generic: 'T' } },
|
|
477
|
+
impl: {
|
|
478
|
+
sql: 'SUM(${value})',
|
|
479
|
+
needsWindowOrderBy: true,
|
|
480
|
+
between: { preceding: 'preceding', following: 0 },
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
'following': {
|
|
484
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
485
|
+
takes: {
|
|
486
|
+
'value': { measure: { generic: 'T' } },
|
|
487
|
+
'preceding': { literal: 'number' },
|
|
488
|
+
'following': { literal: 'number' },
|
|
489
|
+
},
|
|
490
|
+
returns: { calculation: { generic: 'T' } },
|
|
491
|
+
impl: {
|
|
492
|
+
sql: 'SUM(${value})',
|
|
493
|
+
needsWindowOrderBy: true,
|
|
494
|
+
between: { preceding: 'preceding', following: 'following' },
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
const sum_window = {
|
|
499
|
+
generic: ['T', ['string', 'number', 'timestamp', 'date']],
|
|
500
|
+
takes: { 'value': { measure: { generic: 'T' } } },
|
|
501
|
+
returns: { calculation: { generic: 'T' } },
|
|
502
|
+
impl: { function: 'SUM', needsWindowOrderBy: false },
|
|
503
|
+
};
|
|
504
|
+
// SQL functions
|
|
505
|
+
const sql_boolean = {
|
|
506
|
+
takes: { 'value': { literal: 'string' } },
|
|
507
|
+
returns: 'boolean',
|
|
508
|
+
impl: { expr: { node: 'function_parameter', name: 'value' } },
|
|
509
|
+
};
|
|
510
|
+
const sql_date = {
|
|
511
|
+
takes: { 'value': { literal: 'string' } },
|
|
512
|
+
returns: 'date',
|
|
513
|
+
impl: { expr: { node: 'function_parameter', name: 'value' } },
|
|
514
|
+
};
|
|
515
|
+
const sql_number = {
|
|
516
|
+
takes: { 'value': { literal: 'string' } },
|
|
517
|
+
returns: 'number',
|
|
518
|
+
impl: { expr: { node: 'function_parameter', name: 'value' } },
|
|
519
|
+
};
|
|
520
|
+
const sql_string = {
|
|
521
|
+
takes: { 'value': { literal: 'string' } },
|
|
522
|
+
returns: 'string',
|
|
523
|
+
impl: { expr: { node: 'function_parameter', name: 'value' } },
|
|
524
|
+
};
|
|
525
|
+
const sql_timestamp = {
|
|
526
|
+
takes: { 'value': { literal: 'string' } },
|
|
527
|
+
returns: 'timestamp',
|
|
528
|
+
impl: { expr: { node: 'function_parameter', name: 'value' } },
|
|
529
|
+
};
|
|
530
|
+
exports.MALLOY_STANDARD_FUNCTIONS = {
|
|
531
|
+
abs,
|
|
532
|
+
acos,
|
|
533
|
+
ascii,
|
|
534
|
+
asin,
|
|
535
|
+
atan2,
|
|
536
|
+
atan,
|
|
537
|
+
byte_length,
|
|
538
|
+
ceil,
|
|
539
|
+
chr,
|
|
540
|
+
coalesce,
|
|
541
|
+
concat,
|
|
542
|
+
cos,
|
|
543
|
+
div,
|
|
544
|
+
ends_with,
|
|
545
|
+
exp,
|
|
546
|
+
floor,
|
|
547
|
+
greatest,
|
|
548
|
+
ifnull,
|
|
549
|
+
is_inf,
|
|
550
|
+
is_nan,
|
|
551
|
+
least,
|
|
552
|
+
length,
|
|
553
|
+
ln,
|
|
554
|
+
log,
|
|
555
|
+
lower,
|
|
556
|
+
ltrim,
|
|
557
|
+
nullif,
|
|
558
|
+
pi,
|
|
559
|
+
pow,
|
|
560
|
+
rand,
|
|
561
|
+
regexp_extract,
|
|
562
|
+
repeat,
|
|
563
|
+
replace,
|
|
564
|
+
reverse,
|
|
565
|
+
round,
|
|
566
|
+
rtrim,
|
|
567
|
+
sign,
|
|
568
|
+
sin,
|
|
569
|
+
sqrt,
|
|
570
|
+
starts_with,
|
|
571
|
+
strpos,
|
|
572
|
+
substr,
|
|
573
|
+
tan,
|
|
574
|
+
trim,
|
|
575
|
+
trunc,
|
|
576
|
+
unicode,
|
|
577
|
+
upper,
|
|
578
|
+
// Aggregate functions
|
|
579
|
+
stddev,
|
|
580
|
+
// string_agg,
|
|
581
|
+
// string_agg_distinct,
|
|
582
|
+
// Analytic functions
|
|
583
|
+
avg_moving,
|
|
584
|
+
first_value,
|
|
585
|
+
lag,
|
|
586
|
+
last_value,
|
|
587
|
+
lead,
|
|
588
|
+
max_cumulative,
|
|
589
|
+
max_window,
|
|
590
|
+
min_cumulative,
|
|
591
|
+
min_window,
|
|
592
|
+
rank,
|
|
593
|
+
row_number,
|
|
594
|
+
sum_cumulative,
|
|
595
|
+
sum_moving,
|
|
596
|
+
sum_window,
|
|
597
|
+
// SQL functions
|
|
598
|
+
sql_boolean,
|
|
599
|
+
sql_date,
|
|
600
|
+
sql_number,
|
|
601
|
+
sql_string,
|
|
602
|
+
sql_timestamp,
|
|
603
|
+
};
|
|
604
|
+
function getMalloyStandardFunctions() {
|
|
605
|
+
return (0, util_1.expandBlueprintMap)(exports.MALLOY_STANDARD_FUNCTIONS);
|
|
606
|
+
}
|
|
607
|
+
exports.getMalloyStandardFunctions = getMalloyStandardFunctions;
|
|
608
|
+
function expandOverrideMap(overrides) {
|
|
609
|
+
return (0, util_1.expandOverrideMapFromBase)(exports.MALLOY_STANDARD_FUNCTIONS, overrides);
|
|
610
|
+
}
|
|
611
|
+
exports.expandOverrideMap = expandOverrideMap;
|
|
612
|
+
//# sourceMappingURL=malloy_standard_functions.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionParameterDef, FieldValueType, TypeDesc, Expr, FunctionParamTypeDesc } from '../../model/malloy_types';
|
|
1
|
+
import { FunctionParameterDef, FieldValueType, TypeDesc, Expr, FunctionParamTypeDesc, ExpressionValueType } from '../../model/malloy_types';
|
|
2
2
|
import { SQLExprElement } from '../../model/utils';
|
|
3
3
|
export interface DialectFunctionOverloadDef {
|
|
4
4
|
returnType: TypeDesc;
|
|
@@ -20,7 +20,7 @@ export declare function sql(strings: TemplateStringsArray, ...subExprs: SQLExprE
|
|
|
20
20
|
export declare function constant(type: TypeDesc): TypeDesc;
|
|
21
21
|
export declare function output(type: TypeDesc): TypeDesc;
|
|
22
22
|
export declare function literal(type: TypeDesc): TypeDesc;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function variadicParam(name: string, ...allowedTypes: FunctionParamTypeDesc[]): FunctionParameterDef;
|
|
24
24
|
/**
|
|
25
25
|
* Prefer `makeParam` for future function definitions
|
|
26
26
|
*/
|
|
@@ -48,3 +48,79 @@ export declare function overload(returnType: TypeDesc, params: FunctionParameter
|
|
|
48
48
|
defaultOrderByArgIndex?: number;
|
|
49
49
|
supportsOrderBy?: boolean | 'only_default';
|
|
50
50
|
}): DialectFunctionOverloadDef;
|
|
51
|
+
export type TypeDescBlueprint = ExpressionValueType | {
|
|
52
|
+
generic: string;
|
|
53
|
+
} | {
|
|
54
|
+
literal: ExpressionValueType | {
|
|
55
|
+
generic: string;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
constant: ExpressionValueType | {
|
|
59
|
+
generic: string;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
dimension: ExpressionValueType | {
|
|
63
|
+
generic: string;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
measure: ExpressionValueType | {
|
|
67
|
+
generic: string;
|
|
68
|
+
};
|
|
69
|
+
} | {
|
|
70
|
+
calculation: ExpressionValueType | {
|
|
71
|
+
generic: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
type ParamTypeBlueprint = TypeDescBlueprint | TypeDescBlueprint[] | {
|
|
75
|
+
variadic: TypeDescBlueprint | TypeDescBlueprint[];
|
|
76
|
+
};
|
|
77
|
+
export interface SignatureBlueprint {
|
|
78
|
+
generic?: [string, ExpressionValueType[]];
|
|
79
|
+
takes: {
|
|
80
|
+
[name: string]: ParamTypeBlueprint;
|
|
81
|
+
};
|
|
82
|
+
returns: TypeDescBlueprint;
|
|
83
|
+
supportsOrderBy?: boolean | 'only_default';
|
|
84
|
+
supportsLimit?: boolean;
|
|
85
|
+
isSymmetric?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface ImplementationBlueprintBase {
|
|
88
|
+
needsWindowOrderBy?: boolean;
|
|
89
|
+
between?: {
|
|
90
|
+
preceding: number | string;
|
|
91
|
+
following: number | string;
|
|
92
|
+
};
|
|
93
|
+
defaultOrderByArgIndex?: number;
|
|
94
|
+
}
|
|
95
|
+
interface ImplementationBlueprintSql extends ImplementationBlueprintBase {
|
|
96
|
+
sql: string;
|
|
97
|
+
}
|
|
98
|
+
interface ImplementationBlueprintExpr extends ImplementationBlueprintBase {
|
|
99
|
+
expr: Expr;
|
|
100
|
+
}
|
|
101
|
+
interface ImplementationBlueprintFunction extends ImplementationBlueprintBase {
|
|
102
|
+
function: string;
|
|
103
|
+
}
|
|
104
|
+
export type ImplementationBlueprint = ImplementationBlueprintSql | ImplementationBlueprintExpr | ImplementationBlueprintFunction;
|
|
105
|
+
export interface DefinitionBlueprint extends SignatureBlueprint {
|
|
106
|
+
impl: ImplementationBlueprint;
|
|
107
|
+
}
|
|
108
|
+
export type OverloadedDefinitionBlueprint = {
|
|
109
|
+
[signatureName: string]: DefinitionBlueprint;
|
|
110
|
+
};
|
|
111
|
+
export type DefinitionBlueprintMap = {
|
|
112
|
+
[name: string]: DefinitionBlueprint | OverloadedDefinitionBlueprint;
|
|
113
|
+
};
|
|
114
|
+
export type OverloadedImplementationBlueprint = {
|
|
115
|
+
[signatureName: string]: ImplementationBlueprint;
|
|
116
|
+
};
|
|
117
|
+
export type OverrideMap = {
|
|
118
|
+
[name: string]: ImplementationBlueprint | OverloadedImplementationBlueprint;
|
|
119
|
+
};
|
|
120
|
+
export declare function expandBlueprintMap(blueprints: DefinitionBlueprintMap): {
|
|
121
|
+
[name: string]: DialectFunctionOverloadDef[];
|
|
122
|
+
};
|
|
123
|
+
export declare function expandOverrideMapFromBase(base: DefinitionBlueprintMap, overrides: OverrideMap): {
|
|
124
|
+
[name: string]: DialectFunctionOverloadDef[];
|
|
125
|
+
};
|
|
126
|
+
export {};
|