@malloydata/malloy 0.0.22-dev230207144036 → 0.0.22-dev230207180844
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,381 @@
|
|
|
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.StandardSQLDialect = void 0;
|
|
26
|
+
const utils_1 = require("../model/utils");
|
|
27
|
+
const malloy_types_1 = require("../model/malloy_types");
|
|
28
|
+
const dialect_1 = require("./dialect");
|
|
29
|
+
const castMap = {
|
|
30
|
+
number: "float64",
|
|
31
|
+
};
|
|
32
|
+
// These are the units that "TIMESTAMP_ADD" accepts
|
|
33
|
+
const timestampAddUnits = [
|
|
34
|
+
"microsecond",
|
|
35
|
+
"millisecond",
|
|
36
|
+
"second",
|
|
37
|
+
"minute",
|
|
38
|
+
"hour",
|
|
39
|
+
"day",
|
|
40
|
+
];
|
|
41
|
+
const extractMap = {
|
|
42
|
+
day_of_week: "dayofweek",
|
|
43
|
+
day_of_year: "dayofyear",
|
|
44
|
+
};
|
|
45
|
+
class StandardSQLDialect extends dialect_1.Dialect {
|
|
46
|
+
constructor() {
|
|
47
|
+
super(...arguments);
|
|
48
|
+
this.name = "standardsql";
|
|
49
|
+
this.defaultNumberType = "FLOAT64";
|
|
50
|
+
this.udfPrefix = "__udf";
|
|
51
|
+
this.hasFinalStage = false;
|
|
52
|
+
this.stringTypeName = "STRING";
|
|
53
|
+
this.divisionIsInteger = false;
|
|
54
|
+
this.supportsSumDistinctFunction = false;
|
|
55
|
+
this.unnestWithNumbers = false;
|
|
56
|
+
this.defaultSampling = { enable: false };
|
|
57
|
+
this.supportUnnestArrayAgg = false;
|
|
58
|
+
this.supportsCTEinCoorelatedSubQueries = false;
|
|
59
|
+
this.dontUnionIndex = true; // bigquery can't use a sample table more than once in a query.
|
|
60
|
+
this.supportsQualify = true;
|
|
61
|
+
// I think we want an optional list of parameters types that we force a cast to.
|
|
62
|
+
this.functionInfo = {
|
|
63
|
+
timestamp_seconds: {
|
|
64
|
+
returnType: "timestamp",
|
|
65
|
+
},
|
|
66
|
+
concat: { returnType: "string" },
|
|
67
|
+
};
|
|
68
|
+
this.keywords = `
|
|
69
|
+
ALL
|
|
70
|
+
AND
|
|
71
|
+
ANY
|
|
72
|
+
ARRAY
|
|
73
|
+
AS
|
|
74
|
+
ASC
|
|
75
|
+
ASSERT_ROWS_MODIFIED
|
|
76
|
+
AT
|
|
77
|
+
BETWEEN
|
|
78
|
+
BY
|
|
79
|
+
CASE
|
|
80
|
+
CAST
|
|
81
|
+
COLLATE
|
|
82
|
+
CONTAINS
|
|
83
|
+
CREATE
|
|
84
|
+
CROSS
|
|
85
|
+
CUBE
|
|
86
|
+
CURRENT
|
|
87
|
+
DEFAULT
|
|
88
|
+
DEFINE
|
|
89
|
+
DESC
|
|
90
|
+
DISTINCT
|
|
91
|
+
ELSE
|
|
92
|
+
END
|
|
93
|
+
ENUM
|
|
94
|
+
ESCAPE
|
|
95
|
+
EXCEPT
|
|
96
|
+
EXCLUDE
|
|
97
|
+
EXISTS
|
|
98
|
+
EXTRACT
|
|
99
|
+
FALSE
|
|
100
|
+
FETCH
|
|
101
|
+
FOLLOWING
|
|
102
|
+
FOR
|
|
103
|
+
FROM
|
|
104
|
+
FULL
|
|
105
|
+
GROUP
|
|
106
|
+
GROUPING
|
|
107
|
+
GROUPS
|
|
108
|
+
HASH
|
|
109
|
+
HAVING
|
|
110
|
+
IF
|
|
111
|
+
IGNORE
|
|
112
|
+
IN
|
|
113
|
+
INNER
|
|
114
|
+
INTERSECT
|
|
115
|
+
INTERVAL
|
|
116
|
+
INTO
|
|
117
|
+
IS
|
|
118
|
+
JOIN
|
|
119
|
+
LATERAL
|
|
120
|
+
LEFT
|
|
121
|
+
LIKE
|
|
122
|
+
LIMIT
|
|
123
|
+
LOOKUP
|
|
124
|
+
MERGE
|
|
125
|
+
NATURAL
|
|
126
|
+
NEW
|
|
127
|
+
NO
|
|
128
|
+
NOT
|
|
129
|
+
NULL
|
|
130
|
+
NULLS
|
|
131
|
+
OF
|
|
132
|
+
ON
|
|
133
|
+
OR
|
|
134
|
+
ORDER
|
|
135
|
+
OUTER
|
|
136
|
+
OVER
|
|
137
|
+
PARTITION
|
|
138
|
+
PRECEDING
|
|
139
|
+
PROTO
|
|
140
|
+
RANGE
|
|
141
|
+
RECURSIVE
|
|
142
|
+
RESPECT
|
|
143
|
+
RIGHT
|
|
144
|
+
ROLLUP
|
|
145
|
+
ROWS
|
|
146
|
+
SELECT
|
|
147
|
+
SET
|
|
148
|
+
SOME
|
|
149
|
+
STRUCT
|
|
150
|
+
TABLESAMPLE
|
|
151
|
+
THEN
|
|
152
|
+
TO
|
|
153
|
+
TREAT
|
|
154
|
+
TRUE
|
|
155
|
+
UNBOUNDED
|
|
156
|
+
UNION
|
|
157
|
+
UNNEST
|
|
158
|
+
USING
|
|
159
|
+
WHEN
|
|
160
|
+
WHERE
|
|
161
|
+
WINDOW
|
|
162
|
+
WITH
|
|
163
|
+
WITHIN`.split(/\s/);
|
|
164
|
+
}
|
|
165
|
+
quoteTablePath(tablePath) {
|
|
166
|
+
return `\`${tablePath}\``;
|
|
167
|
+
}
|
|
168
|
+
sqlGroupSetTable(groupSetCount) {
|
|
169
|
+
return `CROSS JOIN (SELECT row_number() OVER() -1 group_set FROM UNNEST(GENERATE_ARRAY(0,${groupSetCount},1)))`;
|
|
170
|
+
}
|
|
171
|
+
sqlAnyValue(groupSet, fieldName) {
|
|
172
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN ${fieldName} END)`;
|
|
173
|
+
}
|
|
174
|
+
// can array agg or any_value a struct...
|
|
175
|
+
sqlAggregateTurtle(groupSet, fieldList, orderBy, limit) {
|
|
176
|
+
let tail = "";
|
|
177
|
+
if (limit !== undefined) {
|
|
178
|
+
tail += ` LIMIT ${limit}`;
|
|
179
|
+
}
|
|
180
|
+
const fields = fieldList
|
|
181
|
+
.map((f) => `\n ${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
182
|
+
.join(", ");
|
|
183
|
+
return `ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}\n ) END IGNORE NULLS ${orderBy} ${tail})`;
|
|
184
|
+
}
|
|
185
|
+
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
186
|
+
const fields = fieldList
|
|
187
|
+
.map((f) => `${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
188
|
+
.join(", ");
|
|
189
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}))`;
|
|
190
|
+
}
|
|
191
|
+
sqlAnyValueLastTurtle(name, groupSet, sqlName) {
|
|
192
|
+
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN ${name}__${groupSet} END) as ${sqlName}`;
|
|
193
|
+
}
|
|
194
|
+
sqlCoaleseMeasuresInline(groupSet, fieldList) {
|
|
195
|
+
const fields = fieldList
|
|
196
|
+
.map((f) => `${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
197
|
+
.join(", ");
|
|
198
|
+
const nullValues = fieldList
|
|
199
|
+
.map((f) => `NULL as ${f.sqlOutputName}`)
|
|
200
|
+
.join(", ");
|
|
201
|
+
return `COALESCE(ANY_VALUE(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}) END), STRUCT(${nullValues}))`;
|
|
202
|
+
}
|
|
203
|
+
//
|
|
204
|
+
// this code used to be:
|
|
205
|
+
//
|
|
206
|
+
// from += `JOIN UNNEST(GENERATE_ARRAY(0,${this.maxGroupSet},1)) as group_set\n`;
|
|
207
|
+
//
|
|
208
|
+
// BigQuery will allocate more resources if we use a CROSS JOIN so we do that instead.
|
|
209
|
+
//
|
|
210
|
+
sqlUnnestAlias(source, alias, fieldList, needDistinctKey, isArray) {
|
|
211
|
+
if (isArray) {
|
|
212
|
+
if (needDistinctKey) {
|
|
213
|
+
return `LEFT JOIN UNNEST(ARRAY(( SELECT AS STRUCT row_number() over() as __row_id, value FROM UNNEST(${source}) value))) as ${alias}`;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return `LEFT JOIN UNNEST(ARRAY((SELECT AS STRUCT value FROM unnest(${source}) value))) as ${alias}`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (needDistinctKey) {
|
|
220
|
+
return `LEFT JOIN UNNEST(ARRAY(( SELECT AS STRUCT row_number() over() as __row_id, * FROM UNNEST(${source})))) as ${alias}`;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
return `LEFT JOIN UNNEST(${source}) as ${alias}`;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
sqlSumDistinctHashedKey(sqlDistinctKey) {
|
|
227
|
+
sqlDistinctKey = `CAST(${sqlDistinctKey} AS STRING)`;
|
|
228
|
+
const upperPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 1, 15)) as int64) as numeric) * 4294967296`;
|
|
229
|
+
const lowerPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 16, 8)) as int64) as numeric)`;
|
|
230
|
+
// See the comment below on `sql_sum_distinct` for why we multiply by this decimal
|
|
231
|
+
const precisionShiftMultiplier = "0.000000001";
|
|
232
|
+
return `(${upperPart} + ${lowerPart}) * ${precisionShiftMultiplier}`;
|
|
233
|
+
}
|
|
234
|
+
sqlGenerateUUID() {
|
|
235
|
+
return `GENERATE_UUID()`;
|
|
236
|
+
}
|
|
237
|
+
sqlFieldReference(alias, fieldName, _fieldType, _isNested, _isArray) {
|
|
238
|
+
return `${alias}.${fieldName}`;
|
|
239
|
+
}
|
|
240
|
+
sqlUnnestPipelineHead(isSingleton, sourceSQLExpression) {
|
|
241
|
+
let p = sourceSQLExpression;
|
|
242
|
+
if (isSingleton) {
|
|
243
|
+
p = `[${p}]`;
|
|
244
|
+
}
|
|
245
|
+
return `UNNEST(${p})`;
|
|
246
|
+
}
|
|
247
|
+
sqlCreateFunction(id, funcText) {
|
|
248
|
+
return `CREATE TEMPORARY FUNCTION ${id}(__param ANY TYPE) AS ((\n${(0, utils_1.indent)(funcText)}));\n`;
|
|
249
|
+
}
|
|
250
|
+
sqlCreateTableAsSelect(tableName, sql) {
|
|
251
|
+
return `
|
|
252
|
+
CREATE TABLE IF NOT EXISTS \`${tableName}\`
|
|
253
|
+
OPTIONS (
|
|
254
|
+
expiration_timestamp=TIMESTAMP_ADD(current_timestamp(), INTERVAL 1 hour)
|
|
255
|
+
)
|
|
256
|
+
AS (
|
|
257
|
+
${(0, utils_1.indent)(sql)}
|
|
258
|
+
);
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
sqlCreateFunctionCombineLastStage(lastStageName) {
|
|
262
|
+
return `SELECT ARRAY((SELECT AS STRUCT * FROM ${lastStageName}))\n`;
|
|
263
|
+
}
|
|
264
|
+
sqlSelectAliasAsStruct(alias) {
|
|
265
|
+
return `(SELECT AS STRUCT ${alias}.*)`;
|
|
266
|
+
}
|
|
267
|
+
sqlMaybeQuoteIdentifier(identifier) {
|
|
268
|
+
return this.keywords.indexOf(identifier.toUpperCase()) > 0
|
|
269
|
+
? "`" + identifier + "`"
|
|
270
|
+
: identifier;
|
|
271
|
+
}
|
|
272
|
+
sqlNow() {
|
|
273
|
+
return (0, malloy_types_1.mkExpr) `CURRENT_TIMESTAMP()`;
|
|
274
|
+
}
|
|
275
|
+
sqlTrunc(sqlTime, units) {
|
|
276
|
+
if (sqlTime.valueType == "date") {
|
|
277
|
+
if ((0, malloy_types_1.isDateUnit)(units)) {
|
|
278
|
+
return (0, malloy_types_1.mkExpr) `DATE_TRUNC(${sqlTime.value},${units})`;
|
|
279
|
+
}
|
|
280
|
+
return (0, malloy_types_1.mkExpr) `TIMESTAMP(${sqlTime.value})`;
|
|
281
|
+
}
|
|
282
|
+
return (0, malloy_types_1.mkExpr) `TIMESTAMP_TRUNC(${sqlTime.value},${units})`;
|
|
283
|
+
}
|
|
284
|
+
sqlExtract(expr, units) {
|
|
285
|
+
const extractTo = extractMap[units] || units;
|
|
286
|
+
return (0, malloy_types_1.mkExpr) `EXTRACT(${extractTo} FROM ${expr.value})`;
|
|
287
|
+
}
|
|
288
|
+
sqlAlterTime(op, expr, n, timeframe) {
|
|
289
|
+
let theTime = expr.value;
|
|
290
|
+
let computeType = expr.valueType;
|
|
291
|
+
if (timeframe != "day" && timestampAddUnits.includes(timeframe)) {
|
|
292
|
+
// The units must be done in timestamp, no matter the input type
|
|
293
|
+
computeType = "timestamp";
|
|
294
|
+
if (expr.valueType != "timestamp") {
|
|
295
|
+
theTime = (0, malloy_types_1.mkExpr) `TIMESTAMP(${theTime})`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else if (expr.valueType == "timestamp") {
|
|
299
|
+
theTime = (0, malloy_types_1.mkExpr) `DATETIME(${theTime})`;
|
|
300
|
+
computeType = "datetime";
|
|
301
|
+
}
|
|
302
|
+
const funcName = computeType.toUpperCase() + (op == "+" ? "_ADD" : "_SUB");
|
|
303
|
+
const newTime = (0, malloy_types_1.mkExpr) `${funcName}(${theTime}, INTERVAL ${n} ${timeframe})`;
|
|
304
|
+
return computeType == "datetime" ? (0, malloy_types_1.mkExpr) `TIMESTAMP(${newTime})` : newTime;
|
|
305
|
+
}
|
|
306
|
+
ignoreInProject(fieldName) {
|
|
307
|
+
return fieldName === "_PARTITIONTIME";
|
|
308
|
+
}
|
|
309
|
+
sqlCast(cast) {
|
|
310
|
+
if (cast.srcType !== cast.dstType) {
|
|
311
|
+
const dstType = castMap[cast.dstType] || cast.dstType;
|
|
312
|
+
// This just makes the code look a little prettier ...
|
|
313
|
+
if (!cast.safe && cast.srcType && (0, malloy_types_1.isTimeFieldType)(cast.srcType)) {
|
|
314
|
+
if (dstType == "date") {
|
|
315
|
+
return (0, malloy_types_1.mkExpr) `DATE(${cast.expr})`;
|
|
316
|
+
}
|
|
317
|
+
return (0, malloy_types_1.mkExpr) `TIMESTAMP(${cast.expr})`;
|
|
318
|
+
}
|
|
319
|
+
const castFunc = cast.safe ? "SAFE_CAST" : "CAST";
|
|
320
|
+
return (0, malloy_types_1.mkExpr) `${castFunc}(${cast.expr} AS ${dstType})`;
|
|
321
|
+
}
|
|
322
|
+
return cast.expr;
|
|
323
|
+
}
|
|
324
|
+
sqlRegexpMatch(expr, regexp) {
|
|
325
|
+
return (0, malloy_types_1.mkExpr) `REGEXP_CONTAINS(${expr}, r${regexp})`;
|
|
326
|
+
}
|
|
327
|
+
sqlLiteralTime(timeString, type, timezone) {
|
|
328
|
+
if (type === "date") {
|
|
329
|
+
return `DATE('${timeString}')`;
|
|
330
|
+
}
|
|
331
|
+
else if (type === "timestamp") {
|
|
332
|
+
return `TIMESTAMP('${timeString}', '${timezone}')`;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
throw new Error(`Unknown Liternal time format ${type}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
sqlMeasureTime(from, to, units) {
|
|
339
|
+
let lVal = from.value;
|
|
340
|
+
let rVal = to.value;
|
|
341
|
+
let diffUsing = "TIMESTAMP_DIFF";
|
|
342
|
+
if (units == "second" || units == "minute" || units == "hour") {
|
|
343
|
+
if (from.valueType != "timestamp") {
|
|
344
|
+
lVal = (0, malloy_types_1.mkExpr) `TIMESTAMP(${lVal})`;
|
|
345
|
+
}
|
|
346
|
+
if (to.valueType != "timestamp") {
|
|
347
|
+
rVal = (0, malloy_types_1.mkExpr) `TIMESTAMP(${rVal})`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
diffUsing = "DATE_DIFF";
|
|
352
|
+
if (from.valueType != "date") {
|
|
353
|
+
lVal = (0, malloy_types_1.mkExpr) `DATE(${lVal})`;
|
|
354
|
+
}
|
|
355
|
+
if (to.valueType != "date") {
|
|
356
|
+
rVal = (0, malloy_types_1.mkExpr) `DATE(${rVal})`;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return (0, malloy_types_1.mkExpr) `${diffUsing}(${rVal}, ${lVal}, ${units})`;
|
|
360
|
+
}
|
|
361
|
+
sqlSampleTable(tableSQL, sample) {
|
|
362
|
+
if (sample !== undefined) {
|
|
363
|
+
if ((0, malloy_types_1.isSamplingEnable)(sample) && sample.enable) {
|
|
364
|
+
sample = this.defaultSampling;
|
|
365
|
+
}
|
|
366
|
+
if ((0, malloy_types_1.isSamplingRows)(sample)) {
|
|
367
|
+
throw new Error(`StandardSQL doesn't support sampling by rows only percent`);
|
|
368
|
+
}
|
|
369
|
+
else if ((0, malloy_types_1.isSamplingPercent)(sample)) {
|
|
370
|
+
return `(SELECT * FROM ${tableSQL} TABLESAMPLE SYSTEM (${sample.percent} PERCENT))`;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return tableSQL;
|
|
374
|
+
}
|
|
375
|
+
sqlLiteralString(literal) {
|
|
376
|
+
const noVirgule = literal.replace(/\\/g, "\\\\");
|
|
377
|
+
return "'" + noVirgule.replace(/'/g, "\\'") + "'";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
exports.StandardSQLDialect = StandardSQLDialect;
|
|
381
|
+
//# sourceMappingURL=standardsql.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { QueryDataRow, Fragment, StructDef, StructRelationship, NamedStructDefs, MalloyQueryData, AtomicFieldType as AtomicFieldTypeInner, DateUnit, ExtractUnit, TimestampUnit, TimeFieldType, QueryData, FieldTypeDef, Expr, DialectFragment, TimeValue, FilterExpression, SQLBlock, FieldDef, FilteredAliasedName, PipeSegment, QueryFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, NamedQuery, NamedModelObject, ExpressionType, } from "./model";
|
|
2
|
+
export { Segment, isFilteredAliasedName, flattenQuery, expressionIsCalculation, } from "./model";
|
|
3
|
+
export { HighlightType, MalloyTranslator, } from "./lang";
|
|
4
|
+
export type { LogMessage, TranslateResponse } from "./lang";
|
|
5
|
+
export { Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, Result, parseTableURI, QueryMaterializer, CSVWriter, JSONWriter, DataWriter, } from "./malloy";
|
|
6
|
+
export type { Explore, Model, PreparedQuery, PreparedResult, Field, AtomicField, ExploreField, QueryField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, ModelMaterializer, DocumentSymbol, DocumentHighlight, ResultJSON, PreparedResultMaterializer, SQLBlockMaterializer, ExploreMaterializer, WriteStream, } from "./malloy";
|
|
7
|
+
export type { RunSQLOptions } from "./run_sql_options";
|
|
8
|
+
export type { URLReader, InfoConnection, LookupConnection, Connection, QueryString, ModelString, QueryURL, ModelURL, PooledConnection, TestableConnection, PersistSQLResults, StreamingConnection, } from "./runtime_types";
|
|
9
|
+
export type { Loggable } from "./malloy";
|
|
10
|
+
export { toAsyncGenerator } from "./connection_utils";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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.toAsyncGenerator = exports.DataWriter = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.parseTableURI = exports.Result = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.MalloyTranslator = exports.HighlightType = exports.expressionIsCalculation = exports.flattenQuery = exports.isFilteredAliasedName = exports.Segment = void 0;
|
|
26
|
+
var model_1 = require("./model");
|
|
27
|
+
// Used in Composer Demo
|
|
28
|
+
Object.defineProperty(exports, "Segment", { enumerable: true, get: function () { return model_1.Segment; } });
|
|
29
|
+
Object.defineProperty(exports, "isFilteredAliasedName", { enumerable: true, get: function () { return model_1.isFilteredAliasedName; } });
|
|
30
|
+
Object.defineProperty(exports, "flattenQuery", { enumerable: true, get: function () { return model_1.flattenQuery; } });
|
|
31
|
+
Object.defineProperty(exports, "expressionIsCalculation", { enumerable: true, get: function () { return model_1.expressionIsCalculation; } });
|
|
32
|
+
var lang_1 = require("./lang");
|
|
33
|
+
// Neede for VSCode extension
|
|
34
|
+
Object.defineProperty(exports, "HighlightType", { enumerable: true, get: function () { return lang_1.HighlightType; } });
|
|
35
|
+
// Needed for tests only
|
|
36
|
+
Object.defineProperty(exports, "MalloyTranslator", { enumerable: true, get: function () { return lang_1.MalloyTranslator; } });
|
|
37
|
+
var malloy_1 = require("./malloy");
|
|
38
|
+
Object.defineProperty(exports, "Malloy", { enumerable: true, get: function () { return malloy_1.Malloy; } });
|
|
39
|
+
Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return malloy_1.Runtime; } });
|
|
40
|
+
Object.defineProperty(exports, "AtomicFieldType", { enumerable: true, get: function () { return malloy_1.AtomicFieldType; } });
|
|
41
|
+
Object.defineProperty(exports, "ConnectionRuntime", { enumerable: true, get: function () { return malloy_1.ConnectionRuntime; } });
|
|
42
|
+
Object.defineProperty(exports, "SingleConnectionRuntime", { enumerable: true, get: function () { return malloy_1.SingleConnectionRuntime; } });
|
|
43
|
+
Object.defineProperty(exports, "EmptyURLReader", { enumerable: true, get: function () { return malloy_1.EmptyURLReader; } });
|
|
44
|
+
Object.defineProperty(exports, "InMemoryURLReader", { enumerable: true, get: function () { return malloy_1.InMemoryURLReader; } });
|
|
45
|
+
Object.defineProperty(exports, "FixedConnectionMap", { enumerable: true, get: function () { return malloy_1.FixedConnectionMap; } });
|
|
46
|
+
Object.defineProperty(exports, "MalloyError", { enumerable: true, get: function () { return malloy_1.MalloyError; } });
|
|
47
|
+
Object.defineProperty(exports, "JoinRelationship", { enumerable: true, get: function () { return malloy_1.JoinRelationship; } });
|
|
48
|
+
Object.defineProperty(exports, "SourceRelationship", { enumerable: true, get: function () { return malloy_1.SourceRelationship; } });
|
|
49
|
+
Object.defineProperty(exports, "DateTimeframe", { enumerable: true, get: function () { return malloy_1.DateTimeframe; } });
|
|
50
|
+
Object.defineProperty(exports, "TimestampTimeframe", { enumerable: true, get: function () { return malloy_1.TimestampTimeframe; } });
|
|
51
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return malloy_1.Result; } });
|
|
52
|
+
Object.defineProperty(exports, "parseTableURI", { enumerable: true, get: function () { return malloy_1.parseTableURI; } });
|
|
53
|
+
Object.defineProperty(exports, "QueryMaterializer", { enumerable: true, get: function () { return malloy_1.QueryMaterializer; } });
|
|
54
|
+
Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function () { return malloy_1.CSVWriter; } });
|
|
55
|
+
Object.defineProperty(exports, "JSONWriter", { enumerable: true, get: function () { return malloy_1.JSONWriter; } });
|
|
56
|
+
Object.defineProperty(exports, "DataWriter", { enumerable: true, get: function () { return malloy_1.DataWriter; } });
|
|
57
|
+
var connection_utils_1 = require("./connection_utils");
|
|
58
|
+
Object.defineProperty(exports, "toAsyncGenerator", { enumerable: true, get: function () { return connection_utils_1.toAsyncGenerator; } });
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExprValue } from "./types/expr-value";
|
|
2
|
+
/**
|
|
3
|
+
* When a translation hits an error, log and return one of these as a value.
|
|
4
|
+
* This will allow the rest of the translation walk to complete. The
|
|
5
|
+
* generated SQL will have a reference to an impossible variable name
|
|
6
|
+
* with the reason embedded in it.
|
|
7
|
+
* @param reason very short phrase, only read by implementers
|
|
8
|
+
* @returns Fragment[] which a debugging humnan will regognize
|
|
9
|
+
*/
|
|
10
|
+
export declare function errorFor(reason: string): ExprValue;
|
|
@@ -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.errorFor = void 0;
|
|
26
|
+
/**
|
|
27
|
+
* When a translation hits an error, log and return one of these as a value.
|
|
28
|
+
* This will allow the rest of the translation walk to complete. The
|
|
29
|
+
* generated SQL will have a reference to an impossible variable name
|
|
30
|
+
* with the reason embedded in it.
|
|
31
|
+
* @param reason very short phrase, only read by implementers
|
|
32
|
+
* @returns Fragment[] which a debugging humnan will regognize
|
|
33
|
+
*/
|
|
34
|
+
function errorFor(reason) {
|
|
35
|
+
return {
|
|
36
|
+
dataType: "unknown",
|
|
37
|
+
expressionType: "scalar",
|
|
38
|
+
value: [`_ERROR_${reason.replace(/ /g, "_")}`],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.errorFor = errorFor;
|
|
42
|
+
//# sourceMappingURL=ast-utils.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModelDataRequest } from "../../translate-response";
|
|
2
|
+
import { DocStatement, Document, MalloyElement, RunList } from "../types/malloy-element";
|
|
3
|
+
import { QueryElement } from "../types/query-element";
|
|
4
|
+
export declare class DefineQuery extends MalloyElement implements DocStatement {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly queryDetails: QueryElement;
|
|
7
|
+
elementType: string;
|
|
8
|
+
constructor(name: string, queryDetails: QueryElement);
|
|
9
|
+
execute(doc: Document): ModelDataRequest;
|
|
10
|
+
}
|
|
11
|
+
export declare class DefineQueryList extends RunList implements DocStatement {
|
|
12
|
+
constructor(queryList: DefineQuery[]);
|
|
13
|
+
execute(doc: Document): ModelDataRequest;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.DefineQueryList = exports.DefineQuery = void 0;
|
|
26
|
+
const malloy_element_1 = require("../types/malloy-element");
|
|
27
|
+
class DefineQuery extends malloy_element_1.MalloyElement {
|
|
28
|
+
constructor(name, queryDetails) {
|
|
29
|
+
super({ queryDetails });
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.queryDetails = queryDetails;
|
|
32
|
+
this.elementType = "defineQuery";
|
|
33
|
+
}
|
|
34
|
+
execute(doc) {
|
|
35
|
+
const entry = {
|
|
36
|
+
...this.queryDetails.query(),
|
|
37
|
+
type: "query",
|
|
38
|
+
name: this.name,
|
|
39
|
+
location: this.location,
|
|
40
|
+
};
|
|
41
|
+
const exported = false;
|
|
42
|
+
doc.setEntry(this.name, { entry, exported });
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.DefineQuery = DefineQuery;
|
|
47
|
+
class DefineQueryList extends malloy_element_1.RunList {
|
|
48
|
+
constructor(queryList) {
|
|
49
|
+
super("defineQueries", queryList);
|
|
50
|
+
}
|
|
51
|
+
execute(doc) {
|
|
52
|
+
return this.executeList(doc);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.DefineQueryList = DefineQueryList;
|
|
56
|
+
//# sourceMappingURL=define-query.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ModelDataRequest } from "../../translate-response";
|
|
2
|
+
import { DocStatement, Document, MalloyElement, RunList } from "../types/malloy-element";
|
|
3
|
+
import { HasParameter } from "../parameters/has-parameter";
|
|
4
|
+
import { Source } from "./source";
|
|
5
|
+
export declare class DefineSource extends MalloyElement implements DocStatement {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly theSource: Source;
|
|
8
|
+
readonly exported: boolean;
|
|
9
|
+
elementType: string;
|
|
10
|
+
readonly parameters?: HasParameter[];
|
|
11
|
+
constructor(name: string, theSource: Source, exported: boolean, params?: MalloyElement[]);
|
|
12
|
+
execute(doc: Document): ModelDataRequest;
|
|
13
|
+
}
|
|
14
|
+
export declare class DefineSourceList extends RunList implements DocStatement {
|
|
15
|
+
constructor(sourceList: DefineSource[]);
|
|
16
|
+
execute(doc: Document): ModelDataRequest;
|
|
17
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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.DefineSourceList = exports.DefineSource = void 0;
|
|
26
|
+
const malloy_element_1 = require("../types/malloy-element");
|
|
27
|
+
const has_parameter_1 = require("../parameters/has-parameter");
|
|
28
|
+
const error_factory_1 = require("../error-factory");
|
|
29
|
+
class DefineSource extends malloy_element_1.MalloyElement {
|
|
30
|
+
constructor(name, theSource, exported, params) {
|
|
31
|
+
super({ explore: theSource });
|
|
32
|
+
this.name = name;
|
|
33
|
+
this.theSource = theSource;
|
|
34
|
+
this.exported = exported;
|
|
35
|
+
this.elementType = "defineSource";
|
|
36
|
+
if (params) {
|
|
37
|
+
this.parameters = [];
|
|
38
|
+
for (const el of params) {
|
|
39
|
+
if (el instanceof has_parameter_1.HasParameter) {
|
|
40
|
+
this.parameters.push(el);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.log(`Unexpected element type in define statement: ${el.elementType}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.has({ parameters: this.parameters });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
execute(doc) {
|
|
50
|
+
if (doc.modelEntry(this.name)) {
|
|
51
|
+
this.log(`Cannot redefine '${this.name}'`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const structDef = this.theSource.withParameters(this.parameters);
|
|
55
|
+
if (error_factory_1.ErrorFactory.isErrorStructDef(structDef)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
doc.setEntry(this.name, {
|
|
59
|
+
entry: {
|
|
60
|
+
...structDef,
|
|
61
|
+
as: this.name,
|
|
62
|
+
location: this.location,
|
|
63
|
+
},
|
|
64
|
+
exported: this.exported,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.DefineSource = DefineSource;
|
|
70
|
+
class DefineSourceList extends malloy_element_1.RunList {
|
|
71
|
+
constructor(sourceList) {
|
|
72
|
+
super("defineSources", sourceList);
|
|
73
|
+
}
|
|
74
|
+
execute(doc) {
|
|
75
|
+
return this.executeList(doc);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.DefineSourceList = DefineSourceList;
|
|
79
|
+
//# sourceMappingURL=define-source.js.map
|