@qrvey/formula-lang 2.0.1-rc.514 → 2.0.1-rc.525
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/cjs/functions/left.js +9 -3
- package/dist/cjs/functions/left.js.map +1 -1
- package/dist/cjs/functions/mid.js +18 -9
- package/dist/cjs/functions/mid.js.map +1 -1
- package/dist/cjs/functions/right.js +9 -3
- package/dist/cjs/functions/right.js.map +1 -1
- package/dist/cjs/utils/elasticsearch/scripts.d.ts +1 -1
- package/dist/cjs/utils/elasticsearch/scripts.js +21 -17
- package/dist/cjs/utils/elasticsearch/scripts.js.map +1 -1
- package/dist/module/functions/left.js +9 -3
- package/dist/module/functions/left.js.map +1 -1
- package/dist/module/functions/mid.js +18 -9
- package/dist/module/functions/mid.js.map +1 -1
- package/dist/module/functions/right.js +9 -3
- package/dist/module/functions/right.js.map +1 -1
- package/dist/module/utils/elasticsearch/scripts.d.ts +1 -1
- package/dist/module/utils/elasticsearch/scripts.js +20 -16
- package/dist/module/utils/elasticsearch/scripts.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.LEFT = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const greaterThanOrEqualToReference_1 = require("../utils/greaterThanOrEqualToReference");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `LEFT` Returns the first character or characters in a text string, based on the number of characters you specify.
|
|
9
10
|
*/
|
|
@@ -20,7 +21,11 @@ exports.LEFT = {
|
|
|
20
21
|
identifier: 'EXTRACT_LENGTH',
|
|
21
22
|
optional: true,
|
|
22
23
|
expectedPrimitive: constants_1.AST_PRIMITIVES.NUMBER,
|
|
23
|
-
validator: [
|
|
24
|
+
validator: [
|
|
25
|
+
utils_1.isNumberParam,
|
|
26
|
+
(0, greaterThanOrEqualToReference_1.greaterThanOrEqualToReference)(0),
|
|
27
|
+
isInteger_1.isInteger,
|
|
28
|
+
],
|
|
24
29
|
},
|
|
25
30
|
],
|
|
26
31
|
transpiler: {
|
|
@@ -35,12 +40,13 @@ function elasticsearch(current, length) {
|
|
|
35
40
|
return `${constants_1.ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, 0, ${length !== null && length !== void 0 ? length : 1})`;
|
|
36
41
|
}
|
|
37
42
|
function snowflake(current, length) {
|
|
38
|
-
return `LEFT(${current}, ${length !== null && length !== void 0 ? length : 1})`;
|
|
43
|
+
return `LEFT(${current}, FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER)`;
|
|
39
44
|
}
|
|
40
45
|
function SQL(current, length) {
|
|
41
|
-
const _length = length !== null && length !== void 0 ? length : 1
|
|
46
|
+
const _length = `FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER`;
|
|
42
47
|
return `
|
|
43
48
|
(case
|
|
49
|
+
when ${length !== null && length !== void 0 ? length : 1} IS NULL then NULL
|
|
44
50
|
when (${_length} < 0) then ''
|
|
45
51
|
else
|
|
46
52
|
LEFT(${current}, ${_length})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"left.js","sourceRoot":"","sources":["../../../src/functions/left.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;
|
|
1
|
+
{"version":3,"file":"left.js","sourceRoot":"","sources":["../../../src/functions/left.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;AACvF,kDAA+C;AAE/C;;GAEG;AACU,QAAA,IAAI,GAAuB;IACpC,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,IAAI;YACd,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE;gBACP,qBAAa;gBACb,IAAA,6DAA6B,EAAC,CAAC,CAAC;gBAChC,qBAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,0BAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,OAAe,EAAE,MAAc;IAClD,OAAO,GAAG,sCAA0B,CAAC,SAAS,IAAI,OAAO,QACrD,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CACd,GAAG,CAAC;AACR,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,MAAc;IAC9C,OAAO,QAAQ,OAAO,WAAW,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,MAAc;IACxC,MAAM,OAAO,GAAG,SAAS,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,YAAY,CAAC;IACjD,OAAO;;eAEI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC;UAChB,OAAO;;eAEF,OAAO,KAAK,OAAO;;MAE5B,CAAC,IAAI,EAAE,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,MAAc;IAC/C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.MID = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const greaterThanOrEqualToReference_1 = require("../utils/greaterThanOrEqualToReference");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `MID` Returns a segment of a string.
|
|
9
10
|
*/
|
|
@@ -20,13 +21,17 @@ exports.MID = {
|
|
|
20
21
|
identifier: 'STARTING_AT',
|
|
21
22
|
optional: false,
|
|
22
23
|
expectedPrimitive: constants_1.AST_PRIMITIVES.NUMBER,
|
|
23
|
-
validator: [utils_1.isNumberParam],
|
|
24
|
+
validator: [utils_1.isNumberParam, isInteger_1.isInteger],
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
27
|
identifier: 'EXTRACT_LENGTH',
|
|
27
28
|
optional: false,
|
|
28
29
|
expectedPrimitive: constants_1.AST_PRIMITIVES.NUMBER,
|
|
29
|
-
validator: [
|
|
30
|
+
validator: [
|
|
31
|
+
utils_1.isNumberParam,
|
|
32
|
+
(0, greaterThanOrEqualToReference_1.greaterThanOrEqualToReference)(0),
|
|
33
|
+
isInteger_1.isInteger,
|
|
34
|
+
],
|
|
30
35
|
},
|
|
31
36
|
],
|
|
32
37
|
transpiler: {
|
|
@@ -40,21 +45,25 @@ exports.MID = {
|
|
|
40
45
|
function elasticsearch(current, start, length) {
|
|
41
46
|
return `${constants_1.ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, ${start}, ${length})`;
|
|
42
47
|
}
|
|
48
|
+
function sqlRound(value) {
|
|
49
|
+
return `(FLOOR(ABS(${value})) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
50
|
+
}
|
|
43
51
|
function snowflake(current, start, length) {
|
|
44
|
-
return `SUBSTRING(${current}, ${start}, ${length})`;
|
|
52
|
+
return `SUBSTRING(${current}, ${sqlRound(start)} , ${sqlRound(length)})`;
|
|
45
53
|
}
|
|
46
54
|
function SQL(current, start, length) {
|
|
47
55
|
return `
|
|
48
56
|
(case
|
|
49
|
-
|
|
57
|
+
when ${current} IS NULL OR ${start} IS NULL OR ${length} IS NULL then NULL
|
|
58
|
+
when (${sqlRound(length)} < 0) OR (${sqlRound(start)} * -1) > LENGTH(${current}) then ''
|
|
50
59
|
else
|
|
51
60
|
SUBSTRING(${current},
|
|
52
61
|
(case
|
|
53
|
-
when ${start} < 0 then (LENGTH(${current}) + ${start} + 1)
|
|
54
|
-
when ${start} = 0 then 1
|
|
55
|
-
else ${start}
|
|
56
|
-
end),
|
|
57
|
-
${length})
|
|
62
|
+
when ${sqlRound(start)} < 0 then (LENGTH(${current}) + ${sqlRound(start)} + 1)
|
|
63
|
+
when ${sqlRound(start)} = 0 then 1
|
|
64
|
+
else ${sqlRound(start)}
|
|
65
|
+
end)::INTEGER,
|
|
66
|
+
${sqlRound(length)}::INTEGER)
|
|
58
67
|
end
|
|
59
68
|
)`.trim();
|
|
60
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mid.js","sourceRoot":"","sources":["../../../src/functions/mid.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;
|
|
1
|
+
{"version":3,"file":"mid.js","sourceRoot":"","sources":["../../../src/functions/mid.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;AACvF,kDAA+C;AAE/C;;GAEG;AACU,QAAA,GAAG,GAAuB;IACnC,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE,CAAC,qBAAa,EAAE,qBAAS,CAAC;SACxC;QACD;YACI,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE;gBACP,qBAAa;gBACb,IAA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AAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.RIGHT = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const greaterThanOrEqualToReference_1 = require("../utils/greaterThanOrEqualToReference");
|
|
7
|
+
const isInteger_1 = require("../utils/isInteger");
|
|
7
8
|
/**
|
|
8
9
|
* `RIGHT` Returns the last character or characters in a text string, based on the number of characters you specify.
|
|
9
10
|
*/
|
|
@@ -20,7 +21,11 @@ exports.RIGHT = {
|
|
|
20
21
|
identifier: 'EXTRACT_LENGTH',
|
|
21
22
|
optional: true,
|
|
22
23
|
expectedPrimitive: constants_1.AST_PRIMITIVES.NUMBER,
|
|
23
|
-
validator: [
|
|
24
|
+
validator: [
|
|
25
|
+
utils_1.isNumberParam,
|
|
26
|
+
(0, greaterThanOrEqualToReference_1.greaterThanOrEqualToReference)(0),
|
|
27
|
+
isInteger_1.isInteger,
|
|
28
|
+
],
|
|
24
29
|
},
|
|
25
30
|
],
|
|
26
31
|
transpiler: {
|
|
@@ -36,12 +41,13 @@ function elasticsearch(current, length) {
|
|
|
36
41
|
return `${constants_1.ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, ${_length} * -1, ${_length})`;
|
|
37
42
|
}
|
|
38
43
|
function snowflake(current, length) {
|
|
39
|
-
return `RIGHT(${current}, ${length !== null && length !== void 0 ? length : 1})`;
|
|
44
|
+
return `RIGHT(${current}, FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER)`;
|
|
40
45
|
}
|
|
41
46
|
function SQL(current, length) {
|
|
42
|
-
const _length = length !== null && length !== void 0 ? length : 1
|
|
47
|
+
const _length = `FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER`;
|
|
43
48
|
return `
|
|
44
49
|
(case
|
|
50
|
+
when ${length !== null && length !== void 0 ? length : 1} IS NULL then NULL
|
|
45
51
|
when (${_length} < 0) then ''
|
|
46
52
|
else
|
|
47
53
|
RIGHT(${current}, ${_length})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"right.js","sourceRoot":"","sources":["../../../src/functions/right.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;
|
|
1
|
+
{"version":3,"file":"right.js","sourceRoot":"","sources":["../../../src/functions/right.ts"],"names":[],"mappings":";;;AAAA,4CAA0E;AAE1E,oCAAwD;AACxD,0FAAuF;AACvF,kDAA+C;AAE/C;;GAEG;AACU,QAAA,KAAK,GAAuB;IACrC,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE;QACR;YACI,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE,CAAC,qBAAa,CAAC;SAC7B;QACD;YACI,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,IAAI;YACd,iBAAiB,EAAE,0BAAc,CAAC,MAAM;YACxC,SAAS,EAAE;gBACP,qBAAa;gBACb,IAAA,6DAA6B,EAAC,CAAC,CAAC;gBAChC,qBAAS;aACZ;SACJ;KACJ;IACD,UAAU,EAAE;QACR,aAAa;QACb,SAAS;QACT,QAAQ;QACR,UAAU;KACb;IACD,eAAe,EAAE,0BAAc,CAAC,MAAM;CACzC,CAAC;AAEF,SAAS,aAAa,CAAC,OAAe,EAAE,MAAc;IAClD,MAAM,OAAO,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,CAAC;IAC5B,OAAO,GAAG,sCAA0B,CAAC,SAAS,IAAI,OAAO,KAAK,OAAO,UAAU,OAAO,GAAG,CAAC;AAC9F,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,MAAc;IAC9C,OAAO,SAAS,OAAO,WAAW,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,aAAa,CAAC;AAC/D,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,MAAc;IACxC,MAAM,OAAO,GAAG,SAAS,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,YAAY,CAAC;IACjD,OAAO;;eAEI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC;UAChB,OAAO;;gBAED,OAAO,KAAK,OAAO;;MAE7B,CAAC,IAAI,EAAE,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,MAAc;IAC/C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { DateDifUnitParam } from '../../constants/interfaces';
|
|
|
2
2
|
export declare function toDate(value: string): string;
|
|
3
3
|
export declare const setTimezoneToColumnDate: string;
|
|
4
4
|
export declare const dateFormatScript: string;
|
|
5
|
-
export declare const subStringScript: string;
|
|
6
5
|
export declare const dayScript: (value: any) => string;
|
|
7
6
|
export declare const monthScript: (value: any) => string;
|
|
8
7
|
export declare const yearScript: (value: any) => string;
|
|
@@ -27,3 +26,4 @@ export declare const powerScript = "def POWER(def value, def numberToRaise) {\n
|
|
|
27
26
|
export declare const roundDownScript = "def ROUNDDOWN(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.floor(_value * scale) / scale) * sign;\n}";
|
|
28
27
|
export declare const roundScript: string;
|
|
29
28
|
export declare const roundUpScript: string;
|
|
29
|
+
export declare const subStringScript: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundUpScript = exports.roundScript = exports.roundDownScript = exports.powerScript = exports.oddScript = exports.logScript = exports.evenScript = exports.includeScript = exports.replaceScript = exports.expScript = exports.sqrtScript = exports.lengthScript = exports.leastScript = exports.greatestScript = exports.properScript = exports.isNullScript = exports.getValueScript = exports.dateDif = exports.secondScript = exports.minuteScript = exports.hourScript = exports.yearScript = exports.monthScript = exports.dayScript = exports.
|
|
3
|
+
exports.subStringScript = exports.roundUpScript = exports.roundScript = exports.roundDownScript = exports.powerScript = exports.oddScript = exports.logScript = exports.evenScript = exports.includeScript = exports.replaceScript = exports.expScript = exports.sqrtScript = exports.lengthScript = exports.leastScript = exports.greatestScript = exports.properScript = exports.isNullScript = exports.getValueScript = exports.dateDif = exports.secondScript = exports.minuteScript = exports.hourScript = exports.yearScript = exports.monthScript = exports.dayScript = exports.dateFormatScript = exports.setTimezoneToColumnDate = exports.toDate = void 0;
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
function toDate(value) {
|
|
6
6
|
return `ZonedDateTime.parse("${value}")`;
|
|
@@ -29,22 +29,6 @@ String ${constants_1.ELASTICSEARCH_SCRIPT_NAMES.dateFormat}(def date_value, Stri
|
|
|
29
29
|
return DateTimeFormatter.ofPattern(format).format(date_value)
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
32
|
-
exports.subStringScript = `
|
|
33
|
-
String ${constants_1.ELASTICSEARCH_SCRIPT_NAMES.subString}(String text, int start, int end) {
|
|
34
|
-
int first = 0;
|
|
35
|
-
if (end < 0 || (start * -1 > text.length())) return "";
|
|
36
|
-
if (start < 0) {
|
|
37
|
-
first = (int) Math.max(text.length() + start, 0);
|
|
38
|
-
} else if (start == 0) {
|
|
39
|
-
first = 0;
|
|
40
|
-
} else {
|
|
41
|
-
first = (int) Math.min(start - 1, text.length())
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
int last = (int) Math.min(first + end, text.length());
|
|
45
|
-
return text.substring(first, last);
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
32
|
function dateFormatToInt(value, format) {
|
|
49
33
|
return `Integer.parseInt(${constants_1.ELASTICSEARCH_SCRIPT_NAMES.dateFormat}(${value}, '${format}'))`;
|
|
50
34
|
}
|
|
@@ -201,4 +185,24 @@ def ROUNDUP(def value, def places) {
|
|
|
201
185
|
def scale = Math.pow(10, places);
|
|
202
186
|
return (Math.ceil(_value * scale) / scale) * sign;
|
|
203
187
|
}`;
|
|
188
|
+
exports.subStringScript = `${exports.roundDownScript}
|
|
189
|
+
String ${constants_1.ELASTICSEARCH_SCRIPT_NAMES.subString}(def text, def start, def end) {
|
|
190
|
+
if (text == null || start == null || end == null) return null;
|
|
191
|
+
text = (String) text;
|
|
192
|
+
start = ROUNDDOWN(start, 0);
|
|
193
|
+
end = ROUNDDOWN(end, 0);
|
|
194
|
+
int first = 0;
|
|
195
|
+
if (end < 0 || (start * -1 > text.length())) return "";
|
|
196
|
+
if (start < 0) {
|
|
197
|
+
first = (int) Math.max(text.length() + start, 0);
|
|
198
|
+
} else if (start == 0) {
|
|
199
|
+
first = 0;
|
|
200
|
+
} else {
|
|
201
|
+
first = (int) Math.min(start - 1, text.length())
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
int last = (int) Math.min(first + end, text.length());
|
|
205
|
+
return text.substring(first, last);
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
204
208
|
//# sourceMappingURL=scripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":";;;AACA,+CAA6E;AAE7E,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,wBAAwB,KAAK,IAAI,CAAC;AAC7C,CAAC;AAFD,wBAEC;AAEY,QAAA,uBAAuB,GAAG;MACjC,sCAAY,CAAC,WAAW;;;;;;;;;;;CAW7B,CAAC;AAEW,QAAA,gBAAgB,GAAG;SACvB,sCAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../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ES } from '../constants';
|
|
2
2
|
import { isNumberParam, isStringParam } from '../utils';
|
|
3
3
|
import { greaterThanOrEqualToReference } from '../utils/greaterThanOrEqualToReference';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `LEFT` Returns the first character or characters in a text string, based on the number of characters you specify.
|
|
6
7
|
*/
|
|
@@ -17,7 +18,11 @@ export const LEFT = {
|
|
|
17
18
|
identifier: 'EXTRACT_LENGTH',
|
|
18
19
|
optional: true,
|
|
19
20
|
expectedPrimitive: AST_PRIMITIVES.NUMBER,
|
|
20
|
-
validator: [
|
|
21
|
+
validator: [
|
|
22
|
+
isNumberParam,
|
|
23
|
+
greaterThanOrEqualToReference(0),
|
|
24
|
+
isInteger,
|
|
25
|
+
],
|
|
21
26
|
},
|
|
22
27
|
],
|
|
23
28
|
transpiler: {
|
|
@@ -32,12 +37,13 @@ function elasticsearch(current, length) {
|
|
|
32
37
|
return `${ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, 0, ${length !== null && length !== void 0 ? length : 1})`;
|
|
33
38
|
}
|
|
34
39
|
function snowflake(current, length) {
|
|
35
|
-
return `LEFT(${current}, ${length !== null && length !== void 0 ? length : 1})`;
|
|
40
|
+
return `LEFT(${current}, FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER)`;
|
|
36
41
|
}
|
|
37
42
|
function SQL(current, length) {
|
|
38
|
-
const _length = length !== null && length !== void 0 ? length : 1
|
|
43
|
+
const _length = `FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER`;
|
|
39
44
|
return `
|
|
40
45
|
(case
|
|
46
|
+
when ${length !== null && length !== void 0 ? length : 1} IS NULL then NULL
|
|
41
47
|
when (${_length} < 0) then ''
|
|
42
48
|
else
|
|
43
49
|
LEFT(${current}, ${_length})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"left.js","sourceRoot":"","sources":["../../../src/functions/left.ts"],"names":[],"mappings":"AAAA,OAAO,E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AM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,MAAc;IACxC,MAAM,OAAO,GAAG,SAAS,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,YAAY,CAAC;IACjD,OAAO;;eAEI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC;UAChB,OAAO;;eAEF,OAAO,KAAK,OAAO;;MAE5B,CAAC,IAAI,EAAE,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,MAAc;IAC/C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AST_PRIMITIVES, ELASTICSEARCH_SCRIPT_NAMES } from '../constants';
|
|
2
2
|
import { isNumberParam, isStringParam } from '../utils';
|
|
3
3
|
import { greaterThanOrEqualToReference } from '../utils/greaterThanOrEqualToReference';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `MID` Returns a segment of a string.
|
|
6
7
|
*/
|
|
@@ -17,13 +18,17 @@ export const MID = {
|
|
|
17
18
|
identifier: 'STARTING_AT',
|
|
18
19
|
optional: false,
|
|
19
20
|
expectedPrimitive: AST_PRIMITIVES.NUMBER,
|
|
20
|
-
validator: [isNumberParam],
|
|
21
|
+
validator: [isNumberParam, isInteger],
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
identifier: 'EXTRACT_LENGTH',
|
|
24
25
|
optional: false,
|
|
25
26
|
expectedPrimitive: AST_PRIMITIVES.NUMBER,
|
|
26
|
-
validator: [
|
|
27
|
+
validator: [
|
|
28
|
+
isNumberParam,
|
|
29
|
+
greaterThanOrEqualToReference(0),
|
|
30
|
+
isInteger,
|
|
31
|
+
],
|
|
27
32
|
},
|
|
28
33
|
],
|
|
29
34
|
transpiler: {
|
|
@@ -37,21 +42,25 @@ export const MID = {
|
|
|
37
42
|
function elasticsearch(current, start, length) {
|
|
38
43
|
return `${ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, ${start}, ${length})`;
|
|
39
44
|
}
|
|
45
|
+
function sqlRound(value) {
|
|
46
|
+
return `(FLOOR(ABS(${value})) * (CASE WHEN ${value} < 0 THEN -1 ELSE 1 END))`;
|
|
47
|
+
}
|
|
40
48
|
function snowflake(current, start, length) {
|
|
41
|
-
return `SUBSTRING(${current}, ${start}, ${length})`;
|
|
49
|
+
return `SUBSTRING(${current}, ${sqlRound(start)} , ${sqlRound(length)})`;
|
|
42
50
|
}
|
|
43
51
|
function SQL(current, start, length) {
|
|
44
52
|
return `
|
|
45
53
|
(case
|
|
46
|
-
|
|
54
|
+
when ${current} IS NULL OR ${start} IS NULL OR ${length} IS NULL then NULL
|
|
55
|
+
when (${sqlRound(length)} < 0) OR (${sqlRound(start)} * -1) > LENGTH(${current}) then ''
|
|
47
56
|
else
|
|
48
57
|
SUBSTRING(${current},
|
|
49
58
|
(case
|
|
50
|
-
when ${start} < 0 then (LENGTH(${current}) + ${start} + 1)
|
|
51
|
-
when ${start} = 0 then 1
|
|
52
|
-
else ${start}
|
|
53
|
-
end),
|
|
54
|
-
${length})
|
|
59
|
+
when ${sqlRound(start)} < 0 then (LENGTH(${current}) + ${sqlRound(start)} + 1)
|
|
60
|
+
when ${sqlRound(start)} = 0 then 1
|
|
61
|
+
else ${sqlRound(start)}
|
|
62
|
+
end)::INTEGER,
|
|
63
|
+
${sqlRound(length)}::INTEGER)
|
|
55
64
|
end
|
|
56
65
|
)`.trim();
|
|
57
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mid.js","sourceRoot":"","sources":["../../../src/functions/mid.ts"],"names":[],"mappings":"AAAA,OA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SAAS,IAAI,OAAO,KAAK,KAAK,KAAK,MAAM,GAAG,CAAC;AACtF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,cAAc,KAAK,mBAAmB,KAAK,2BAA2B,CAAC;AAClF,CAAC;AAED,SAAS,SAAS,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC7D,OAAO,aAAa,OAAO,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;AAC7E,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IACvD,OAAO;;eAEI,OAAO,eAAe,KAAK,eAAe,MAAM;UACrD,QAAQ,CAAC,MAAM,CAAC,aAAa,QAAQ,CACvC,KAAK,CACR,mBAAmB,OAAO;;oBAEX,OAAO;;uBAEJ,QAAQ,CACX,KAAK,CACR,qBAAqB,OAAO,OAAO,QAAQ,CAAC,KAAK,CAAC;uBAC5C,QAAQ,CAAC,KAAK,CAAC;uBACf,QAAQ,CAAC,KAAK,CAAC;;cAExB,QAAQ,CAAC,MAAM,CAAC;;MAExB,CAAC,IAAI,EAAE,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC5D,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,KAAa,EAAE,MAAc;IAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AST_PRIMITIVES, ELASTICSEARCH_SCRIPT_NAMES } from '../constants';
|
|
2
2
|
import { isNumberParam, isStringParam } from '../utils';
|
|
3
3
|
import { greaterThanOrEqualToReference } from '../utils/greaterThanOrEqualToReference';
|
|
4
|
+
import { isInteger } from '../utils/isInteger';
|
|
4
5
|
/**
|
|
5
6
|
* `RIGHT` Returns the last character or characters in a text string, based on the number of characters you specify.
|
|
6
7
|
*/
|
|
@@ -17,7 +18,11 @@ export const RIGHT = {
|
|
|
17
18
|
identifier: 'EXTRACT_LENGTH',
|
|
18
19
|
optional: true,
|
|
19
20
|
expectedPrimitive: AST_PRIMITIVES.NUMBER,
|
|
20
|
-
validator: [
|
|
21
|
+
validator: [
|
|
22
|
+
isNumberParam,
|
|
23
|
+
greaterThanOrEqualToReference(0),
|
|
24
|
+
isInteger,
|
|
25
|
+
],
|
|
21
26
|
},
|
|
22
27
|
],
|
|
23
28
|
transpiler: {
|
|
@@ -33,12 +38,13 @@ function elasticsearch(current, length) {
|
|
|
33
38
|
return `${ELASTICSEARCH_SCRIPT_NAMES.subString}(${current}, ${_length} * -1, ${_length})`;
|
|
34
39
|
}
|
|
35
40
|
function snowflake(current, length) {
|
|
36
|
-
return `RIGHT(${current}, ${length !== null && length !== void 0 ? length : 1})`;
|
|
41
|
+
return `RIGHT(${current}, FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER)`;
|
|
37
42
|
}
|
|
38
43
|
function SQL(current, length) {
|
|
39
|
-
const _length = length !== null && length !== void 0 ? length : 1
|
|
44
|
+
const _length = `FLOOR(${length !== null && length !== void 0 ? length : 1})::INTEGER`;
|
|
40
45
|
return `
|
|
41
46
|
(case
|
|
47
|
+
when ${length !== null && length !== void 0 ? length : 1} IS NULL then NULL
|
|
42
48
|
when (${_length} < 0) then ''
|
|
43
49
|
else
|
|
44
50
|
RIGHT(${current}, ${_length})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"right.js","sourceRoot":"","sources":["../../../src/functions/right.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,w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,MAAc;IACxC,MAAM,OAAO,GAAG,SAAS,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC,YAAY,CAAC;IACjD,OAAO;;eAEI,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,CAAC;UAChB,OAAO;;gBAED,OAAO,KAAK,OAAO;;MAE7B,CAAC,IAAI,EAAE,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,OAAe,EAAE,MAAc;IAC7C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,MAAc;IAC/C,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { DateDifUnitParam } from '../../constants/interfaces';
|
|
|
2
2
|
export declare function toDate(value: string): string;
|
|
3
3
|
export declare const setTimezoneToColumnDate: string;
|
|
4
4
|
export declare const dateFormatScript: string;
|
|
5
|
-
export declare const subStringScript: string;
|
|
6
5
|
export declare const dayScript: (value: any) => string;
|
|
7
6
|
export declare const monthScript: (value: any) => string;
|
|
8
7
|
export declare const yearScript: (value: any) => string;
|
|
@@ -27,3 +26,4 @@ export declare const powerScript = "def POWER(def value, def numberToRaise) {\n
|
|
|
27
26
|
export declare const roundDownScript = "def ROUNDDOWN(def value, def places) {\n if (value == null || places == null) return null; \n if (places > 10) places = 10;\n if (places < 0) places = 0;\n def _value = Math.abs(value);\n def sign = value < 0 ? -1 : 1;\n def scale = Math.pow(10, places);\n return (Math.floor(_value * scale) / scale) * sign;\n}";
|
|
28
27
|
export declare const roundScript: string;
|
|
29
28
|
export declare const roundUpScript: string;
|
|
29
|
+
export declare const subStringScript: string;
|
|
@@ -25,22 +25,6 @@ String ${SCRIPT_NAMES.dateFormat}(def date_value, String format) {
|
|
|
25
25
|
return DateTimeFormatter.ofPattern(format).format(date_value)
|
|
26
26
|
}
|
|
27
27
|
`;
|
|
28
|
-
export const subStringScript = `
|
|
29
|
-
String ${SCRIPT_NAMES.subString}(String text, int start, int end) {
|
|
30
|
-
int first = 0;
|
|
31
|
-
if (end < 0 || (start * -1 > text.length())) return "";
|
|
32
|
-
if (start < 0) {
|
|
33
|
-
first = (int) Math.max(text.length() + start, 0);
|
|
34
|
-
} else if (start == 0) {
|
|
35
|
-
first = 0;
|
|
36
|
-
} else {
|
|
37
|
-
first = (int) Math.min(start - 1, text.length())
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
int last = (int) Math.min(first + end, text.length());
|
|
41
|
-
return text.substring(first, last);
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
28
|
function dateFormatToInt(value, format) {
|
|
45
29
|
return `Integer.parseInt(${SCRIPT_NAMES.dateFormat}(${value}, '${format}'))`;
|
|
46
30
|
}
|
|
@@ -190,4 +174,24 @@ def ROUNDUP(def value, def places) {
|
|
|
190
174
|
def scale = Math.pow(10, places);
|
|
191
175
|
return (Math.ceil(_value * scale) / scale) * sign;
|
|
192
176
|
}`;
|
|
177
|
+
export const subStringScript = `${roundDownScript}
|
|
178
|
+
String ${SCRIPT_NAMES.subString}(def text, def start, def end) {
|
|
179
|
+
if (text == null || start == null || end == null) return null;
|
|
180
|
+
text = (String) text;
|
|
181
|
+
start = ROUNDDOWN(start, 0);
|
|
182
|
+
end = ROUNDDOWN(end, 0);
|
|
183
|
+
int first = 0;
|
|
184
|
+
if (end < 0 || (start * -1 > text.length())) return "";
|
|
185
|
+
if (start < 0) {
|
|
186
|
+
first = (int) Math.max(text.length() + start, 0);
|
|
187
|
+
} else if (start == 0) {
|
|
188
|
+
first = 0;
|
|
189
|
+
} else {
|
|
190
|
+
first = (int) Math.min(start - 1, text.length())
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
int last = (int) Math.min(first + end, text.length());
|
|
194
|
+
return text.substring(first, last);
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
193
197
|
//# sourceMappingURL=scripts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,UAAU,MAAM,CAAC,KAAa;IAChC,OAAO,wBAAwB,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;MACjC,YAAY,CAAC,WAAW;;;;;;;;;;;CAW7B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;SACvB,YAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../../src/utils/elasticsearch/scripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,UAAU,MAAM,CAAC,KAAa;IAChC,OAAO,wBAAwB,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;MACjC,YAAY,CAAC,WAAW;;;;;;;;;;;CAW7B,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;SACvB,YAAY,CAAC,UAAU;;;;;;;;CAQ/B,CAAC;AAEF,SAAS,eAAe,CAAC,KAAU,EAAE,MAAc;IAC/C,OAAO,oBAAoB,YAAY,CAAC,UAAU,IAAI,KAAK,MAAM,MAAM,KAAK,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAU,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