@malloydata/malloy 0.0.22-dev230207144036 → 0.0.22-dev230207171614
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/connection_utils.d.ts +1 -0
- package/dist/connection_utils.js +66 -0
- package/dist/dialect/dialect.d.ts +66 -0
- package/dist/dialect/dialect.js +85 -0
- package/dist/dialect/dialect_map.d.ts +3 -0
- package/dist/dialect/dialect_map.js +45 -0
- package/dist/dialect/duckdb.d.ts +52 -0
- package/dist/dialect/duckdb.js +364 -0
- package/dist/dialect/index.d.ts +6 -0
- package/dist/dialect/index.js +37 -0
- package/dist/dialect/postgres.d.ts +52 -0
- package/dist/dialect/postgres.js +330 -0
- package/dist/dialect/standardsql.d.ts +49 -0
- package/dist/dialect/standardsql.js +381 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +59 -0
- 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-query.d.ts +14 -0
- package/dist/lang/ast/elements/define-query.js +56 -0
- package/dist/lang/ast/elements/define-source.d.ts +17 -0
- package/dist/lang/ast/elements/define-source.js +79 -0
- package/dist/lang/ast/elements/import-statement.d.ts +9 -0
- package/dist/lang/ast/elements/import-statement.js +78 -0
- package/dist/lang/ast/elements/pipeline-desc.d.ts +30 -0
- package/dist/lang/ast/elements/pipeline-desc.js +102 -0
- package/dist/lang/ast/elements/refined-source.d.ts +15 -0
- package/dist/lang/ast/elements/refined-source.js +121 -0
- package/dist/lang/ast/elements/source.d.ts +12 -0
- package/dist/lang/ast/elements/source.js +53 -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 +21 -0
- package/dist/lang/ast/executors/reduce-executor.js +149 -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-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 +58 -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 +75 -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 +12 -0
- package/dist/lang/ast/expressions/utils.js +87 -0
- package/dist/lang/ast/field-space/column-space-field.d.ts +9 -0
- package/dist/lang/ast/field-space/column-space-field.js +40 -0
- package/dist/lang/ast/field-space/dynamic-space.d.ts +22 -0
- package/dist/lang/ast/field-space/dynamic-space.js +140 -0
- package/dist/lang/ast/field-space/field-definition-value.d.ts +16 -0
- package/dist/lang/ast/field-space/field-definition-value.js +55 -0
- package/dist/lang/ast/field-space/index-field-space.d.ts +10 -0
- package/dist/lang/ast/field-space/index-field-space.js +57 -0
- package/dist/lang/ast/field-space/join-space-field.d.ts +8 -0
- package/dist/lang/ast/field-space/join-space-field.js +35 -0
- package/dist/lang/ast/field-space/project-field-space.d.ts +6 -0
- package/dist/lang/ast/field-space/project-field-space.js +51 -0
- package/dist/lang/ast/field-space/query-field-struct.d.ts +10 -0
- package/dist/lang/ast/field-space/query-field-struct.js +46 -0
- package/dist/lang/ast/field-space/query-space-field.d.ts +11 -0
- package/dist/lang/ast/field-space/query-space-field.js +37 -0
- package/dist/lang/ast/field-space/query-spaces.d.ts +50 -0
- package/dist/lang/ast/field-space/query-spaces.js +233 -0
- package/dist/lang/ast/field-space/reference-field.d.ts +11 -0
- package/dist/lang/ast/field-space/reference-field.js +45 -0
- package/dist/lang/ast/field-space/refined-space.d.ts +13 -0
- package/dist/lang/ast/field-space/refined-space.js +100 -0
- package/dist/lang/ast/field-space/rename-space-field.d.ts +11 -0
- package/dist/lang/ast/field-space/rename-space-field.js +50 -0
- package/dist/lang/ast/field-space/static-space.d.ts +29 -0
- package/dist/lang/ast/field-space/static-space.js +156 -0
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +11 -0
- package/dist/lang/ast/field-space/struct-space-field-base.js +40 -0
- package/dist/lang/ast/field-space/wild-space-field.d.ts +10 -0
- package/dist/lang/ast/field-space/wild-space-field.js +40 -0
- package/dist/lang/ast/fragtype-utils.d.ts +39 -0
- package/dist/lang/ast/fragtype-utils.js +100 -0
- package/dist/lang/ast/index.d.ts +90 -0
- package/dist/lang/ast/index.js +129 -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/nest-reference.d.ts +7 -0
- package/dist/lang/ast/query-properties/nest-reference.js +35 -0
- package/dist/lang/ast/query-properties/nest.d.ts +31 -0
- package/dist/lang/ast/query-properties/nest.js +133 -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 +124 -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/source-properties/field-list-edit.d.ts +8 -0
- package/dist/lang/ast/source-properties/field-list-edit.js +36 -0
- package/dist/lang/ast/source-properties/primary-key.d.ts +7 -0
- package/dist/lang/ast/source-properties/primary-key.js +35 -0
- package/dist/lang/ast/source-properties/renames.d.ts +11 -0
- package/dist/lang/ast/source-properties/renames.js +43 -0
- package/dist/lang/ast/source-properties/turtles.d.ts +5 -0
- package/dist/lang/ast/source-properties/turtles.js +33 -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-seed.d.ts +16 -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/struct-utils.d.ts +4 -0
- package/dist/lang/ast/struct-utils.js +48 -0
- package/dist/lang/ast/time-utils.d.ts +12 -0
- package/dist/lang/ast/time-utils.js +140 -0
- package/dist/lang/ast/types/comparison.d.ts +11 -0
- package/dist/lang/ast/types/comparison.js +41 -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/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/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-space.d.ts +24 -0
- package/dist/lang/ast/types/field-space.js +44 -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 +106 -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/source-property.d.ts +10 -0
- package/dist/lang/ast/types/source-property.js +43 -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 +20 -0
- package/dist/lang/ast/types/space-param.js +61 -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/ast/types/type-desc.d.ts +7 -0
- package/dist/lang/ast/types/type-desc.js +25 -0
- package/dist/lang/field-utils.d.ts +5 -0
- package/dist/lang/field-utils.js +43 -0
- package/dist/lang/index.d.ts +10 -0
- package/dist/lang/index.js +32 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +165 -0
- package/dist/lang/lib/Malloy/MalloyLexer.js +1232 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1947 -0
- package/dist/lang/lib/Malloy/MalloyParser.js +11909 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2022 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1274 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
- package/dist/lang/malloy-to-ast.d.ts +155 -0
- package/dist/lang/malloy-to-ast.js +990 -0
- package/dist/lang/parse-error-handler.d.ts +9 -0
- package/dist/lang/parse-error-handler.js +44 -0
- package/dist/lang/parse-log.d.ts +27 -0
- package/dist/lang/parse-log.js +51 -0
- package/dist/lang/parse-malloy.d.ts +182 -0
- package/dist/lang/parse-malloy.js +728 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +148 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +107 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +385 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +182 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +74 -0
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/find-external-references.js +61 -0
- package/dist/lang/reference-list.d.ts +10 -0
- package/dist/lang/reference-list.js +90 -0
- package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-help-context-walker.spec.js +55 -0
- package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-symbol-walker.spec.js +110 -0
- package/dist/lang/test/field-symbols.spec.d.ts +1 -0
- package/dist/lang/test/field-symbols.spec.js +184 -0
- package/dist/lang/test/parse.spec.d.ts +14 -0
- package/dist/lang/test/parse.spec.js +2135 -0
- package/dist/lang/test/test-translator.d.ts +41 -0
- package/dist/lang/test/test-translator.js +344 -0
- package/dist/lang/translate-response.d.ts +59 -0
- package/dist/lang/translate-response.js +30 -0
- package/dist/lang/zone.d.ts +57 -0
- package/dist/lang/zone.js +107 -0
- package/dist/malloy.d.ts +1146 -0
- package/dist/malloy.js +2413 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +45 -0
- package/dist/model/malloy_query.d.ts +351 -0
- package/dist/model/malloy_query.js +3174 -0
- package/dist/model/malloy_types.d.ts +551 -0
- package/dist/model/malloy_types.js +378 -0
- package/dist/model/sql_block.d.ts +7 -0
- package/dist/model/sql_block.js +56 -0
- package/dist/model/utils.d.ts +22 -0
- package/dist/model/utils.js +102 -0
- package/dist/run_sql_options.d.ts +3 -0
- package/dist/run_sql_options.js +25 -0
- package/dist/runtime_types.d.ts +105 -0
- package/dist/runtime_types.js +25 -0
- package/package.json +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
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.isExploreField = void 0;
|
|
26
|
+
const renames_1 = require("../source-properties/renames");
|
|
27
|
+
const field_decl_1 = require("./field-decl");
|
|
28
|
+
function isExploreField(f) {
|
|
29
|
+
return (0, field_decl_1.isFieldDecl)(f) || f instanceof renames_1.RenameField;
|
|
30
|
+
}
|
|
31
|
+
exports.isExploreField = isExploreField;
|
|
32
|
+
//# sourceMappingURL=explore-field.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
//# sourceMappingURL=expr-result.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
//# sourceMappingURL=expr-value.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TimestampUnit } from "../../../model/malloy_types";
|
|
2
|
+
import { ExprValue } from "./expr-value";
|
|
3
|
+
import { FieldSpace } from "./field-space";
|
|
4
|
+
import { MalloyElement } from "./malloy-element";
|
|
5
|
+
/**
|
|
6
|
+
* Root node for any element in an expression. These essentially
|
|
7
|
+
* create a sub-tree in the larger AST. Expression nodes know
|
|
8
|
+
* how to write themselves as SQL (or rather, generate the
|
|
9
|
+
* template for SQL required by the query writer)
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class ExpressionDef extends MalloyElement {
|
|
12
|
+
abstract elementType: string;
|
|
13
|
+
granular(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the "translation" or template for SQL generation. When asking
|
|
16
|
+
* for a tranlsation you may pass the types you can accept, allowing
|
|
17
|
+
* the translation code a chance to convert to match your expectations
|
|
18
|
+
* @param space Namespace for looking up field references
|
|
19
|
+
*/
|
|
20
|
+
abstract getExpression(fs: FieldSpace): ExprValue;
|
|
21
|
+
legalChildTypes: import("./type-desc").TypeDesc[];
|
|
22
|
+
/**
|
|
23
|
+
* Some operators want to give the right hand value a chance to
|
|
24
|
+
* rewrite itself. This requests a translation for a rewrite,
|
|
25
|
+
* or returns undefined if that request should be denied.
|
|
26
|
+
* @param fs FieldSpace
|
|
27
|
+
* @returns Translated expression or undefined
|
|
28
|
+
*/
|
|
29
|
+
requestExpression(fs: FieldSpace): ExprValue | undefined;
|
|
30
|
+
defaultFieldName(): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check an expression for type compatibility
|
|
33
|
+
* @param _eNode currently unused, will be used to get error location
|
|
34
|
+
* @param eVal ...list of expressions that must match legalChildTypes
|
|
35
|
+
*/
|
|
36
|
+
typeCheck(eNode: ExpressionDef, eVal: ExprValue): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* This is the operation which makes partial comparison and value trees work
|
|
39
|
+
* The default implemention merely constructs LEFT OP RIGHT, but specialized
|
|
40
|
+
* nodes like alternation trees or or partial comparison can control how
|
|
41
|
+
* the appplication gets generated
|
|
42
|
+
* @param fs The symbol table
|
|
43
|
+
* @param op The operator being applied
|
|
44
|
+
* @param expr The "other" (besdies 'this') value
|
|
45
|
+
* @returns The translated expression
|
|
46
|
+
*/
|
|
47
|
+
apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
|
|
48
|
+
}
|
|
49
|
+
export declare class ExprDuration extends ExpressionDef {
|
|
50
|
+
readonly n: ExpressionDef;
|
|
51
|
+
readonly timeframe: TimestampUnit;
|
|
52
|
+
elementType: string;
|
|
53
|
+
legalChildTypes: import("./type-desc").TypeDesc[];
|
|
54
|
+
constructor(n: ExpressionDef, timeframe: TimestampUnit);
|
|
55
|
+
apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
|
|
56
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* All of the magic of malloy expressions eventually flows to here,
|
|
60
|
+
* where an operator is applied to two values. Depending on the
|
|
61
|
+
* operator and value types this may involve transformations of
|
|
62
|
+
* the values or even the operator.
|
|
63
|
+
* @param fs FieldSpace for the symbols
|
|
64
|
+
* @param left Left value
|
|
65
|
+
* @param op The operator
|
|
66
|
+
* @param right Right Value
|
|
67
|
+
* @returns ExprValue of the expression
|
|
68
|
+
*/
|
|
69
|
+
export declare function applyBinary(fs: FieldSpace, left: ExpressionDef, op: string, right: ExpressionDef): ExprValue;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyBinary = exports.ExprDuration = exports.ExpressionDef = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2023 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
* a copy of this software and associated documentation files
|
|
9
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
10
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
11
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
12
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be
|
|
16
|
+
* included in all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
+
const ast_utils_1 = require("../ast-utils");
|
|
28
|
+
const utils_1 = require("../expressions/utils");
|
|
29
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
30
|
+
const time_utils_1 = require("../time-utils");
|
|
31
|
+
const comparison_1 = require("./comparison");
|
|
32
|
+
const equality_1 = require("./equality");
|
|
33
|
+
const granular_result_1 = require("./granular-result");
|
|
34
|
+
const malloy_element_1 = require("./malloy-element");
|
|
35
|
+
class TypeMismatch extends Error {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Root node for any element in an expression. These essentially
|
|
39
|
+
* create a sub-tree in the larger AST. Expression nodes know
|
|
40
|
+
* how to write themselves as SQL (or rather, generate the
|
|
41
|
+
* template for SQL required by the query writer)
|
|
42
|
+
*/
|
|
43
|
+
class ExpressionDef extends malloy_element_1.MalloyElement {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.legalChildTypes = fragtype_utils_1.FT.anyAtomicT;
|
|
47
|
+
}
|
|
48
|
+
granular() {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Some operators want to give the right hand value a chance to
|
|
53
|
+
* rewrite itself. This requests a translation for a rewrite,
|
|
54
|
+
* or returns undefined if that request should be denied.
|
|
55
|
+
* @param fs FieldSpace
|
|
56
|
+
* @returns Translated expression or undefined
|
|
57
|
+
*/
|
|
58
|
+
requestExpression(fs) {
|
|
59
|
+
return this.getExpression(fs);
|
|
60
|
+
}
|
|
61
|
+
defaultFieldName() {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check an expression for type compatibility
|
|
66
|
+
* @param _eNode currently unused, will be used to get error location
|
|
67
|
+
* @param eVal ...list of expressions that must match legalChildTypes
|
|
68
|
+
*/
|
|
69
|
+
typeCheck(eNode, eVal) {
|
|
70
|
+
if (!fragtype_utils_1.FT.in(eVal, this.legalChildTypes)) {
|
|
71
|
+
eNode.log(`'${this.elementType}' Can't use type ${fragtype_utils_1.FT.inspect(eVal)}`);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* This is the operation which makes partial comparison and value trees work
|
|
78
|
+
* The default implemention merely constructs LEFT OP RIGHT, but specialized
|
|
79
|
+
* nodes like alternation trees or or partial comparison can control how
|
|
80
|
+
* the appplication gets generated
|
|
81
|
+
* @param fs The symbol table
|
|
82
|
+
* @param op The operator being applied
|
|
83
|
+
* @param expr The "other" (besdies 'this') value
|
|
84
|
+
* @returns The translated expression
|
|
85
|
+
*/
|
|
86
|
+
apply(fs, op, left) {
|
|
87
|
+
return applyBinary(fs, left, op, this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ExpressionDef = ExpressionDef;
|
|
91
|
+
class ExprDuration extends ExpressionDef {
|
|
92
|
+
constructor(n, timeframe) {
|
|
93
|
+
super({ n });
|
|
94
|
+
this.n = n;
|
|
95
|
+
this.timeframe = timeframe;
|
|
96
|
+
this.elementType = "duration";
|
|
97
|
+
this.legalChildTypes = [fragtype_utils_1.FT.timestampT, fragtype_utils_1.FT.dateT];
|
|
98
|
+
}
|
|
99
|
+
apply(fs, op, left) {
|
|
100
|
+
const lhs = left.getExpression(fs);
|
|
101
|
+
this.typeCheck(this, lhs);
|
|
102
|
+
if ((0, malloy_types_1.isTimeFieldType)(lhs.dataType) && (op === "+" || op === "-")) {
|
|
103
|
+
const num = this.n.getExpression(fs);
|
|
104
|
+
if (!fragtype_utils_1.FT.typeEq(num, fragtype_utils_1.FT.numberT)) {
|
|
105
|
+
this.log(`Duration units needs number not '${num.dataType}`);
|
|
106
|
+
return (0, ast_utils_1.errorFor)("illegal unit expression");
|
|
107
|
+
}
|
|
108
|
+
let resultGranularity;
|
|
109
|
+
// Only allow the output of this to be granular if the
|
|
110
|
+
// granularities match, this is still an area where
|
|
111
|
+
// more thought is required.
|
|
112
|
+
if ((0, granular_result_1.isGranularResult)(lhs) && lhs.timeframe == this.timeframe) {
|
|
113
|
+
resultGranularity = lhs.timeframe;
|
|
114
|
+
}
|
|
115
|
+
if (lhs.dataType === "timestamp") {
|
|
116
|
+
const result = (0, time_utils_1.timeOffset)("timestamp", lhs.value, op, num.value, this.timeframe);
|
|
117
|
+
return (0, time_utils_1.timeResult)({
|
|
118
|
+
dataType: "timestamp",
|
|
119
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
|
|
120
|
+
value: result,
|
|
121
|
+
}, resultGranularity);
|
|
122
|
+
}
|
|
123
|
+
return (0, time_utils_1.timeResult)({
|
|
124
|
+
dataType: "date",
|
|
125
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
|
|
126
|
+
value: (0, time_utils_1.timeOffset)("date", lhs.value, op, num.value, this.timeframe),
|
|
127
|
+
}, resultGranularity);
|
|
128
|
+
}
|
|
129
|
+
return super.apply(fs, op, left);
|
|
130
|
+
}
|
|
131
|
+
getExpression(_fs) {
|
|
132
|
+
return {
|
|
133
|
+
dataType: "duration",
|
|
134
|
+
expressionType: "scalar",
|
|
135
|
+
value: ["__ERROR_DURATION_IS_NOT_A_VALUE__"],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.ExprDuration = ExprDuration;
|
|
140
|
+
function timeCompare(lhs, op, rhs) {
|
|
141
|
+
if ((0, malloy_types_1.isTimeFieldType)(lhs.dataType) && (0, malloy_types_1.isTimeFieldType)(rhs.dataType)) {
|
|
142
|
+
if (lhs.dataType !== rhs.dataType) {
|
|
143
|
+
let lval = lhs.value;
|
|
144
|
+
let rval = rhs.value;
|
|
145
|
+
if (lhs.dataType === "timestamp") {
|
|
146
|
+
lval = (0, time_utils_1.castTimestampToDate)(lval);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
rval = (0, time_utils_1.castTimestampToDate)(rval);
|
|
150
|
+
}
|
|
151
|
+
return (0, utils_1.compose)(lval, op, rval);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
function regexEqual(left, right) {
|
|
157
|
+
if (left.dataType === "string") {
|
|
158
|
+
if (right.dataType === "regular expression") {
|
|
159
|
+
return [
|
|
160
|
+
{
|
|
161
|
+
type: "dialect",
|
|
162
|
+
function: "regexpMatch",
|
|
163
|
+
expr: left.value,
|
|
164
|
+
regexp: right.value[0].replace(/^r'/, "'"),
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (right.dataType === "string") {
|
|
170
|
+
if (left.dataType === "regular expression") {
|
|
171
|
+
return [
|
|
172
|
+
{
|
|
173
|
+
type: "dialect",
|
|
174
|
+
function: "regexpMatch",
|
|
175
|
+
expr: right.value,
|
|
176
|
+
regexp: left.value[0].replace(/^r'/, "'"),
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
function nullCompare(left, op, right) {
|
|
184
|
+
const not = op === "!=" || op === "!~";
|
|
185
|
+
if (left.dataType === "null" || right.dataType === "null") {
|
|
186
|
+
const maybeNot = not ? " NOT" : "";
|
|
187
|
+
if (left.dataType !== "null") {
|
|
188
|
+
return [...left.value, ` IS${maybeNot} NULL`];
|
|
189
|
+
}
|
|
190
|
+
if (right.dataType !== "null") {
|
|
191
|
+
return [...right.value, `IS${maybeNot} NULL`];
|
|
192
|
+
}
|
|
193
|
+
return [not ? "false" : "true"];
|
|
194
|
+
}
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
function equality(fs, left, op, right) {
|
|
198
|
+
const lhs = left.getExpression(fs);
|
|
199
|
+
const rhs = right.getExpression(fs);
|
|
200
|
+
let value = timeCompare(lhs, op, rhs) || (0, utils_1.compose)(lhs.value, op, rhs.value);
|
|
201
|
+
if (lhs.dataType != "unknown" && rhs.dataType != "unknown") {
|
|
202
|
+
switch (op) {
|
|
203
|
+
case "~":
|
|
204
|
+
case "!~": {
|
|
205
|
+
if (lhs.dataType === "string" && rhs.dataType === "string") {
|
|
206
|
+
value = (0, utils_1.compose)(lhs.value, "LIKE", rhs.value);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const regexCmp = regexEqual(lhs, rhs);
|
|
210
|
+
if (regexCmp === undefined) {
|
|
211
|
+
throw new TypeMismatch("Incompatible types for match('~') operator");
|
|
212
|
+
}
|
|
213
|
+
value = regexCmp;
|
|
214
|
+
}
|
|
215
|
+
value = (0, utils_1.nullsafeNot)(value, op);
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case "=":
|
|
219
|
+
case "!=": {
|
|
220
|
+
const nullCmp = nullCompare(lhs, op, rhs);
|
|
221
|
+
if (nullCmp) {
|
|
222
|
+
value = nullCmp;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
value = (0, utils_1.nullsafeNot)(regexEqual(lhs, rhs) || (0, utils_1.compose)(lhs.value, "=", rhs.value), op);
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
dataType: "boolean",
|
|
233
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, rhs.expressionType),
|
|
234
|
+
value,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function compare(fs, left, op, right) {
|
|
238
|
+
const lhs = left.getExpression(fs);
|
|
239
|
+
const rhs = right.getExpression(fs);
|
|
240
|
+
const expressionType = (0, malloy_types_1.maxExpressionType)(lhs.expressionType, rhs.expressionType);
|
|
241
|
+
const value = timeCompare(lhs, op, rhs) || (0, utils_1.compose)(lhs.value, op, rhs.value);
|
|
242
|
+
return {
|
|
243
|
+
dataType: "boolean",
|
|
244
|
+
expressionType,
|
|
245
|
+
value: value,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function oneOf(op, ...operators) {
|
|
249
|
+
return operators.includes(op);
|
|
250
|
+
}
|
|
251
|
+
function allAre(oneType, ...values) {
|
|
252
|
+
for (const v of values) {
|
|
253
|
+
if (v.dataType !== oneType) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
function numeric(fs, left, op, right) {
|
|
260
|
+
const lhs = left.getExpression(fs);
|
|
261
|
+
const rhs = right.getExpression(fs);
|
|
262
|
+
const expressionType = (0, malloy_types_1.maxExpressionType)(lhs.expressionType, rhs.expressionType);
|
|
263
|
+
if (allAre("number", lhs, rhs)) {
|
|
264
|
+
return {
|
|
265
|
+
dataType: "number",
|
|
266
|
+
expressionType,
|
|
267
|
+
value: (0, utils_1.compose)(lhs.value, op, rhs.value),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
left.log(`Non numeric('${lhs.dataType},${rhs.dataType}') value with '${op}'`);
|
|
271
|
+
return (0, ast_utils_1.errorFor)("numbers required");
|
|
272
|
+
}
|
|
273
|
+
function delta(fs, left, op, right) {
|
|
274
|
+
const lhs = left.getExpression(fs);
|
|
275
|
+
const rhs = right.getExpression(fs);
|
|
276
|
+
if ((0, malloy_types_1.isTimeFieldType)(lhs.dataType)) {
|
|
277
|
+
let duration = right;
|
|
278
|
+
if (rhs.dataType !== "duration") {
|
|
279
|
+
if ((0, granular_result_1.isGranularResult)(lhs)) {
|
|
280
|
+
duration = new ExprDuration(right, lhs.timeframe);
|
|
281
|
+
}
|
|
282
|
+
else if (lhs.dataType === "date") {
|
|
283
|
+
duration = new ExprDuration(right, "day");
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
left.log(`Can not offset time by '${rhs.dataType}'`);
|
|
287
|
+
return (0, ast_utils_1.errorFor)(`time plus ${rhs.dataType}`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return duration.apply(fs, op, left);
|
|
291
|
+
}
|
|
292
|
+
return numeric(fs, left, op, right);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* All of the magic of malloy expressions eventually flows to here,
|
|
296
|
+
* where an operator is applied to two values. Depending on the
|
|
297
|
+
* operator and value types this may involve transformations of
|
|
298
|
+
* the values or even the operator.
|
|
299
|
+
* @param fs FieldSpace for the symbols
|
|
300
|
+
* @param left Left value
|
|
301
|
+
* @param op The operator
|
|
302
|
+
* @param right Right Value
|
|
303
|
+
* @returns ExprValue of the expression
|
|
304
|
+
*/
|
|
305
|
+
function applyBinary(fs, left, op, right) {
|
|
306
|
+
if ((0, equality_1.isEquality)(op)) {
|
|
307
|
+
return equality(fs, left, op, right);
|
|
308
|
+
}
|
|
309
|
+
if ((0, comparison_1.isComparison)(op)) {
|
|
310
|
+
return compare(fs, left, op, right);
|
|
311
|
+
}
|
|
312
|
+
if (oneOf(op, "+", "-")) {
|
|
313
|
+
return delta(fs, left, op, right);
|
|
314
|
+
}
|
|
315
|
+
if (oneOf(op, "*", "%")) {
|
|
316
|
+
return numeric(fs, left, op, right);
|
|
317
|
+
}
|
|
318
|
+
if (oneOf(op, "/")) {
|
|
319
|
+
const num = left.getExpression(fs);
|
|
320
|
+
const denom = right.getExpression(fs);
|
|
321
|
+
if (num.dataType != "number") {
|
|
322
|
+
left.log("Numerator for division must be a number");
|
|
323
|
+
}
|
|
324
|
+
else if (denom.dataType != "number") {
|
|
325
|
+
right.log("Denominator for division must be a number");
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
const div = {
|
|
329
|
+
type: "dialect",
|
|
330
|
+
function: "div",
|
|
331
|
+
numerator: num.value,
|
|
332
|
+
denominator: denom.value,
|
|
333
|
+
};
|
|
334
|
+
return {
|
|
335
|
+
dataType: "number",
|
|
336
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(num.expressionType, denom.expressionType),
|
|
337
|
+
value: [div],
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return (0, ast_utils_1.errorFor)("divide type mismatch");
|
|
341
|
+
}
|
|
342
|
+
left.log(`Canot use ${op} operator here`);
|
|
343
|
+
return (0, ast_utils_1.errorFor)("applybinary bad operator");
|
|
344
|
+
}
|
|
345
|
+
exports.applyBinary = applyBinary;
|
|
346
|
+
//# sourceMappingURL=expression-def.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FieldDeclaration } from "../query-items/field-declaration";
|
|
2
|
+
import { FieldReferenceElement } from "../query-items/field-references";
|
|
3
|
+
import { MalloyElement } from "./malloy-element";
|
|
4
|
+
export declare type FieldCollectionMember = FieldReferenceElement | FieldDeclaration;
|
|
5
|
+
export declare function isFieldCollectionMember(el: MalloyElement): el is FieldCollectionMember;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFieldCollectionMember = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2023 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
* a copy of this software and associated documentation files
|
|
9
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
10
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
11
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
12
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be
|
|
16
|
+
* included in all copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
const field_declaration_1 = require("../query-items/field-declaration");
|
|
27
|
+
const field_references_1 = require("../query-items/field-references");
|
|
28
|
+
function isFieldCollectionMember(el) {
|
|
29
|
+
return (el instanceof field_references_1.FieldReference ||
|
|
30
|
+
el instanceof field_references_1.WildcardFieldReference ||
|
|
31
|
+
el instanceof field_declaration_1.FieldDeclaration);
|
|
32
|
+
}
|
|
33
|
+
exports.isFieldCollectionMember = isFieldCollectionMember;
|
|
34
|
+
//# sourceMappingURL=field-collection-member.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TurtleDecl } from "../query-properties/nest";
|
|
2
|
+
import { Turtles } from "../source-properties/turtles";
|
|
3
|
+
import { FieldDeclaration } from "../query-items/field-declaration";
|
|
4
|
+
import { Join } from "../query-properties/joins";
|
|
5
|
+
import { MalloyElement } from "./malloy-element";
|
|
6
|
+
export declare type FieldDecl = FieldDeclaration | Join | TurtleDecl | Turtles;
|
|
7
|
+
export declare function isFieldDecl(f: MalloyElement): f is FieldDecl;
|
|
@@ -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.isFieldDecl = void 0;
|
|
26
|
+
const nest_1 = require("../query-properties/nest");
|
|
27
|
+
const turtles_1 = require("../source-properties/turtles");
|
|
28
|
+
const field_declaration_1 = require("../query-items/field-declaration");
|
|
29
|
+
const joins_1 = require("../query-properties/joins");
|
|
30
|
+
function isFieldDecl(f) {
|
|
31
|
+
return (f instanceof field_declaration_1.FieldDeclaration ||
|
|
32
|
+
f instanceof joins_1.Join ||
|
|
33
|
+
f instanceof nest_1.TurtleDecl ||
|
|
34
|
+
f instanceof turtles_1.Turtles);
|
|
35
|
+
}
|
|
36
|
+
exports.isFieldDecl = isFieldDecl;
|
|
37
|
+
//# sourceMappingURL=field-decl.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dialect } from "../../../dialect/dialect";
|
|
2
|
+
import { StructDef } from "../../../model/malloy_types";
|
|
3
|
+
import { LookupResult } from "./lookup-result";
|
|
4
|
+
import { MalloyElement } from "./malloy-element";
|
|
5
|
+
/**
|
|
6
|
+
* A FieldSpace is a hierarchy of namespaces, where the leaf nodes
|
|
7
|
+
* are fields. A FieldSpace can lookup fields, and generate a StructDef
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldSpace {
|
|
10
|
+
type: "fieldSpace";
|
|
11
|
+
structDef(): StructDef;
|
|
12
|
+
emptyStructDef(): StructDef;
|
|
13
|
+
lookup(symbol: FieldName[]): LookupResult;
|
|
14
|
+
dialectObj(): Dialect | undefined;
|
|
15
|
+
whenComplete: (step: () => void) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare class FieldName extends MalloyElement {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
elementType: string;
|
|
20
|
+
constructor(name: string);
|
|
21
|
+
get refString(): string;
|
|
22
|
+
toString(): string;
|
|
23
|
+
getField(fs: FieldSpace): LookupResult;
|
|
24
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.FieldName = void 0;
|
|
26
|
+
const malloy_element_1 = require("./malloy-element");
|
|
27
|
+
class FieldName extends malloy_element_1.MalloyElement {
|
|
28
|
+
constructor(name) {
|
|
29
|
+
super();
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.elementType = "fieldName";
|
|
32
|
+
}
|
|
33
|
+
get refString() {
|
|
34
|
+
return this.name;
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
return this.refString;
|
|
38
|
+
}
|
|
39
|
+
getField(fs) {
|
|
40
|
+
return fs.lookup([this]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.FieldName = FieldName;
|
|
44
|
+
//# sourceMappingURL=field-space.js.map
|