@malloydata/malloy 0.0.22-dev230126015148 → 0.0.22-dev230202171033
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/lang/ast/ast-main.d.ts +18 -815
- package/dist/lang/ast/ast-main.js +106 -3241
- package/dist/lang/ast/ast-utils.d.ts +10 -0
- package/dist/lang/ast/ast-utils.js +42 -0
- package/dist/lang/ast/elements/define-explore.d.ts +17 -0
- package/dist/lang/ast/elements/define-explore.js +79 -0
- package/dist/lang/ast/elements/define-query.d.ts +14 -0
- package/dist/lang/ast/elements/define-query.js +56 -0
- package/dist/lang/ast/elements/mallobj.d.ts +12 -0
- package/dist/lang/ast/elements/mallobj.js +53 -0
- package/dist/lang/ast/elements/pipeline-desc.d.ts +28 -0
- package/dist/lang/ast/elements/pipeline-desc.js +102 -0
- package/dist/lang/ast/elements/refined-explore.d.ts +15 -0
- package/dist/lang/ast/elements/refined-explore.js +121 -0
- package/dist/lang/ast/error-factory.d.ts +9 -0
- package/dist/lang/ast/error-factory.js +61 -0
- package/dist/lang/ast/executors/index-executor.d.ts +18 -0
- package/dist/lang/ast/executors/index-executor.js +96 -0
- package/dist/lang/ast/executors/project-executor.d.ts +10 -0
- package/dist/lang/ast/executors/project-executor.js +68 -0
- package/dist/lang/ast/executors/reduce-executor.d.ts +20 -0
- package/dist/lang/ast/executors/reduce-executor.js +149 -0
- package/dist/lang/ast/explore-properties/field-list-edit.d.ts +8 -0
- package/dist/lang/ast/explore-properties/field-list-edit.js +36 -0
- package/dist/lang/ast/explore-properties/primary-key.d.ts +7 -0
- package/dist/lang/ast/{apply-expr.js → explore-properties/primary-key.js} +9 -8
- package/dist/lang/ast/explore-properties/renames.d.ts +11 -0
- package/dist/lang/ast/explore-properties/renames.js +43 -0
- package/dist/lang/ast/explore-properties/turtles.d.ts +5 -0
- package/dist/lang/ast/explore-properties/turtles.js +33 -0
- package/dist/lang/ast/expressions/apply.d.ts +8 -0
- package/dist/lang/ast/expressions/apply.js +37 -0
- package/dist/lang/ast/expressions/binary-boolean.d.ts +12 -0
- package/dist/lang/ast/expressions/binary-boolean.js +54 -0
- package/dist/lang/ast/expressions/binary-numeric.d.ts +11 -0
- package/dist/lang/ast/expressions/binary-numeric.js +42 -0
- package/dist/lang/ast/expressions/boolean.d.ts +8 -0
- package/dist/lang/ast/expressions/boolean.js +39 -0
- package/dist/lang/ast/expressions/constant-sub-expression.d.ts +16 -0
- package/dist/lang/ast/expressions/constant-sub-expression.js +98 -0
- package/dist/lang/ast/expressions/expr-add-sub.d.ts +4 -0
- package/dist/lang/ast/expressions/expr-add-sub.js +34 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +15 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.js +99 -0
- package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-alternation-tree.js +54 -0
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-asymmetric.js +27 -0
- package/dist/lang/ast/expressions/expr-avg.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-avg.js +34 -0
- package/dist/lang/ast/expressions/expr-case.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-case.js +84 -0
- package/dist/lang/ast/expressions/expr-cast.d.ts +13 -0
- package/dist/lang/ast/expressions/expr-cast.js +29 -0
- package/dist/lang/ast/expressions/expr-compare.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-compare.js +48 -0
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-count-distinct.js +35 -0
- package/dist/lang/ast/expressions/expr-count.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-count.js +57 -0
- package/dist/lang/ast/expressions/expr-filter.d.ts +12 -0
- package/dist/lang/ast/expressions/expr-filter.js +69 -0
- package/dist/lang/ast/expressions/expr-func.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-func.js +63 -0
- package/dist/lang/ast/expressions/expr-granular-time.d.ts +24 -0
- package/dist/lang/ast/expressions/expr-granular-time.js +117 -0
- package/dist/lang/ast/expressions/expr-id-reference.d.ts +12 -0
- package/dist/lang/ast/expressions/expr-id-reference.js +76 -0
- package/dist/lang/ast/expressions/expr-logical-op.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-logical-op.js +36 -0
- package/dist/lang/ast/expressions/expr-max.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-max.js +16 -0
- package/dist/lang/ast/expressions/expr-min.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-min.js +16 -0
- package/dist/lang/ast/expressions/expr-minus.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-minus.js +48 -0
- package/dist/lang/ast/expressions/expr-mul-div.d.ts +4 -0
- package/dist/lang/ast/expressions/expr-mul-div.js +34 -0
- package/dist/lang/ast/expressions/expr-not.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-not.js +49 -0
- package/dist/lang/ast/expressions/expr-now.d.ts +7 -0
- package/dist/lang/ast/expressions/expr-now.js +46 -0
- package/dist/lang/ast/expressions/expr-null.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-null.js +41 -0
- package/dist/lang/ast/expressions/expr-number.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-number.js +42 -0
- package/dist/lang/ast/expressions/expr-parens.d.ts +10 -0
- package/dist/lang/ast/expressions/expr-parens.js +42 -0
- package/dist/lang/ast/expressions/expr-regex.d.ts +8 -0
- package/dist/lang/ast/expressions/expr-regex.js +42 -0
- package/dist/lang/ast/expressions/expr-string.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-string.js +50 -0
- package/dist/lang/ast/expressions/expr-sum.d.ts +6 -0
- package/dist/lang/ast/expressions/expr-sum.js +12 -0
- package/dist/lang/ast/expressions/expr-time-extract.d.ts +13 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +117 -0
- package/dist/lang/ast/expressions/expr-time.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-time.js +62 -0
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +14 -0
- package/dist/lang/ast/expressions/expr-ungroup.js +83 -0
- package/dist/lang/ast/expressions/for-range.d.ts +19 -0
- package/dist/lang/ast/expressions/for-range.js +101 -0
- package/dist/lang/ast/expressions/granular-literal.d.ts +20 -0
- package/dist/lang/ast/expressions/granular-literal.js +148 -0
- package/dist/lang/ast/expressions/partial-compare.d.ts +14 -0
- package/dist/lang/ast/expressions/partial-compare.js +50 -0
- package/dist/lang/ast/expressions/pick-when.d.ts +19 -0
- package/dist/lang/ast/expressions/pick-when.js +156 -0
- package/dist/lang/ast/expressions/range.d.ts +12 -0
- package/dist/lang/ast/expressions/range.js +80 -0
- package/dist/lang/ast/expressions/time-frame.d.ts +7 -0
- package/dist/lang/ast/expressions/time-frame.js +40 -0
- package/dist/lang/ast/expressions/top-by.d.ts +10 -0
- package/dist/lang/ast/expressions/top-by.js +51 -0
- package/dist/lang/ast/expressions/unary.d.ts +5 -0
- package/dist/lang/ast/expressions/unary.js +34 -0
- package/dist/lang/ast/expressions/utils.d.ts +15 -0
- package/dist/lang/ast/expressions/utils.js +106 -0
- package/dist/lang/ast/expressions/when-clause.d.ts +10 -0
- package/dist/lang/ast/expressions/when-clause.js +17 -0
- package/dist/lang/ast/fragtype-utils.d.ts +39 -0
- package/dist/lang/ast/fragtype-utils.js +100 -0
- package/dist/lang/ast/import-elements/import-statement.d.ts +9 -0
- package/dist/lang/ast/import-elements/import-statement.js +78 -0
- package/dist/lang/ast/index.d.ts +94 -3
- package/dist/lang/ast/index.js +94 -3
- package/dist/lang/ast/json-elements/json-element.d.ts +6 -0
- package/dist/lang/ast/json-elements/json-element.js +41 -0
- package/dist/lang/ast/json-elements/json-struct-def.d.ts +10 -0
- package/dist/lang/ast/json-elements/json-struct-def.js +48 -0
- package/dist/lang/ast/nesting/nest-reference.d.ts +7 -0
- package/dist/lang/ast/nesting/nest-reference.js +35 -0
- package/dist/lang/ast/parameters/constant-parameter.d.ts +8 -0
- package/dist/lang/ast/parameters/constant-parameter.js +54 -0
- package/dist/lang/ast/parameters/has-parameter.d.ts +19 -0
- package/dist/lang/ast/parameters/has-parameter.js +64 -0
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +9 -0
- package/dist/lang/ast/query-elements/anonymous-query.js +41 -0
- package/dist/lang/ast/query-elements/existing-query.d.ts +11 -0
- package/dist/lang/ast/query-elements/existing-query.js +79 -0
- package/dist/lang/ast/query-elements/full-query.d.ts +10 -0
- package/dist/lang/ast/query-elements/full-query.js +85 -0
- package/dist/lang/ast/query-elements/query-head-struct.d.ts +9 -0
- package/dist/lang/ast/query-elements/query-head-struct.js +48 -0
- package/dist/lang/ast/query-items/field-declaration.d.ts +31 -0
- package/dist/lang/ast/query-items/field-declaration.js +137 -0
- package/dist/lang/ast/query-items/field-references.d.ts +25 -0
- package/dist/lang/ast/query-items/field-references.js +80 -0
- package/dist/lang/ast/query-properties/aggregate.d.ts +5 -0
- package/dist/lang/ast/query-properties/aggregate.js +39 -0
- package/dist/lang/ast/query-properties/declare-fields.d.ts +5 -0
- package/dist/lang/ast/query-properties/declare-fields.js +33 -0
- package/dist/lang/ast/query-properties/dimmensions.d.ts +5 -0
- package/dist/lang/ast/query-properties/dimmensions.js +36 -0
- package/dist/lang/ast/query-properties/filters.d.ts +18 -0
- package/dist/lang/ast/query-properties/filters.js +89 -0
- package/dist/lang/ast/query-properties/group-by.d.ts +5 -0
- package/dist/lang/ast/query-properties/group-by.js +39 -0
- package/dist/lang/ast/query-properties/indexing.d.ts +10 -0
- package/dist/lang/ast/query-properties/indexing.js +39 -0
- package/dist/lang/ast/query-properties/joins.d.ts +36 -0
- package/dist/lang/ast/query-properties/joins.js +143 -0
- package/dist/lang/ast/query-properties/limit.d.ts +6 -0
- package/dist/lang/ast/query-properties/limit.js +35 -0
- package/dist/lang/ast/query-properties/measures.d.ts +5 -0
- package/dist/lang/ast/query-properties/measures.js +36 -0
- package/dist/lang/ast/query-properties/nests.d.ts +5 -0
- package/dist/lang/ast/query-properties/nests.js +33 -0
- package/dist/lang/ast/query-properties/ordering.d.ts +15 -0
- package/dist/lang/ast/query-properties/ordering.js +66 -0
- package/dist/lang/ast/query-properties/project-statement.d.ts +5 -0
- package/dist/lang/ast/query-properties/project-statement.js +33 -0
- package/dist/lang/ast/query-properties/qop-desc.d.ts +17 -0
- package/dist/lang/ast/query-properties/qop-desc.js +123 -0
- package/dist/lang/ast/query-properties/sampling.d.ts +8 -0
- package/dist/lang/ast/query-properties/sampling.js +38 -0
- package/dist/lang/ast/query-properties/top.d.ts +13 -0
- package/dist/lang/ast/query-properties/top.js +60 -0
- package/dist/lang/ast/result-spaces/index-field-space.d.ts +10 -0
- package/dist/lang/ast/result-spaces/index-field-space.js +57 -0
- package/dist/lang/ast/result-spaces/project-field-space.d.ts +6 -0
- package/dist/lang/ast/result-spaces/project-field-space.js +51 -0
- package/dist/lang/ast/result-spaces/reduce-field-space.d.ts +7 -0
- package/dist/lang/ast/result-spaces/reduce-field-space.js +37 -0
- package/dist/lang/ast/sources/named-source.d.ts +19 -0
- package/dist/lang/ast/sources/named-source.js +147 -0
- package/dist/lang/ast/sources/query-source.d.ts +9 -0
- package/dist/lang/ast/sources/query-source.js +41 -0
- package/dist/lang/ast/sources/sql-source.d.ts +7 -0
- package/dist/lang/ast/sources/sql-source.js +54 -0
- package/dist/lang/ast/sources/table-source.d.ts +8 -0
- package/dist/lang/ast/sources/table-source.js +60 -0
- package/dist/lang/ast/space-fields/column-space-field.d.ts +9 -0
- package/dist/lang/ast/space-fields/column-space-field.js +40 -0
- package/dist/lang/ast/space-fields/join-space-field.d.ts +8 -0
- package/dist/lang/ast/space-fields/join-space-field.js +35 -0
- package/dist/lang/ast/space-fields/query-field-struct.d.ts +10 -0
- package/dist/lang/ast/space-fields/query-field-struct.js +46 -0
- package/dist/lang/ast/space-fields/query-space-field.d.ts +11 -0
- package/dist/lang/ast/space-fields/query-space-field.js +37 -0
- package/dist/lang/ast/space-fields/reference-field.d.ts +11 -0
- package/dist/lang/ast/space-fields/reference-field.js +45 -0
- package/dist/lang/ast/space-fields/rename-space-field.d.ts +11 -0
- package/dist/lang/ast/space-fields/rename-space-field.js +50 -0
- package/dist/lang/ast/space-fields/wild-space-field.d.ts +10 -0
- package/dist/lang/ast/space-fields/wild-space-field.js +40 -0
- package/dist/lang/ast/space-parameters/abstract-parameter.d.ts +10 -0
- package/dist/lang/ast/space-parameters/abstract-parameter.js +41 -0
- package/dist/lang/ast/space-parameters/defined-parameter.d.ts +9 -0
- package/dist/lang/ast/space-parameters/defined-parameter.js +40 -0
- package/dist/lang/ast/space-seed.d.ts +17 -0
- package/dist/lang/ast/space-seed.js +59 -0
- package/dist/lang/ast/sql-elements/sql-statement.d.ts +19 -0
- package/dist/lang/ast/sql-elements/sql-statement.js +80 -0
- package/dist/lang/ast/sql-elements/sql-string.d.ts +12 -0
- package/dist/lang/ast/sql-elements/sql-string.js +60 -0
- package/dist/lang/ast/static-space.d.ts +33 -0
- package/dist/lang/ast/static-space.js +167 -0
- package/dist/lang/ast/struct-utils.d.ts +4 -0
- package/dist/lang/ast/struct-utils.js +48 -0
- package/dist/lang/ast/time-utils.d.ts +5 -2
- package/dist/lang/ast/time-utils.js +37 -1
- package/dist/lang/ast/types/comparison.d.ts +11 -0
- package/dist/lang/ast/types/comparison.js +41 -0
- package/dist/lang/ast/types/compart-types.d.ts +10 -0
- package/dist/lang/ast/types/compart-types.js +37 -0
- package/dist/lang/ast/types/document-compile-result.d.ts +8 -0
- package/dist/lang/ast/types/document-compile-result.js +25 -0
- package/dist/lang/ast/types/equality.d.ts +7 -0
- package/dist/lang/ast/types/equality.js +37 -0
- package/dist/lang/ast/types/executor.d.ts +9 -0
- package/dist/lang/ast/types/executor.js +25 -0
- package/dist/lang/ast/types/explore-desc.d.ts +5 -0
- package/dist/lang/ast/types/explore-desc.js +33 -0
- package/dist/lang/ast/types/explore-field.d.ts +5 -0
- package/dist/lang/ast/types/explore-field.js +32 -0
- package/dist/lang/ast/types/explore-property.d.ts +10 -0
- package/dist/lang/ast/types/explore-property.js +43 -0
- package/dist/lang/ast/types/expr-result.d.ts +5 -0
- package/dist/lang/ast/types/expr-result.js +25 -0
- package/dist/lang/ast/types/expr-value.d.ts +3 -0
- package/dist/lang/ast/types/expr-value.js +25 -0
- package/dist/lang/ast/types/expression-def.d.ts +69 -0
- package/dist/lang/ast/types/expression-def.js +346 -0
- package/dist/lang/ast/types/expression-value-type.d.ts +2 -0
- package/dist/lang/ast/types/expression-value-type.js +25 -0
- package/dist/lang/ast/types/field-collection-member.d.ts +5 -0
- package/dist/lang/ast/types/field-collection-member.js +34 -0
- package/dist/lang/ast/types/field-decl.d.ts +7 -0
- package/dist/lang/ast/types/field-decl.js +37 -0
- package/dist/lang/ast/types/field-map.d.ts +2 -0
- package/dist/lang/ast/types/field-map.js +25 -0
- package/dist/lang/ast/types/field-space.d.ts +26 -0
- package/dist/lang/ast/types/field-space.js +48 -0
- package/dist/lang/ast/types/field-type.d.ts +6 -0
- package/dist/lang/ast/types/field-type.js +25 -0
- package/dist/lang/ast/types/field-value-type.d.ts +3 -0
- package/dist/lang/ast/types/field-value-type.js +25 -0
- package/dist/lang/ast/types/frag-type.d.ts +6 -0
- package/dist/lang/ast/types/frag-type.js +25 -0
- package/dist/lang/ast/types/granular-result.d.ts +7 -0
- package/dist/lang/ast/types/granular-result.js +11 -0
- package/dist/lang/ast/types/lookup-result.d.ts +10 -0
- package/dist/lang/ast/types/lookup-result.js +25 -0
- package/dist/lang/ast/types/malloy-element.d.ts +105 -0
- package/dist/lang/ast/types/malloy-element.js +398 -0
- package/dist/lang/ast/types/model-entry.d.ts +6 -0
- package/dist/lang/ast/types/model-entry.js +25 -0
- package/dist/lang/ast/types/name-space.d.ts +5 -0
- package/dist/lang/ast/types/name-space.js +25 -0
- package/dist/lang/ast/types/nested-query.d.ts +3 -0
- package/dist/lang/ast/types/nested-query.js +25 -0
- package/dist/lang/ast/types/op-desc.d.ts +6 -0
- package/dist/lang/ast/types/op-desc.js +25 -0
- package/dist/lang/ast/types/query-comp.d.ts +5 -0
- package/dist/lang/ast/types/query-comp.js +25 -0
- package/dist/lang/ast/types/query-element.d.ts +5 -0
- package/dist/lang/ast/types/query-element.js +32 -0
- package/dist/lang/ast/types/query-item.d.ts +5 -0
- package/dist/lang/ast/types/query-item.js +25 -0
- package/dist/lang/ast/types/query-property.d.ts +17 -0
- package/dist/lang/ast/types/query-property.js +55 -0
- package/dist/lang/ast/types/space-entry.d.ts +5 -0
- package/dist/lang/ast/types/space-entry.js +29 -0
- package/dist/lang/ast/types/space-field.d.ts +10 -0
- package/dist/lang/ast/types/space-field.js +48 -0
- package/dist/lang/ast/types/space-param.d.ts +6 -0
- package/dist/lang/ast/types/space-param.js +34 -0
- package/dist/lang/ast/types/stage-field-type.d.ts +1 -0
- package/dist/lang/ast/types/stage-field-type.js +25 -0
- package/dist/lang/ast/types/time-result.d.ts +6 -0
- package/dist/lang/ast/types/time-result.js +25 -0
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +7 -0
- package/dist/lang/ast/types/turtle-headed-pipe.js +37 -0
- package/dist/lang/space-field.d.ts +4 -1
- package/dist/lang/space-field.js +4 -3
- package/dist/lang/test/field-symbols.spec.js +25 -21
- package/dist/lang/test/parse.spec.js +4 -3
- package/dist/lang/test/test-translator.d.ts +3 -1
- package/package.json +1 -1
- package/dist/lang/ast/apply-expr.d.ts +0 -3
- package/dist/lang/ast/ast-expr.d.ts +0 -206
- package/dist/lang/ast/ast-expr.js +0 -781
- package/dist/lang/ast/ast-time-expr.d.ts +0 -69
- package/dist/lang/ast/ast-time-expr.js +0 -389
- package/dist/lang/ast/ast-types.d.ts +0 -83
- package/dist/lang/ast/ast-types.js +0 -225
|
@@ -0,0 +1,42 @@
|
|
|
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.BinaryNumeric = void 0;
|
|
26
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
27
|
+
const expression_def_1 = require("../types/expression-def");
|
|
28
|
+
class BinaryNumeric extends expression_def_1.ExpressionDef {
|
|
29
|
+
constructor(left, op, right) {
|
|
30
|
+
super({ left, right });
|
|
31
|
+
this.left = left;
|
|
32
|
+
this.op = op;
|
|
33
|
+
this.right = right;
|
|
34
|
+
this.elementType = "numeric binary abstract";
|
|
35
|
+
this.legalChildTypes = [fragtype_utils_1.FT.numberT];
|
|
36
|
+
}
|
|
37
|
+
getExpression(fs) {
|
|
38
|
+
return this.right.apply(fs, this.op, this.left);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.BinaryNumeric = BinaryNumeric;
|
|
42
|
+
//# sourceMappingURL=binary-numeric.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
3
|
+
export declare class Boolean extends ExpressionDef {
|
|
4
|
+
readonly value: "true" | "false";
|
|
5
|
+
elementType: string;
|
|
6
|
+
constructor(value: "true" | "false");
|
|
7
|
+
getExpression(): ExprValue;
|
|
8
|
+
}
|
|
@@ -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.Boolean = void 0;
|
|
26
|
+
const expression_def_1 = require("../types/expression-def");
|
|
27
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
28
|
+
class Boolean extends expression_def_1.ExpressionDef {
|
|
29
|
+
constructor(value) {
|
|
30
|
+
super();
|
|
31
|
+
this.value = value;
|
|
32
|
+
this.elementType = "boolean literal";
|
|
33
|
+
}
|
|
34
|
+
getExpression() {
|
|
35
|
+
return { ...fragtype_utils_1.FT.boolT, value: [this.value] };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Boolean = Boolean;
|
|
39
|
+
//# sourceMappingURL=boolean.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AtomicFieldType } from "../../../model/malloy_types";
|
|
2
|
+
import { ExprValue } from "../types/expr-value";
|
|
3
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
4
|
+
import { FieldSpace } from "../types/field-space";
|
|
5
|
+
export declare class ConstantSubExpression extends ExpressionDef {
|
|
6
|
+
readonly expr: ExpressionDef;
|
|
7
|
+
elementType: string;
|
|
8
|
+
private cfs?;
|
|
9
|
+
constructor(expr: ExpressionDef);
|
|
10
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
11
|
+
private get constantFs();
|
|
12
|
+
constantValue(): ExprValue;
|
|
13
|
+
constantCondition(type: AtomicFieldType): ExprValue;
|
|
14
|
+
apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
15
|
+
requestExpression(fs: FieldSpace): ExprValue | undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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.ConstantSubExpression = void 0;
|
|
26
|
+
const comparison_1 = require("../types/comparison");
|
|
27
|
+
const expr_compare_1 = require("./expr-compare");
|
|
28
|
+
const expression_def_1 = require("../types/expression-def");
|
|
29
|
+
const utils_1 = require("./utils");
|
|
30
|
+
class ConstantFieldSpace {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.type = "fieldSpace";
|
|
33
|
+
}
|
|
34
|
+
structDef() {
|
|
35
|
+
throw new Error("ConstantFieldSpace cannot generate a structDef");
|
|
36
|
+
}
|
|
37
|
+
emptyStructDef() {
|
|
38
|
+
throw new Error("ConstantFieldSpace cannot generate a structDef");
|
|
39
|
+
}
|
|
40
|
+
lookup(_name) {
|
|
41
|
+
return {
|
|
42
|
+
error: "Only constants allowed in parameter expressions",
|
|
43
|
+
found: undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
dialectObj() {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
whenComplete(step) {
|
|
50
|
+
step();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class DollarReference extends expression_def_1.ExpressionDef {
|
|
54
|
+
constructor(refType) {
|
|
55
|
+
super();
|
|
56
|
+
this.refType = refType;
|
|
57
|
+
this.elementType = "$";
|
|
58
|
+
}
|
|
59
|
+
getExpression(_fs) {
|
|
60
|
+
return {
|
|
61
|
+
dataType: this.refType,
|
|
62
|
+
value: [{ type: "applyVal" }],
|
|
63
|
+
expressionType: "scalar",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class ConstantSubExpression extends expression_def_1.ExpressionDef {
|
|
68
|
+
constructor(expr) {
|
|
69
|
+
super({ expr });
|
|
70
|
+
this.expr = expr;
|
|
71
|
+
this.elementType = "constantExpression";
|
|
72
|
+
}
|
|
73
|
+
getExpression(_fs) {
|
|
74
|
+
return this.constantValue();
|
|
75
|
+
}
|
|
76
|
+
get constantFs() {
|
|
77
|
+
if (!this.cfs) {
|
|
78
|
+
this.cfs = new ConstantFieldSpace();
|
|
79
|
+
}
|
|
80
|
+
return this.cfs;
|
|
81
|
+
}
|
|
82
|
+
constantValue() {
|
|
83
|
+
return this.expr.getExpression(this.constantFs);
|
|
84
|
+
}
|
|
85
|
+
constantCondition(type) {
|
|
86
|
+
const compareAndContrast = new expr_compare_1.ExprCompare(new DollarReference(type), comparison_1.Comparison.EqualTo, this.expr);
|
|
87
|
+
const application = compareAndContrast.getExpression(this.constantFs);
|
|
88
|
+
return { ...application, value: (0, utils_1.compressExpr)(application.value) };
|
|
89
|
+
}
|
|
90
|
+
apply(fs, op, expr) {
|
|
91
|
+
return this.expr.apply(fs, op, expr);
|
|
92
|
+
}
|
|
93
|
+
requestExpression(fs) {
|
|
94
|
+
return this.expr.requestExpression(fs);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.ConstantSubExpression = ConstantSubExpression;
|
|
98
|
+
//# sourceMappingURL=constant-sub-expression.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.ExprAddSub = void 0;
|
|
26
|
+
const binary_numeric_1 = require("./binary-numeric");
|
|
27
|
+
class ExprAddSub extends binary_numeric_1.BinaryNumeric {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.elementType = "+-";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ExprAddSub = ExprAddSub;
|
|
34
|
+
//# sourceMappingURL=expr-add-sub.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { FieldValueType } from "../types/field-value-type";
|
|
3
|
+
import { FieldReference } from "../query-items/field-references";
|
|
4
|
+
import { FieldSpace } from "../types/field-space";
|
|
5
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
6
|
+
export declare abstract class ExprAggregateFunction extends ExpressionDef {
|
|
7
|
+
readonly func: string;
|
|
8
|
+
elementType: string;
|
|
9
|
+
source?: FieldReference;
|
|
10
|
+
expr?: ExpressionDef;
|
|
11
|
+
legalChildTypes: import("../types/frag-type").FragType[];
|
|
12
|
+
constructor(func: string, expr?: ExpressionDef);
|
|
13
|
+
returns(_forExpression: ExprValue): FieldValueType;
|
|
14
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
15
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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.ExprAggregateFunction = void 0;
|
|
26
|
+
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
+
const ast_utils_1 = require("../ast-utils");
|
|
28
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
29
|
+
const static_space_1 = require("../static-space");
|
|
30
|
+
const expression_def_1 = require("../types/expression-def");
|
|
31
|
+
class ExprAggregateFunction extends expression_def_1.ExpressionDef {
|
|
32
|
+
constructor(func, expr) {
|
|
33
|
+
super();
|
|
34
|
+
this.func = func;
|
|
35
|
+
this.legalChildTypes = [fragtype_utils_1.FT.numberT];
|
|
36
|
+
this.elementType = func;
|
|
37
|
+
if (expr) {
|
|
38
|
+
this.expr = expr;
|
|
39
|
+
this.has({ expr });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
returns(_forExpression) {
|
|
43
|
+
return "number";
|
|
44
|
+
}
|
|
45
|
+
getExpression(fs) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
let exprVal = (_a = this.expr) === null || _a === void 0 ? void 0 : _a.getExpression(fs);
|
|
48
|
+
let structPath = (_b = this.source) === null || _b === void 0 ? void 0 : _b.refString;
|
|
49
|
+
if (this.source) {
|
|
50
|
+
const sourceFoot = this.source.getField(fs).found;
|
|
51
|
+
if (sourceFoot) {
|
|
52
|
+
const footType = sourceFoot.type();
|
|
53
|
+
if ((0, malloy_types_1.isAtomicFieldType)(footType.type)) {
|
|
54
|
+
exprVal = {
|
|
55
|
+
dataType: footType.type,
|
|
56
|
+
expressionType: footType.expressionType || "scalar",
|
|
57
|
+
value: [{ type: "field", path: this.source.refString }],
|
|
58
|
+
};
|
|
59
|
+
structPath = this.source.sourceString;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (!(sourceFoot instanceof static_space_1.StructSpaceField)) {
|
|
63
|
+
this.log(`Aggregate source cannot be a ${footType.type}`);
|
|
64
|
+
return (0, ast_utils_1.errorFor)(`Aggregate source cannot be a ${footType.type}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.log(`Reference to undefined value ${this.source.refString}`);
|
|
70
|
+
return (0, ast_utils_1.errorFor)(`Reference to undefined value ${this.source.refString}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (exprVal === undefined) {
|
|
74
|
+
this.log("Missing expression for aggregate function");
|
|
75
|
+
return (0, ast_utils_1.errorFor)("agggregate without expression");
|
|
76
|
+
}
|
|
77
|
+
if (this.typeCheck(this.expr || this, {
|
|
78
|
+
...exprVal,
|
|
79
|
+
expressionType: "scalar",
|
|
80
|
+
})) {
|
|
81
|
+
const f = {
|
|
82
|
+
type: "aggregate",
|
|
83
|
+
function: this.func,
|
|
84
|
+
e: exprVal.value,
|
|
85
|
+
};
|
|
86
|
+
if (structPath) {
|
|
87
|
+
f.structPath = structPath;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
dataType: this.returns(exprVal),
|
|
91
|
+
expressionType: "aggregate",
|
|
92
|
+
value: [f],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return (0, ast_utils_1.errorFor)("aggregate type check");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.ExprAggregateFunction = ExprAggregateFunction;
|
|
99
|
+
//# sourceMappingURL=expr-aggregate-function.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { BinaryBoolean } from "./binary-boolean";
|
|
3
|
+
import { FieldSpace } from "../types/field-space";
|
|
4
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
5
|
+
export declare class ExprAlternationTree extends BinaryBoolean<"|" | "&"> {
|
|
6
|
+
elementType: string;
|
|
7
|
+
constructor(left: ExpressionDef, op: "|" | "&", right: ExpressionDef);
|
|
8
|
+
apply(fs: FieldSpace, applyOp: string, expr: ExpressionDef): ExprValue;
|
|
9
|
+
requestExpression(_fs: FieldSpace): ExprValue | undefined;
|
|
10
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.ExprAlternationTree = void 0;
|
|
26
|
+
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
+
const ast_utils_1 = require("../ast-utils");
|
|
28
|
+
const binary_boolean_1 = require("./binary-boolean");
|
|
29
|
+
const utils_1 = require("./utils");
|
|
30
|
+
class ExprAlternationTree extends binary_boolean_1.BinaryBoolean {
|
|
31
|
+
constructor(left, op, right) {
|
|
32
|
+
super(left, op, right);
|
|
33
|
+
this.elementType = "alternation";
|
|
34
|
+
this.elementType = `${op}alternation${op}`;
|
|
35
|
+
}
|
|
36
|
+
apply(fs, applyOp, expr) {
|
|
37
|
+
const choice1 = this.left.apply(fs, applyOp, expr);
|
|
38
|
+
const choice2 = this.right.apply(fs, applyOp, expr);
|
|
39
|
+
return {
|
|
40
|
+
dataType: "boolean",
|
|
41
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(choice1.expressionType, choice2.expressionType),
|
|
42
|
+
value: (0, utils_1.compose)(choice1.value, this.op === "&" ? "and" : "or", choice2.value),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
requestExpression(_fs) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
getExpression(_fs) {
|
|
49
|
+
this.log(`Alternation tree has no value`);
|
|
50
|
+
return (0, ast_utils_1.errorFor)("no value from alternation tree");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ExprAlternationTree = ExprAlternationTree;
|
|
54
|
+
//# sourceMappingURL=expr-alternation-tree.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FieldReference } from "../query-items/field-references";
|
|
2
|
+
import { ExprAggregateFunction } from "./expr-aggregate-function";
|
|
3
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
4
|
+
export declare abstract class ExprAsymmetric extends ExprAggregateFunction {
|
|
5
|
+
readonly func: "sum" | "avg";
|
|
6
|
+
readonly expr: ExpressionDef | undefined;
|
|
7
|
+
readonly source?: FieldReference | undefined;
|
|
8
|
+
constructor(func: "sum" | "avg", expr: ExpressionDef | undefined, source?: FieldReference | undefined);
|
|
9
|
+
defaultFieldName(): undefined | string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExprAsymmetric = void 0;
|
|
4
|
+
const expr_aggregate_function_1 = require("./expr-aggregate-function");
|
|
5
|
+
class ExprAsymmetric extends expr_aggregate_function_1.ExprAggregateFunction {
|
|
6
|
+
constructor(func, expr, source) {
|
|
7
|
+
super(func, expr);
|
|
8
|
+
this.func = func;
|
|
9
|
+
this.expr = expr;
|
|
10
|
+
this.source = source;
|
|
11
|
+
this.has({ source });
|
|
12
|
+
}
|
|
13
|
+
defaultFieldName() {
|
|
14
|
+
if (this.source && this.expr === undefined) {
|
|
15
|
+
const tag = this.source.nameString;
|
|
16
|
+
switch (this.func) {
|
|
17
|
+
case "sum":
|
|
18
|
+
return `total_${tag}`;
|
|
19
|
+
case "avg":
|
|
20
|
+
return `avg_${tag}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ExprAsymmetric = ExprAsymmetric;
|
|
27
|
+
//# sourceMappingURL=expr-asymmetric.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
2
|
+
import { FieldReference } from "../query-items/field-references";
|
|
3
|
+
import { ExprAsymmetric } from "./expr-asymmetric";
|
|
4
|
+
export declare class ExprAvg extends ExprAsymmetric {
|
|
5
|
+
constructor(expr: ExpressionDef | undefined, source?: FieldReference);
|
|
6
|
+
}
|
|
@@ -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.ExprAvg = void 0;
|
|
26
|
+
const expr_asymmetric_1 = require("./expr-asymmetric");
|
|
27
|
+
class ExprAvg extends expr_asymmetric_1.ExprAsymmetric {
|
|
28
|
+
constructor(expr, source) {
|
|
29
|
+
super("avg", expr, source);
|
|
30
|
+
this.has({ source });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ExprAvg = ExprAvg;
|
|
34
|
+
//# sourceMappingURL=expr-avg.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { FieldSpace } from "../types/field-space";
|
|
3
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
4
|
+
import { WhenClause } from "./when-clause";
|
|
5
|
+
export declare class ExprCase extends ExpressionDef {
|
|
6
|
+
readonly when: WhenClause[];
|
|
7
|
+
readonly elseClause?: ExpressionDef | undefined;
|
|
8
|
+
elementType: string;
|
|
9
|
+
constructor(when: WhenClause[], elseClause?: ExpressionDef | undefined);
|
|
10
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
11
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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.ExprCase = void 0;
|
|
26
|
+
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
+
const ast_utils_1 = require("../ast-utils");
|
|
28
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
29
|
+
const expression_def_1 = require("../types/expression-def");
|
|
30
|
+
class ExprCase extends expression_def_1.ExpressionDef {
|
|
31
|
+
constructor(when, elseClause) {
|
|
32
|
+
super({ when });
|
|
33
|
+
this.when = when;
|
|
34
|
+
this.elseClause = elseClause;
|
|
35
|
+
this.elementType = "case statement";
|
|
36
|
+
this.has({ elseClause });
|
|
37
|
+
}
|
|
38
|
+
getExpression(fs) {
|
|
39
|
+
let retType;
|
|
40
|
+
let expressionType = "scalar";
|
|
41
|
+
const caseExpr = ["CASE "];
|
|
42
|
+
for (const clause of this.when) {
|
|
43
|
+
const whenExpr = clause.whenThis.getExpression(fs);
|
|
44
|
+
const thenExpr = clause.thenThis.getExpression(fs);
|
|
45
|
+
expressionType = (0, malloy_types_1.maxExpressionType)(expressionType, (0, malloy_types_1.maxExpressionType)(whenExpr.expressionType, thenExpr.expressionType));
|
|
46
|
+
if (thenExpr.dataType !== "null") {
|
|
47
|
+
if (retType && !fragtype_utils_1.FT.typeEq(retType, thenExpr)) {
|
|
48
|
+
this.log(`Mismatched THEN clause types, ${fragtype_utils_1.FT.inspect(retType, thenExpr)}`);
|
|
49
|
+
return (0, ast_utils_1.errorFor)("then typecheck");
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
retType = thenExpr;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
caseExpr.push("WHEN ", ...whenExpr.value, " THEN ", ...thenExpr.value);
|
|
56
|
+
}
|
|
57
|
+
if (this.elseClause) {
|
|
58
|
+
const elseExpr = this.elseClause.getExpression(fs);
|
|
59
|
+
expressionType = (0, malloy_types_1.maxExpressionType)(expressionType, elseExpr.expressionType);
|
|
60
|
+
caseExpr.push(" ELSE ", ...elseExpr.value);
|
|
61
|
+
if (elseExpr.dataType !== "null") {
|
|
62
|
+
if (retType && !fragtype_utils_1.FT.typeEq(retType, elseExpr)) {
|
|
63
|
+
this.log(`Mismatched ELSE clause type, ${fragtype_utils_1.FT.inspect(retType, elseExpr)}`);
|
|
64
|
+
return (0, ast_utils_1.errorFor)("else typecheck");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
retType = elseExpr;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (retType === undefined) {
|
|
72
|
+
this.log("case statement type not computable");
|
|
73
|
+
return (0, ast_utils_1.errorFor)("typeless case");
|
|
74
|
+
}
|
|
75
|
+
caseExpr.push(" END");
|
|
76
|
+
return {
|
|
77
|
+
dataType: retType.dataType,
|
|
78
|
+
expressionType,
|
|
79
|
+
value: caseExpr,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.ExprCase = ExprCase;
|
|
84
|
+
//# sourceMappingURL=expr-case.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { FieldSpace } from "../types/field-space";
|
|
3
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
4
|
+
export declare type CastType = "string" | "number" | "boolean" | "date" | "timestamp";
|
|
5
|
+
export declare function isCastType(t: string): t is CastType;
|
|
6
|
+
export declare class ExprCast extends ExpressionDef {
|
|
7
|
+
readonly expr: ExpressionDef;
|
|
8
|
+
readonly castType: CastType;
|
|
9
|
+
readonly safe: boolean;
|
|
10
|
+
elementType: string;
|
|
11
|
+
constructor(expr: ExpressionDef, castType: CastType, safe?: boolean);
|
|
12
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExprCast = exports.isCastType = void 0;
|
|
4
|
+
const time_utils_1 = require("../time-utils");
|
|
5
|
+
const expression_def_1 = require("../types/expression-def");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
function isCastType(t) {
|
|
8
|
+
return ["string", "number", "boolean", "date", "timestamp"].includes(t);
|
|
9
|
+
}
|
|
10
|
+
exports.isCastType = isCastType;
|
|
11
|
+
class ExprCast extends expression_def_1.ExpressionDef {
|
|
12
|
+
constructor(expr, castType, safe = false) {
|
|
13
|
+
super({ expr });
|
|
14
|
+
this.expr = expr;
|
|
15
|
+
this.castType = castType;
|
|
16
|
+
this.safe = safe;
|
|
17
|
+
this.elementType = "cast";
|
|
18
|
+
}
|
|
19
|
+
getExpression(fs) {
|
|
20
|
+
const expr = this.expr.getExpression(fs);
|
|
21
|
+
return {
|
|
22
|
+
dataType: this.castType,
|
|
23
|
+
expressionType: expr.expressionType,
|
|
24
|
+
value: (0, utils_1.compressExpr)((0, time_utils_1.castTo)(this.castType, expr.value, this.safe)),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ExprCast = ExprCast;
|
|
29
|
+
//# sourceMappingURL=expr-cast.js.map
|