@malloydata/malloy 0.0.126-dev240221165840 → 0.0.126-dev240305182920
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/README.md +1 -0
- package/dist/dialect/dialect.d.ts +1 -0
- package/dist/dialect/dialect_map.js +2 -0
- package/dist/dialect/functions/concat.js +2 -2
- package/dist/dialect/functions/length.js +1 -0
- package/dist/dialect/index.d.ts +1 -0
- package/dist/dialect/index.js +3 -1
- package/dist/dialect/snowflake/functions/chr.d.ts +2 -0
- package/dist/dialect/snowflake/functions/chr.js +36 -0
- package/dist/dialect/snowflake/functions/div.d.ts +2 -0
- package/dist/dialect/snowflake/functions/div.js +37 -0
- package/dist/dialect/snowflake/functions/index.d.ts +1 -0
- package/dist/dialect/snowflake/functions/index.js +28 -0
- package/dist/dialect/snowflake/functions/is_inf.d.ts +2 -0
- package/dist/dialect/snowflake/functions/is_inf.js +34 -0
- package/dist/dialect/snowflake/functions/is_nan.d.ts +2 -0
- package/dist/dialect/snowflake/functions/is_nan.js +33 -0
- package/dist/dialect/snowflake/functions/length.d.ts +3 -0
- package/dist/dialect/snowflake/functions/length.js +39 -0
- package/dist/dialect/snowflake/functions/log.d.ts +2 -0
- package/dist/dialect/snowflake/functions/log.js +37 -0
- package/dist/dialect/snowflake/functions/rand.d.ts +2 -0
- package/dist/dialect/snowflake/functions/rand.js +33 -0
- package/dist/dialect/snowflake/functions/regexp_extract.d.ts +2 -0
- package/dist/dialect/snowflake/functions/regexp_extract.js +35 -0
- package/dist/dialect/snowflake/functions/snowflake_functions.d.ts +1 -0
- package/dist/dialect/snowflake/functions/snowflake_functions.js +56 -0
- package/dist/dialect/snowflake/functions/starts_ends_with.d.ts +3 -0
- package/dist/dialect/snowflake/functions/starts_ends_with.js +43 -0
- package/dist/dialect/snowflake/functions/string_agg.d.ts +3 -0
- package/dist/dialect/snowflake/functions/string_agg.js +47 -0
- package/dist/dialect/snowflake/functions/strpos.d.ts +2 -0
- package/dist/dialect/snowflake/functions/strpos.js +35 -0
- package/dist/dialect/snowflake/functions/trunc.d.ts +2 -0
- package/dist/dialect/snowflake/functions/trunc.js +39 -0
- package/dist/dialect/snowflake/index.d.ts +1 -0
- package/dist/dialect/snowflake/index.js +40 -0
- package/dist/dialect/snowflake/snowflake.d.ts +62 -0
- package/dist/dialect/snowflake/snowflake.js +408 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/malloy.d.ts +2 -0
- package/dist/malloy.js +7 -0
- package/dist/model/malloy_query.js +16 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ In practice, much of this loop is handled by various database plugins:
|
|
|
32
32
|
- [DuckDB](https://github.com/malloydata/malloy/tree/main/packages/malloy-db-duckdb)
|
|
33
33
|
- [BigQuery](https://github.com/malloydata/malloy/tree/main/packages/malloy-db-bigquery)
|
|
34
34
|
- [Postgres](https://github.com/malloydata/malloy/tree/main/packages/malloy-db-postgres)
|
|
35
|
+
- [Snowflake](https://github.com/malloydata/malloy/tree/main/packages/malloy-db-snowflake)
|
|
35
36
|
|
|
36
37
|
## Do you have any examples?
|
|
37
38
|
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.getDialectFunction = exports.registerDialect = exports.getDialect = void 0;
|
|
26
26
|
const duckdb_1 = require("./duckdb");
|
|
27
27
|
const postgres_1 = require("./postgres");
|
|
28
|
+
const snowflake_1 = require("./snowflake");
|
|
28
29
|
const standardsql_1 = require("./standardsql");
|
|
29
30
|
const dialectMap = new Map();
|
|
30
31
|
function getDialect(name) {
|
|
@@ -42,6 +43,7 @@ exports.registerDialect = registerDialect;
|
|
|
42
43
|
registerDialect(new postgres_1.PostgresDialect());
|
|
43
44
|
registerDialect(new standardsql_1.StandardSQLDialect());
|
|
44
45
|
registerDialect(new duckdb_1.DuckDBDialect());
|
|
46
|
+
registerDialect(new snowflake_1.SnowflakeDialect());
|
|
45
47
|
function paramsEqual(a, b) {
|
|
46
48
|
return (a.params.length === b.params.length &&
|
|
47
49
|
a.params.every((param, i) => {
|
|
@@ -26,8 +26,8 @@ exports.fnConcat = void 0;
|
|
|
26
26
|
const util_1 = require("./util");
|
|
27
27
|
function fnConcat() {
|
|
28
28
|
return [
|
|
29
|
-
// TODO in DuckDB, nulls are treated like "",
|
|
30
|
-
// result becomes null
|
|
29
|
+
// TODO: in DuckDB and Postgres, nulls are treated like "",
|
|
30
|
+
// but in BigQuery and Snowflake, nulls propagate and the result becomes null
|
|
31
31
|
(0, util_1.overload)((0, util_1.minScalar)('string'), [], [{ type: 'dialect', function: 'stringLiteral', literal: '' }]),
|
|
32
32
|
(0, util_1.overload)((0, util_1.minScalar)('string'), [
|
|
33
33
|
(0, util_1.params)('values', (0, util_1.anyExprType)('string'), (0, util_1.anyExprType)('number'), (0, util_1.anyExprType)('date'), (0, util_1.anyExprType)('timestamp'), (0, util_1.anyExprType)('boolean')),
|
|
@@ -30,6 +30,7 @@ function fnLength() {
|
|
|
30
30
|
];
|
|
31
31
|
}
|
|
32
32
|
exports.fnLength = fnLength;
|
|
33
|
+
// TODO: add support for byte length in postgres, duckdb
|
|
33
34
|
function fnByteLength() {
|
|
34
35
|
return [
|
|
35
36
|
(0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('value', (0, util_1.anyExprType)('string'))], (0, util_1.sql) `BYTE_LENGTH(${(0, util_1.arg)('value')})`),
|
package/dist/dialect/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export type { DialectFieldList, QueryInfo } from './dialect';
|
|
|
5
5
|
export { StandardSQLDialect } from './standardsql';
|
|
6
6
|
export { PostgresDialect } from './postgres';
|
|
7
7
|
export { DuckDBDialect } from './duckdb';
|
|
8
|
+
export { SnowflakeDialect } from './snowflake';
|
|
8
9
|
export { getDialect, registerDialect, getDialectFunction } from './dialect_map';
|
|
9
10
|
export { FUNCTIONS } from './functions';
|
package/dist/dialect/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.FUNCTIONS = exports.getDialectFunction = exports.registerDialect = exports.getDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.params = exports.param = exports.sqlFragment = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
25
|
+
exports.FUNCTIONS = exports.getDialectFunction = exports.registerDialect = exports.getDialect = exports.SnowflakeDialect = exports.DuckDBDialect = exports.PostgresDialect = exports.StandardSQLDialect = exports.qtz = exports.Dialect = exports.sql = exports.literal = exports.params = exports.param = exports.sqlFragment = exports.spread = exports.maxScalar = exports.minAggregate = exports.minScalar = exports.overload = exports.makeParam = exports.anyExprType = exports.arg = void 0;
|
|
26
26
|
var util_1 = require("./functions/util");
|
|
27
27
|
Object.defineProperty(exports, "arg", { enumerable: true, get: function () { return util_1.arg; } });
|
|
28
28
|
Object.defineProperty(exports, "anyExprType", { enumerable: true, get: function () { return util_1.anyExprType; } });
|
|
@@ -46,6 +46,8 @@ var postgres_1 = require("./postgres");
|
|
|
46
46
|
Object.defineProperty(exports, "PostgresDialect", { enumerable: true, get: function () { return postgres_1.PostgresDialect; } });
|
|
47
47
|
var duckdb_1 = require("./duckdb");
|
|
48
48
|
Object.defineProperty(exports, "DuckDBDialect", { enumerable: true, get: function () { return duckdb_1.DuckDBDialect; } });
|
|
49
|
+
var snowflake_1 = require("./snowflake");
|
|
50
|
+
Object.defineProperty(exports, "SnowflakeDialect", { enumerable: true, get: function () { return snowflake_1.SnowflakeDialect; } });
|
|
49
51
|
var dialect_map_1 = require("./dialect_map");
|
|
50
52
|
Object.defineProperty(exports, "getDialect", { enumerable: true, get: function () { return dialect_map_1.getDialect; } });
|
|
51
53
|
Object.defineProperty(exports, "registerDialect", { enumerable: true, get: function () { return dialect_map_1.registerDialect; } });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnChr = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnChr() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('number'));
|
|
29
|
+
return [
|
|
30
|
+
(0, util_1.overload)((0, util_1.minScalar)('string'), [value.param],
|
|
31
|
+
// Need to explicitly have a case for when the arg is 0, to return ''
|
|
32
|
+
(0, util_1.sql) `COALESCE(CHR(${value.arg}), '')`),
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
exports.fnChr = fnChr;
|
|
36
|
+
//# sourceMappingURL=chr.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnDiv = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnDiv() {
|
|
28
|
+
const dividend = (0, util_1.makeParam)('dividend', (0, util_1.anyExprType)('number'));
|
|
29
|
+
const divisor = (0, util_1.makeParam)('divisor', (0, util_1.anyExprType)('number'));
|
|
30
|
+
return [
|
|
31
|
+
(0, util_1.overload)((0, util_1.minScalar)('number'), [dividend.param, divisor.param],
|
|
32
|
+
// in Snowflake division is always a float division, so we need this conversion
|
|
33
|
+
(0, util_1.sql) `CASE WHEN DIV0(${dividend.arg}, ${divisor.arg}) < 0 THEN CEIL(DIV0(${dividend.arg}, ${divisor.arg})) ELSE FLOOR(DIV0(${dividend.arg}, ${divisor.arg})) END`),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
exports.fnDiv = fnDiv;
|
|
37
|
+
//# sourceMappingURL=div.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SNOWFLAKE_FUNCTIONS } from './snowflake_functions';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.SNOWFLAKE_FUNCTIONS = void 0;
|
|
26
|
+
var snowflake_functions_1 = require("./snowflake_functions");
|
|
27
|
+
Object.defineProperty(exports, "SNOWFLAKE_FUNCTIONS", { enumerable: true, get: function () { return snowflake_functions_1.SNOWFLAKE_FUNCTIONS; } });
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnIsInf = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnIsInf() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('number'));
|
|
29
|
+
return [
|
|
30
|
+
(0, util_1.overload)((0, util_1.minScalar)('boolean'), [value.param], (0, util_1.sql) `COALESCE(${value.arg} = 'inf'::FLOAT OR ${value.arg} = '-inf'::FLOAT, false)`),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
exports.fnIsInf = fnIsInf;
|
|
34
|
+
//# sourceMappingURL=is_inf.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnIsNan = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnIsNan() {
|
|
28
|
+
return [
|
|
29
|
+
(0, util_1.overload)((0, util_1.minScalar)('boolean'), [(0, util_1.param)('value', (0, util_1.anyExprType)('number'))], (0, util_1.sql) `COALESCE(${(0, util_1.arg)('value')} = 'NAN'::FLOAT, false)`),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
exports.fnIsNan = fnIsNan;
|
|
33
|
+
//# sourceMappingURL=is_nan.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnByteLength = exports.fnLength = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnLength() {
|
|
28
|
+
return [
|
|
29
|
+
(0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('value', (0, util_1.anyExprType)('string'))], (0, util_1.sql) `LENGTH(${(0, util_1.arg)('value')})`),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
exports.fnLength = fnLength;
|
|
33
|
+
function fnByteLength() {
|
|
34
|
+
return [
|
|
35
|
+
(0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('value', (0, util_1.anyExprType)('string'))], (0, util_1.sql) `CEIL(BIT_LENGTH(${(0, util_1.arg)('value')}) / 8)`),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
exports.fnByteLength = fnByteLength;
|
|
39
|
+
//# sourceMappingURL=length.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnLog = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnLog() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('number'));
|
|
29
|
+
const base = (0, util_1.makeParam)('base', (0, util_1.anyExprType)('number'));
|
|
30
|
+
return [
|
|
31
|
+
(0, util_1.overload)((0, util_1.minScalar)('number'), [value.param, base.param],
|
|
32
|
+
// Snowflake take base first, then value
|
|
33
|
+
(0, util_1.sql) `LOG(${base.arg}, ${value.arg})`),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
exports.fnLog = fnLog;
|
|
37
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnRand = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnRand() {
|
|
28
|
+
return [
|
|
29
|
+
(0, util_1.overload)((0, util_1.minScalar)('number'), [], (0, util_1.sql) `UNIFORM(0::FLOAT, 1::FLOAT, RANDOM())`),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
exports.fnRand = fnRand;
|
|
33
|
+
//# sourceMappingURL=rand.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnRegexpExtract = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnRegexpExtract() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('string'));
|
|
29
|
+
const pattern = (0, util_1.makeParam)('pattern', (0, util_1.anyExprType)('regular expression'));
|
|
30
|
+
return [
|
|
31
|
+
(0, util_1.overload)((0, util_1.minScalar)('string'), [value.param, pattern.param], (0, util_1.sql) `REGEXP_SUBSTR(${value.arg}, ${pattern.arg}, 1, 1, 'e')`),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
exports.fnRegexpExtract = fnRegexpExtract;
|
|
35
|
+
//# sourceMappingURL=regexp_extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SNOWFLAKE_FUNCTIONS: import("../../functions/function_map").FunctionMap;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.SNOWFLAKE_FUNCTIONS = void 0;
|
|
26
|
+
const functions_1 = require("../../functions");
|
|
27
|
+
const chr_1 = require("./chr");
|
|
28
|
+
const div_1 = require("./div");
|
|
29
|
+
const is_inf_1 = require("./is_inf");
|
|
30
|
+
const is_nan_1 = require("./is_nan");
|
|
31
|
+
const length_1 = require("./length");
|
|
32
|
+
const log_1 = require("./log");
|
|
33
|
+
const rand_1 = require("./rand");
|
|
34
|
+
const regexp_extract_1 = require("./regexp_extract");
|
|
35
|
+
const starts_ends_with_1 = require("./starts_ends_with");
|
|
36
|
+
const strpos_1 = require("./strpos");
|
|
37
|
+
const trunc_1 = require("./trunc");
|
|
38
|
+
const string_agg_1 = require("./string_agg");
|
|
39
|
+
exports.SNOWFLAKE_FUNCTIONS = functions_1.FUNCTIONS.clone();
|
|
40
|
+
exports.SNOWFLAKE_FUNCTIONS.add('byte_length', length_1.fnByteLength);
|
|
41
|
+
exports.SNOWFLAKE_FUNCTIONS.add('chr', chr_1.fnChr);
|
|
42
|
+
exports.SNOWFLAKE_FUNCTIONS.add('div', div_1.fnDiv);
|
|
43
|
+
exports.SNOWFLAKE_FUNCTIONS.add('is_inf', is_inf_1.fnIsInf);
|
|
44
|
+
exports.SNOWFLAKE_FUNCTIONS.add('is_nan', is_nan_1.fnIsNan);
|
|
45
|
+
exports.SNOWFLAKE_FUNCTIONS.add('length', length_1.fnLength);
|
|
46
|
+
exports.SNOWFLAKE_FUNCTIONS.add('log', log_1.fnLog);
|
|
47
|
+
exports.SNOWFLAKE_FUNCTIONS.add('rand', rand_1.fnRand);
|
|
48
|
+
exports.SNOWFLAKE_FUNCTIONS.add('regexp_extract', regexp_extract_1.fnRegexpExtract);
|
|
49
|
+
exports.SNOWFLAKE_FUNCTIONS.add('starts_with', starts_ends_with_1.fnStartsWith);
|
|
50
|
+
exports.SNOWFLAKE_FUNCTIONS.add('ends_with', starts_ends_with_1.fnEndsWith);
|
|
51
|
+
exports.SNOWFLAKE_FUNCTIONS.add('strpos', strpos_1.fnStrpos);
|
|
52
|
+
exports.SNOWFLAKE_FUNCTIONS.add('trunc', trunc_1.fnTrunc);
|
|
53
|
+
exports.SNOWFLAKE_FUNCTIONS.add('string_agg', string_agg_1.fnStringAgg);
|
|
54
|
+
exports.SNOWFLAKE_FUNCTIONS.add('string_agg_distinct', string_agg_1.fnStringAggDistinct);
|
|
55
|
+
exports.SNOWFLAKE_FUNCTIONS.seal();
|
|
56
|
+
//# sourceMappingURL=snowflake_functions.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnEndsWith = exports.fnStartsWith = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnStartsWith() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('string'));
|
|
29
|
+
const prefix = (0, util_1.makeParam)('prefix', (0, util_1.anyExprType)('string'));
|
|
30
|
+
return [
|
|
31
|
+
(0, util_1.overload)((0, util_1.minScalar)('boolean'), [value.param, prefix.param], (0, util_1.sql) `COALESCE(STARTSWITH(${value.arg}, ${prefix.arg}), false)`),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
exports.fnStartsWith = fnStartsWith;
|
|
35
|
+
function fnEndsWith() {
|
|
36
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('string'));
|
|
37
|
+
const suffix = (0, util_1.makeParam)('suffix', (0, util_1.anyExprType)('string'));
|
|
38
|
+
return [
|
|
39
|
+
(0, util_1.overload)((0, util_1.minScalar)('boolean'), [value.param, suffix.param], (0, util_1.sql) `COALESCE(ENDSWITH(${value.arg}, ${suffix.arg}), false)`),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
exports.fnEndsWith = fnEndsWith;
|
|
43
|
+
//# sourceMappingURL=starts_ends_with.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.fnStringAggDistinct = exports.fnStringAgg = void 0;
|
|
26
|
+
const util_1 = require("../../functions/util");
|
|
27
|
+
function fnStringAgg() {
|
|
28
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.maxScalar)('string'));
|
|
29
|
+
const separator = (0, util_1.makeParam)('separator', (0, util_1.literal)((0, util_1.maxScalar)('string')));
|
|
30
|
+
const orderBy = { type: 'aggregate_order_by' };
|
|
31
|
+
return [
|
|
32
|
+
(0, util_1.overload)((0, util_1.minAggregate)('string'), [value.param], (0, util_1.sql) `LISTAGG(${value.arg}, ',') WITHIN GROUP(${orderBy})`, { supportsOrderBy: true, supportsLimit: false }),
|
|
33
|
+
(0, util_1.overload)((0, util_1.minAggregate)('string'), [value.param, separator.param], (0, util_1.sql) `LISTAGG(${value.arg}, ${separator.arg}) WITHIN GROUP(${orderBy})`, { supportsOrderBy: true, supportsLimit: false }),
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
exports.fnStringAgg = fnStringAgg;
|
|
37
|
+
function fnStringAggDistinct() {
|
|
38
|
+
const value = (0, util_1.makeParam)('value', (0, util_1.maxScalar)('string'));
|
|
39
|
+
const separator = (0, util_1.makeParam)('separator', (0, util_1.literal)((0, util_1.maxScalar)('string')));
|
|
40
|
+
const orderBy = { type: 'aggregate_order_by' };
|
|
41
|
+
return [
|
|
42
|
+
(0, util_1.overload)((0, util_1.minAggregate)('string'), [value.param], (0, util_1.sql) `LISTAGG(DISTINCT ${value.arg}, ',') WITHIN GROUP(${orderBy})`, { supportsOrderBy: true, supportsLimit: false }),
|
|
43
|
+
(0, util_1.overload)((0, util_1.minAggregate)('string'), [value.param, separator.param], (0, util_1.sql) `LISTAGG(DISTINCT ${value.arg}, ${separator.arg}) WITHIN GROUP(${orderBy})`, { supportsOrderBy: true, supportsLimit: false }),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
exports.fnStringAggDistinct = fnStringAggDistinct;
|
|
47
|
+
//# sourceMappingURL=string_agg.js.map
|