@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,378 @@
|
|
|
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.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isSQLBlock = exports.isSQLFragment = exports.isJoinOn = exports.isIndexSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxExpressionType = exports.expressionIsCalculation = exports.expressionIsAggregate = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isFieldFragment = exports.isAnalyticFragment = exports.malloyFunctions = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isFilteredAliasedName = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
|
|
26
|
+
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = void 0;
|
|
27
|
+
function isValueParameter(p) {
|
|
28
|
+
return p.value !== undefined;
|
|
29
|
+
}
|
|
30
|
+
exports.isValueParameter = isValueParameter;
|
|
31
|
+
function isConditionParameter(p) {
|
|
32
|
+
return p.condition !== undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.isConditionParameter = isConditionParameter;
|
|
35
|
+
function paramHasValue(p) {
|
|
36
|
+
return isValueParameter(p) || p.condition !== null;
|
|
37
|
+
}
|
|
38
|
+
exports.paramHasValue = paramHasValue;
|
|
39
|
+
function isFilteredAliasedName(f) {
|
|
40
|
+
for (const prop of Object.keys(f)) {
|
|
41
|
+
if (!["name", "as", "filterList"].includes(prop)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
exports.isFilteredAliasedName = isFilteredAliasedName;
|
|
48
|
+
function isFilterFragment(f) {
|
|
49
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "filterExpression";
|
|
50
|
+
}
|
|
51
|
+
exports.isFilterFragment = isFilterFragment;
|
|
52
|
+
function isDialectFragment(f) {
|
|
53
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "dialect";
|
|
54
|
+
}
|
|
55
|
+
exports.isDialectFragment = isDialectFragment;
|
|
56
|
+
function isAggregateFragment(f) {
|
|
57
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "aggregate";
|
|
58
|
+
}
|
|
59
|
+
exports.isAggregateFragment = isAggregateFragment;
|
|
60
|
+
function isAsymmetricFragment(f) {
|
|
61
|
+
return isAggregateFragment(f) && ["sum", "avg", "count"].includes(f.function);
|
|
62
|
+
}
|
|
63
|
+
exports.isAsymmetricFragment = isAsymmetricFragment;
|
|
64
|
+
function isUngroupFragment(f) {
|
|
65
|
+
const ftype = f === null || f === void 0 ? void 0 : f.type;
|
|
66
|
+
return ftype == "all" || ftype == "exclude";
|
|
67
|
+
}
|
|
68
|
+
exports.isUngroupFragment = isUngroupFragment;
|
|
69
|
+
exports.malloyFunctions = {
|
|
70
|
+
row_number: {
|
|
71
|
+
returnType: "number",
|
|
72
|
+
parameters: "none",
|
|
73
|
+
expressionType: "analytic",
|
|
74
|
+
},
|
|
75
|
+
rank: {
|
|
76
|
+
returnType: "number",
|
|
77
|
+
parameters: "none",
|
|
78
|
+
expressionType: "analytic",
|
|
79
|
+
},
|
|
80
|
+
dense_rank: {
|
|
81
|
+
returnType: "number",
|
|
82
|
+
parameters: "none",
|
|
83
|
+
expressionType: "analytic",
|
|
84
|
+
},
|
|
85
|
+
first_value_in_column: {
|
|
86
|
+
returnType: "number",
|
|
87
|
+
parameters: "any",
|
|
88
|
+
expressionType: "analytic",
|
|
89
|
+
sqlName: "first_value",
|
|
90
|
+
},
|
|
91
|
+
last_value_in_column: {
|
|
92
|
+
returnType: "number",
|
|
93
|
+
parameters: "any",
|
|
94
|
+
expressionType: "analytic",
|
|
95
|
+
sqlName: "last_value",
|
|
96
|
+
},
|
|
97
|
+
min_in_column: {
|
|
98
|
+
returnType: "number",
|
|
99
|
+
parameters: "any",
|
|
100
|
+
expressionType: "analytic",
|
|
101
|
+
sqlName: "min",
|
|
102
|
+
},
|
|
103
|
+
max_in_column: {
|
|
104
|
+
returnType: "number",
|
|
105
|
+
parameters: "any",
|
|
106
|
+
expressionType: "analytic",
|
|
107
|
+
sqlName: "max",
|
|
108
|
+
},
|
|
109
|
+
ntile: {
|
|
110
|
+
returnType: "number",
|
|
111
|
+
parameters: ["nconst"],
|
|
112
|
+
expressionType: "analytic",
|
|
113
|
+
},
|
|
114
|
+
lag: {
|
|
115
|
+
returnType: "number",
|
|
116
|
+
parameters: ["number", "nconst"],
|
|
117
|
+
expressionType: "analytic",
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
function isAnalyticFragment(f) {
|
|
121
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "analytic";
|
|
122
|
+
}
|
|
123
|
+
exports.isAnalyticFragment = isAnalyticFragment;
|
|
124
|
+
function isFieldFragment(f) {
|
|
125
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "field";
|
|
126
|
+
}
|
|
127
|
+
exports.isFieldFragment = isFieldFragment;
|
|
128
|
+
function isParameterFragment(f) {
|
|
129
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "parameter";
|
|
130
|
+
}
|
|
131
|
+
exports.isParameterFragment = isParameterFragment;
|
|
132
|
+
function isApplyValue(f) {
|
|
133
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "applyVal";
|
|
134
|
+
}
|
|
135
|
+
exports.isApplyValue = isApplyValue;
|
|
136
|
+
function isApplyFragment(f) {
|
|
137
|
+
return (f === null || f === void 0 ? void 0 : f.type) === "apply";
|
|
138
|
+
}
|
|
139
|
+
exports.isApplyFragment = isApplyFragment;
|
|
140
|
+
/**
|
|
141
|
+
* Return an Expr based on the string template, subsittutions can be
|
|
142
|
+
* either strings, or other Exprs.
|
|
143
|
+
|
|
144
|
+
* ```
|
|
145
|
+
* units = "inches"
|
|
146
|
+
* len: Expr = [ "something", "returning", "a length "]
|
|
147
|
+
* computeExpr = mkExpr`MEASURE(${len} in ${units})`;
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
function mkExpr(src, ...exprs) {
|
|
151
|
+
const ret = [];
|
|
152
|
+
let index;
|
|
153
|
+
for (index = 0; index < exprs.length; index++) {
|
|
154
|
+
const el = exprs[index];
|
|
155
|
+
if (src[index].length > 0) {
|
|
156
|
+
ret.push(src[index]);
|
|
157
|
+
}
|
|
158
|
+
if (typeof el == "string") {
|
|
159
|
+
ret.push(el);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
ret.push(...el);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (src[index].length > 0) {
|
|
166
|
+
ret.push(src[index]);
|
|
167
|
+
}
|
|
168
|
+
return ret;
|
|
169
|
+
}
|
|
170
|
+
exports.mkExpr = mkExpr;
|
|
171
|
+
function expressionIsAggregate(e) {
|
|
172
|
+
return e === "aggregate";
|
|
173
|
+
}
|
|
174
|
+
exports.expressionIsAggregate = expressionIsAggregate;
|
|
175
|
+
function expressionIsCalculation(e) {
|
|
176
|
+
return e === "aggregate" || e === "analytic";
|
|
177
|
+
}
|
|
178
|
+
exports.expressionIsCalculation = expressionIsCalculation;
|
|
179
|
+
function maxExpressionType(e1, e2) {
|
|
180
|
+
let ret = "scalar";
|
|
181
|
+
if (e1 === "aggregate" || e2 === "aggregate") {
|
|
182
|
+
ret = "aggregate";
|
|
183
|
+
}
|
|
184
|
+
if (e1 === "analytic" || e2 === "analytic") {
|
|
185
|
+
ret = "analytic";
|
|
186
|
+
}
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
exports.maxExpressionType = maxExpressionType;
|
|
190
|
+
/** Grants access to the expression property of a FielfDef */
|
|
191
|
+
function hasExpression(f) {
|
|
192
|
+
return f.e !== undefined;
|
|
193
|
+
}
|
|
194
|
+
exports.hasExpression = hasExpression;
|
|
195
|
+
function isTimeFieldType(s) {
|
|
196
|
+
return s == "date" || s == "timestamp";
|
|
197
|
+
}
|
|
198
|
+
exports.isTimeFieldType = isTimeFieldType;
|
|
199
|
+
function isAtomicFieldType(s) {
|
|
200
|
+
return ["string", "number", "date", "timestamp", "boolean", "json"].includes(s);
|
|
201
|
+
}
|
|
202
|
+
exports.isAtomicFieldType = isAtomicFieldType;
|
|
203
|
+
// this field definition represents something in the database.
|
|
204
|
+
function FieldIsIntrinsic(f) {
|
|
205
|
+
if (isAtomicFieldType(f.type) && !hasExpression(f)) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
else if (f.type === "struct" &&
|
|
209
|
+
(f.structSource.type === "inline" || f.structSource.type === "nested")) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.FieldIsIntrinsic = FieldIsIntrinsic;
|
|
217
|
+
function isDateUnit(str) {
|
|
218
|
+
return ["day", "week", "month", "quarter", "year"].includes(str);
|
|
219
|
+
}
|
|
220
|
+
exports.isDateUnit = isDateUnit;
|
|
221
|
+
function isTimestampUnit(s) {
|
|
222
|
+
return isDateUnit(s) || ["hour", "minute", "second"].includes(s);
|
|
223
|
+
}
|
|
224
|
+
exports.isTimestampUnit = isTimestampUnit;
|
|
225
|
+
function isExtractUnit(s) {
|
|
226
|
+
return isTimestampUnit(s) || s == "day_of_week" || s == "day_of_year";
|
|
227
|
+
}
|
|
228
|
+
exports.isExtractUnit = isExtractUnit;
|
|
229
|
+
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
230
|
+
var ValueType;
|
|
231
|
+
(function (ValueType) {
|
|
232
|
+
ValueType["Date"] = "date";
|
|
233
|
+
ValueType["Timestamp"] = "timestamp";
|
|
234
|
+
ValueType["Number"] = "number";
|
|
235
|
+
ValueType["String"] = "string";
|
|
236
|
+
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
237
|
+
function isByName(by) {
|
|
238
|
+
if (by === undefined) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
return by.by === "name";
|
|
242
|
+
}
|
|
243
|
+
exports.isByName = isByName;
|
|
244
|
+
function isByExpression(by) {
|
|
245
|
+
if (by === undefined) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
return by.by === "name";
|
|
249
|
+
}
|
|
250
|
+
exports.isByExpression = isByExpression;
|
|
251
|
+
function refIsStructDef(ref) {
|
|
252
|
+
return typeof ref !== "string" && ref.type === "struct";
|
|
253
|
+
}
|
|
254
|
+
exports.refIsStructDef = refIsStructDef;
|
|
255
|
+
function isReduceSegment(pe) {
|
|
256
|
+
return pe.type === "reduce";
|
|
257
|
+
}
|
|
258
|
+
exports.isReduceSegment = isReduceSegment;
|
|
259
|
+
function isProjectSegment(pe) {
|
|
260
|
+
return pe.type === "project";
|
|
261
|
+
}
|
|
262
|
+
exports.isProjectSegment = isProjectSegment;
|
|
263
|
+
function isQuerySegment(pe) {
|
|
264
|
+
return isProjectSegment(pe) || isReduceSegment(pe);
|
|
265
|
+
}
|
|
266
|
+
exports.isQuerySegment = isQuerySegment;
|
|
267
|
+
function isSamplingRows(s) {
|
|
268
|
+
return s.rows !== undefined;
|
|
269
|
+
}
|
|
270
|
+
exports.isSamplingRows = isSamplingRows;
|
|
271
|
+
function isSamplingPercent(s) {
|
|
272
|
+
return s.percent !== undefined;
|
|
273
|
+
}
|
|
274
|
+
exports.isSamplingPercent = isSamplingPercent;
|
|
275
|
+
function isSamplingEnable(s) {
|
|
276
|
+
return s.enable !== undefined;
|
|
277
|
+
}
|
|
278
|
+
exports.isSamplingEnable = isSamplingEnable;
|
|
279
|
+
function isIndexSegment(pe) {
|
|
280
|
+
return pe.type === "index";
|
|
281
|
+
}
|
|
282
|
+
exports.isIndexSegment = isIndexSegment;
|
|
283
|
+
function isJoinOn(sr) {
|
|
284
|
+
return ["one", "many", "cross"].includes(sr.type);
|
|
285
|
+
}
|
|
286
|
+
exports.isJoinOn = isJoinOn;
|
|
287
|
+
function isSQLFragment(f) {
|
|
288
|
+
return f.sql !== undefined;
|
|
289
|
+
}
|
|
290
|
+
exports.isSQLFragment = isSQLFragment;
|
|
291
|
+
function isSQLBlock(sd) {
|
|
292
|
+
const src = sd.structSource;
|
|
293
|
+
return src.type == "sql" && src.method == "subquery";
|
|
294
|
+
}
|
|
295
|
+
exports.isSQLBlock = isSQLBlock;
|
|
296
|
+
function isFieldTypeDef(f) {
|
|
297
|
+
return (f.type === "string" ||
|
|
298
|
+
f.type === "date" ||
|
|
299
|
+
f.type === "number" ||
|
|
300
|
+
f.type === "timestamp" ||
|
|
301
|
+
f.type === "boolean" ||
|
|
302
|
+
f.type === "json");
|
|
303
|
+
}
|
|
304
|
+
exports.isFieldTypeDef = isFieldTypeDef;
|
|
305
|
+
function isFieldTimeBased(f) {
|
|
306
|
+
return f.type === "date" || f.type === "timestamp";
|
|
307
|
+
}
|
|
308
|
+
exports.isFieldTimeBased = isFieldTimeBased;
|
|
309
|
+
function isFieldStructDef(f) {
|
|
310
|
+
return f.type === "struct";
|
|
311
|
+
}
|
|
312
|
+
exports.isFieldStructDef = isFieldStructDef;
|
|
313
|
+
/** Get the output name for a NamedObject */
|
|
314
|
+
function getIdentifier(n) {
|
|
315
|
+
if (n.as !== undefined) {
|
|
316
|
+
return n.as;
|
|
317
|
+
}
|
|
318
|
+
return n.name;
|
|
319
|
+
}
|
|
320
|
+
exports.getIdentifier = getIdentifier;
|
|
321
|
+
function isTurtleDef(def) {
|
|
322
|
+
return def.type === "turtle";
|
|
323
|
+
}
|
|
324
|
+
exports.isTurtleDef = isTurtleDef;
|
|
325
|
+
function isDimensional(field) {
|
|
326
|
+
var _a;
|
|
327
|
+
if ("resultMetadata" in field) {
|
|
328
|
+
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "dimension";
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
exports.isDimensional = isDimensional;
|
|
333
|
+
function isPhysical(field) {
|
|
334
|
+
return ((isFieldTypeDef(field) && field.e === undefined) ||
|
|
335
|
+
(isFieldStructDef(field) &&
|
|
336
|
+
(field.structSource.type === "nested" ||
|
|
337
|
+
field.structSource.type == "inline")));
|
|
338
|
+
}
|
|
339
|
+
exports.isPhysical = isPhysical;
|
|
340
|
+
function getDimensions(structDef) {
|
|
341
|
+
return structDef.fields.filter(isDimensional);
|
|
342
|
+
}
|
|
343
|
+
exports.getDimensions = getDimensions;
|
|
344
|
+
function getPhysicalFields(structDef) {
|
|
345
|
+
return structDef.fields.filter(isPhysical);
|
|
346
|
+
}
|
|
347
|
+
exports.getPhysicalFields = getPhysicalFields;
|
|
348
|
+
function isMeasureLike(field) {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
if ("resultMetadata" in field) {
|
|
351
|
+
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "measure" ||
|
|
352
|
+
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === "struct");
|
|
353
|
+
}
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
exports.isMeasureLike = isMeasureLike;
|
|
357
|
+
function isValueString(value, field) {
|
|
358
|
+
return field.type === "string";
|
|
359
|
+
}
|
|
360
|
+
exports.isValueString = isValueString;
|
|
361
|
+
function isValueNumber(value, field) {
|
|
362
|
+
return field.type === "number";
|
|
363
|
+
}
|
|
364
|
+
exports.isValueNumber = isValueNumber;
|
|
365
|
+
function isValueBoolean(value, field) {
|
|
366
|
+
return field.type === "boolean";
|
|
367
|
+
}
|
|
368
|
+
exports.isValueBoolean = isValueBoolean;
|
|
369
|
+
function isValueTimestamp(value, field) {
|
|
370
|
+
return field.type === "timestamp";
|
|
371
|
+
}
|
|
372
|
+
exports.isValueTimestamp = isValueTimestamp;
|
|
373
|
+
function isValueDate(value, field) {
|
|
374
|
+
return field.type === "date";
|
|
375
|
+
}
|
|
376
|
+
exports.isValueDate = isValueDate;
|
|
377
|
+
// clang-format on
|
|
378
|
+
//# sourceMappingURL=malloy_types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SQLBlockSource, SQLPhrase } from "./malloy_types";
|
|
2
|
+
/**
|
|
3
|
+
* The factory for SQLBlocks. Exists because the name is computed
|
|
4
|
+
* from the components of the block and that name needs to be
|
|
5
|
+
* unique, but predictable.
|
|
6
|
+
*/
|
|
7
|
+
export declare function makeSQLBlock(select: SQLPhrase[], connection?: string): SQLBlockSource;
|
|
@@ -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.makeSQLBlock = void 0;
|
|
26
|
+
const malloy_types_1 = require("./malloy_types");
|
|
27
|
+
const utils_1 = require("./utils");
|
|
28
|
+
/**
|
|
29
|
+
* The factory for SQLBlocks. Exists because the name is computed
|
|
30
|
+
* from the components of the block and that name needs to be
|
|
31
|
+
* unique, but predictable.
|
|
32
|
+
*/
|
|
33
|
+
function makeSQLBlock(select, connection) {
|
|
34
|
+
const theBlock = {
|
|
35
|
+
name: `md5:/${connection || "$default"}//${nameFor(select)}`,
|
|
36
|
+
select,
|
|
37
|
+
};
|
|
38
|
+
if (connection) {
|
|
39
|
+
theBlock.connection = connection;
|
|
40
|
+
}
|
|
41
|
+
return theBlock;
|
|
42
|
+
}
|
|
43
|
+
exports.makeSQLBlock = makeSQLBlock;
|
|
44
|
+
// This feels like wrongness on toast, before SQL contained a query we
|
|
45
|
+
// could compute a stable hash from the select property to use to
|
|
46
|
+
// indentify this piece of SQL. Now the actual SQL isn't known until
|
|
47
|
+
// runtime and I am not certain what the right thing to do is, and
|
|
48
|
+
// at this moment when I am still trying to imagine how this is all
|
|
49
|
+
// going to work, I am using stringify(), but I suspect I will be back
|
|
50
|
+
// here for later, and that the whole "how to determine the name of a query"
|
|
51
|
+
// algorithm needs to change
|
|
52
|
+
function nameFor(select) {
|
|
53
|
+
const phrases = select.map((el) => (0, malloy_types_1.isSQLFragment)(el) ? el.sql : JSON.stringify(el));
|
|
54
|
+
return (0, utils_1.generateHash)(phrases.join(";"));
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sql_block.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** simple indent function */
|
|
2
|
+
export declare function indent(s: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Generate a SQL string literal from a given `input` string, safe, e.g., to be used in `WHERE` clauses.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateSQLStringLiteral(input: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* WHERE and HAVING clauses are built out of a chain of boolean experssions
|
|
9
|
+
* joined with AND.
|
|
10
|
+
*/
|
|
11
|
+
export declare class AndChain {
|
|
12
|
+
private clauses;
|
|
13
|
+
constructor(intial?: string);
|
|
14
|
+
clone(): AndChain;
|
|
15
|
+
add(clause: string): AndChain;
|
|
16
|
+
addChain(andChain: AndChain): AndChain;
|
|
17
|
+
empty(): boolean;
|
|
18
|
+
present(): boolean;
|
|
19
|
+
sqlOr(): string;
|
|
20
|
+
sql(whereOrHaving?: "where" | "having"): string;
|
|
21
|
+
}
|
|
22
|
+
export declare function generateHash(input: string): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.generateHash = exports.AndChain = exports.generateSQLStringLiteral = exports.indent = void 0;
|
|
29
|
+
const md5_1 = __importDefault(require("md5"));
|
|
30
|
+
/** simple indent function */
|
|
31
|
+
function indent(s) {
|
|
32
|
+
const re = /(^|\n)/g;
|
|
33
|
+
const lastNewline = /\n {2}$/;
|
|
34
|
+
return s.replace(re, "$1 ").replace(lastNewline, "\n");
|
|
35
|
+
}
|
|
36
|
+
exports.indent = indent;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a SQL string literal from a given `input` string, safe, e.g., to be used in `WHERE` clauses.
|
|
39
|
+
*/
|
|
40
|
+
function generateSQLStringLiteral(input) {
|
|
41
|
+
const escapedString = input.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
42
|
+
return `'${escapedString}'`;
|
|
43
|
+
}
|
|
44
|
+
exports.generateSQLStringLiteral = generateSQLStringLiteral;
|
|
45
|
+
/**
|
|
46
|
+
* WHERE and HAVING clauses are built out of a chain of boolean experssions
|
|
47
|
+
* joined with AND.
|
|
48
|
+
*/
|
|
49
|
+
class AndChain {
|
|
50
|
+
constructor(intial) {
|
|
51
|
+
this.clauses = [];
|
|
52
|
+
if (intial) {
|
|
53
|
+
this.clauses.push(intial);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
clone() {
|
|
57
|
+
const theClone = new AndChain();
|
|
58
|
+
theClone.addChain(this);
|
|
59
|
+
return theClone;
|
|
60
|
+
}
|
|
61
|
+
add(clause) {
|
|
62
|
+
this.clauses.push(clause);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
addChain(andChain) {
|
|
66
|
+
this.clauses.push(...andChain.clauses);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
empty() {
|
|
70
|
+
return this.clauses.length === 0;
|
|
71
|
+
}
|
|
72
|
+
present() {
|
|
73
|
+
return this.clauses.length > 0;
|
|
74
|
+
}
|
|
75
|
+
sqlOr() {
|
|
76
|
+
if (this.empty()) {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
return this.clauses.map((c) => `(${c})`).join("OR ") + "\n";
|
|
80
|
+
}
|
|
81
|
+
sql(whereOrHaving) {
|
|
82
|
+
if (this.empty()) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
let prefix = "";
|
|
86
|
+
let postfix = "";
|
|
87
|
+
if (whereOrHaving) {
|
|
88
|
+
prefix = whereOrHaving.toUpperCase() + " ";
|
|
89
|
+
postfix = "\n";
|
|
90
|
+
}
|
|
91
|
+
if (this.clauses.length === 1) {
|
|
92
|
+
return prefix + this.clauses[0] + postfix;
|
|
93
|
+
}
|
|
94
|
+
return prefix + this.clauses.map((c) => `(${c})`).join("\nAND ") + postfix;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.AndChain = AndChain;
|
|
98
|
+
function generateHash(input) {
|
|
99
|
+
return (0, md5_1.default)(input);
|
|
100
|
+
}
|
|
101
|
+
exports.generateHash = generateHash;
|
|
102
|
+
//# sourceMappingURL=utils.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=run_sql_options.js.map
|