@malloydata/malloy 0.0.24-dev230224214106 → 0.0.24-dev230228224434
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.js +10 -10
- package/dist/dialect/dialect.d.ts +2 -2
- package/dist/dialect/dialect.js +13 -13
- package/dist/dialect/dialect_map.d.ts +1 -1
- package/dist/dialect/duckdb.d.ts +3 -3
- package/dist/dialect/duckdb.js +44 -44
- package/dist/dialect/index.d.ts +6 -6
- package/dist/dialect/postgres.d.ts +3 -3
- package/dist/dialect/postgres.js +46 -46
- package/dist/dialect/standardsql.d.ts +4 -4
- package/dist/dialect/standardsql.js +51 -51
- package/dist/index.d.ts +10 -10
- package/dist/lang/ast/ast-utils.d.ts +1 -1
- package/dist/lang/ast/ast-utils.js +3 -3
- package/dist/lang/ast/elements/define-query.d.ts +3 -3
- package/dist/lang/ast/elements/define-query.js +6 -6
- package/dist/lang/ast/elements/define-source.d.ts +4 -4
- package/dist/lang/ast/elements/define-source.js +8 -8
- package/dist/lang/ast/elements/import-statement.d.ts +2 -2
- package/dist/lang/ast/elements/import-statement.js +7 -7
- package/dist/lang/ast/elements/pipeline-desc.d.ts +5 -5
- package/dist/lang/ast/elements/pipeline-desc.js +11 -11
- package/dist/lang/ast/elements/refined-source.d.ts +4 -4
- package/dist/lang/ast/elements/refined-source.js +6 -6
- package/dist/lang/ast/elements/source.d.ts +3 -3
- package/dist/lang/ast/elements/source.js +1 -1
- package/dist/lang/ast/error-factory.d.ts +1 -1
- package/dist/lang/ast/error-factory.js +15 -15
- package/dist/lang/ast/executors/index-executor.d.ts +7 -7
- package/dist/lang/ast/executors/index-executor.js +4 -4
- package/dist/lang/ast/executors/project-executor.d.ts +5 -5
- package/dist/lang/ast/executors/project-executor.js +2 -2
- package/dist/lang/ast/executors/reduce-executor.d.ts +8 -8
- package/dist/lang/ast/executors/reduce-executor.js +5 -5
- package/dist/lang/ast/expressions/apply.d.ts +2 -2
- package/dist/lang/ast/expressions/apply.js +1 -1
- package/dist/lang/ast/expressions/binary-boolean.d.ts +3 -3
- package/dist/lang/ast/expressions/binary-boolean.js +6 -6
- package/dist/lang/ast/expressions/binary-numeric.d.ts +3 -3
- package/dist/lang/ast/expressions/binary-numeric.js +2 -2
- package/dist/lang/ast/expressions/boolean.d.ts +4 -4
- package/dist/lang/ast/expressions/boolean.js +2 -2
- package/dist/lang/ast/expressions/constant-sub-expression.d.ts +4 -4
- package/dist/lang/ast/expressions/constant-sub-expression.js +12 -12
- package/dist/lang/ast/expressions/expr-add-sub.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-add-sub.js +1 -1
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +5 -5
- package/dist/lang/ast/expressions/expr-aggregate-function.js +15 -15
- package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +6 -6
- package/dist/lang/ast/expressions/expr-alternation-tree.js +6 -6
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +5 -5
- package/dist/lang/ast/expressions/expr-asymmetric.js +3 -3
- package/dist/lang/ast/expressions/expr-avg.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-avg.js +2 -2
- package/dist/lang/ast/expressions/expr-cast.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-cast.js +6 -6
- package/dist/lang/ast/expressions/expr-compare.d.ts +5 -5
- package/dist/lang/ast/expressions/expr-compare.js +9 -9
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-count-distinct.js +1 -1
- package/dist/lang/ast/expressions/expr-count.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-count.js +10 -10
- package/dist/lang/ast/expressions/expr-filter.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-filter.js +13 -13
- package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-func.js +8 -8
- package/dist/lang/ast/expressions/expr-granular-time.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-granular-time.js +17 -17
- package/dist/lang/ast/expressions/expr-id-reference.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-id-reference.js +11 -11
- package/dist/lang/ast/expressions/expr-logical-op.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-logical-op.js +1 -1
- package/dist/lang/ast/expressions/expr-max.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-max.js +1 -1
- package/dist/lang/ast/expressions/expr-min.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-min.js +1 -1
- package/dist/lang/ast/expressions/expr-minus.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-minus.js +5 -5
- package/dist/lang/ast/expressions/expr-mul-div.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-mul-div.js +1 -1
- package/dist/lang/ast/expressions/expr-not.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-not.js +3 -3
- package/dist/lang/ast/expressions/expr-now.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-now.js +8 -8
- package/dist/lang/ast/expressions/expr-null.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-null.js +4 -4
- package/dist/lang/ast/expressions/expr-number.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-number.js +2 -2
- package/dist/lang/ast/expressions/expr-parens.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-parens.js +3 -3
- package/dist/lang/ast/expressions/expr-regex.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-regex.js +4 -4
- package/dist/lang/ast/expressions/expr-string.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-string.js +8 -8
- package/dist/lang/ast/expressions/expr-sum.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-sum.js +2 -2
- package/dist/lang/ast/expressions/expr-time-extract.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-time-extract.js +30 -30
- package/dist/lang/ast/expressions/expr-time.d.ts +4 -4
- package/dist/lang/ast/expressions/expr-time.js +10 -10
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +6 -6
- package/dist/lang/ast/expressions/expr-ungroup.js +13 -13
- package/dist/lang/ast/expressions/for-range.d.ts +4 -4
- package/dist/lang/ast/expressions/for-range.js +17 -17
- package/dist/lang/ast/expressions/granular-literal.d.ts +4 -4
- package/dist/lang/ast/expressions/granular-literal.js +34 -34
- package/dist/lang/ast/expressions/partial-compare.d.ts +4 -4
- package/dist/lang/ast/expressions/partial-compare.js +4 -4
- package/dist/lang/ast/expressions/pick-when.d.ts +4 -4
- package/dist/lang/ast/expressions/pick-when.js +32 -32
- package/dist/lang/ast/expressions/range.d.ts +3 -3
- package/dist/lang/ast/expressions/range.js +20 -20
- package/dist/lang/ast/expressions/time-frame.d.ts +2 -2
- package/dist/lang/ast/expressions/time-frame.js +3 -3
- package/dist/lang/ast/expressions/top-by.d.ts +4 -4
- package/dist/lang/ast/expressions/top-by.js +5 -5
- package/dist/lang/ast/expressions/unary.d.ts +1 -1
- package/dist/lang/ast/expressions/unary.js +1 -1
- package/dist/lang/ast/expressions/utils.d.ts +2 -2
- package/dist/lang/ast/expressions/utils.js +6 -6
- package/dist/lang/ast/field-space/column-space-field.d.ts +3 -3
- package/dist/lang/ast/field-space/dynamic-space.d.ts +7 -7
- package/dist/lang/ast/field-space/dynamic-space.js +2 -2
- package/dist/lang/ast/field-space/field-definition-value.d.ts +5 -5
- package/dist/lang/ast/field-space/index-field-space.d.ts +3 -3
- package/dist/lang/ast/field-space/index-field-space.js +4 -4
- package/dist/lang/ast/field-space/join-space-field.d.ts +3 -3
- package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
- package/dist/lang/ast/field-space/project-field-space.js +5 -5
- package/dist/lang/ast/field-space/query-field-struct.d.ts +3 -3
- package/dist/lang/ast/field-space/query-field-struct.js +1 -1
- package/dist/lang/ast/field-space/query-space-field.d.ts +4 -4
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.d.ts +11 -11
- package/dist/lang/ast/field-space/query-spaces.js +8 -8
- package/dist/lang/ast/field-space/reference-field.d.ts +5 -5
- package/dist/lang/ast/field-space/reference-field.js +1 -1
- package/dist/lang/ast/field-space/refined-space.d.ts +4 -4
- package/dist/lang/ast/field-space/refined-space.js +2 -2
- package/dist/lang/ast/field-space/rename-space-field.d.ts +3 -3
- package/dist/lang/ast/field-space/rename-space-field.js +2 -2
- package/dist/lang/ast/field-space/static-space.d.ts +7 -7
- package/dist/lang/ast/field-space/static-space.js +12 -12
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +4 -4
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/field-space/wild-space-field.d.ts +4 -4
- package/dist/lang/ast/field-space/wild-space-field.js +1 -1
- package/dist/lang/ast/fragtype-utils.d.ts +1 -1
- package/dist/lang/ast/fragtype-utils.js +15 -15
- package/dist/lang/ast/index.d.ts +90 -90
- package/dist/lang/ast/parameters/constant-parameter.d.ts +3 -3
- package/dist/lang/ast/parameters/constant-parameter.js +10 -10
- package/dist/lang/ast/parameters/has-parameter.d.ts +3 -3
- package/dist/lang/ast/parameters/has-parameter.js +7 -7
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
- package/dist/lang/ast/query-elements/anonymous-query.js +2 -2
- package/dist/lang/ast/query-elements/existing-query.d.ts +4 -4
- package/dist/lang/ast/query-elements/existing-query.js +10 -10
- package/dist/lang/ast/query-elements/full-query.d.ts +4 -4
- package/dist/lang/ast/query-elements/full-query.js +10 -10
- package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
- package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
- package/dist/lang/ast/query-items/field-declaration.d.ts +6 -6
- package/dist/lang/ast/query-items/field-declaration.js +14 -14
- package/dist/lang/ast/query-items/field-references.d.ts +6 -6
- package/dist/lang/ast/query-items/field-references.js +9 -9
- package/dist/lang/ast/query-properties/aggregate.d.ts +2 -2
- package/dist/lang/ast/query-properties/aggregate.js +1 -1
- package/dist/lang/ast/query-properties/declare-fields.d.ts +2 -2
- package/dist/lang/ast/query-properties/declare-fields.js +1 -1
- package/dist/lang/ast/query-properties/dimmensions.d.ts +2 -2
- package/dist/lang/ast/query-properties/dimmensions.js +1 -1
- package/dist/lang/ast/query-properties/filters.d.ts +4 -4
- package/dist/lang/ast/query-properties/filters.js +16 -16
- package/dist/lang/ast/query-properties/group-by.d.ts +2 -2
- package/dist/lang/ast/query-properties/group-by.js +1 -1
- package/dist/lang/ast/query-properties/indexing.d.ts +3 -3
- package/dist/lang/ast/query-properties/indexing.js +3 -3
- package/dist/lang/ast/query-properties/joins.d.ts +6 -6
- package/dist/lang/ast/query-properties/joins.js +27 -27
- package/dist/lang/ast/query-properties/limit.d.ts +1 -1
- package/dist/lang/ast/query-properties/limit.js +1 -1
- package/dist/lang/ast/query-properties/measures.d.ts +2 -2
- package/dist/lang/ast/query-properties/measures.js +1 -1
- package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -2
- package/dist/lang/ast/query-properties/nest-reference.js +1 -1
- package/dist/lang/ast/query-properties/nest.d.ts +7 -7
- package/dist/lang/ast/query-properties/nest.js +7 -7
- package/dist/lang/ast/query-properties/nests.d.ts +2 -2
- package/dist/lang/ast/query-properties/nests.js +1 -1
- package/dist/lang/ast/query-properties/ordering.d.ts +3 -3
- package/dist/lang/ast/query-properties/ordering.js +6 -6
- package/dist/lang/ast/query-properties/project-statement.d.ts +2 -2
- package/dist/lang/ast/query-properties/project-statement.js +1 -1
- package/dist/lang/ast/query-properties/qop-desc.d.ts +7 -7
- package/dist/lang/ast/query-properties/qop-desc.js +20 -20
- package/dist/lang/ast/query-properties/sampling.d.ts +2 -2
- package/dist/lang/ast/query-properties/sampling.js +1 -1
- package/dist/lang/ast/query-properties/top.d.ts +4 -4
- package/dist/lang/ast/query-properties/top.js +5 -5
- package/dist/lang/ast/source-properties/field-list-edit.d.ts +4 -4
- package/dist/lang/ast/source-properties/field-list-edit.js +2 -2
- package/dist/lang/ast/source-properties/primary-key.d.ts +2 -2
- package/dist/lang/ast/source-properties/primary-key.js +2 -2
- package/dist/lang/ast/source-properties/renames.d.ts +2 -2
- package/dist/lang/ast/source-properties/renames.js +3 -3
- package/dist/lang/ast/source-properties/turtles.d.ts +2 -2
- package/dist/lang/ast/source-properties/turtles.js +1 -1
- package/dist/lang/ast/sources/named-source.d.ts +4 -4
- package/dist/lang/ast/sources/named-source.js +5 -5
- package/dist/lang/ast/sources/query-source.d.ts +3 -3
- package/dist/lang/ast/sources/query-source.js +3 -3
- package/dist/lang/ast/sources/sql-source.d.ts +2 -2
- package/dist/lang/ast/sources/sql-source.js +2 -2
- package/dist/lang/ast/sources/table-source.d.ts +2 -2
- package/dist/lang/ast/sources/table-source.js +7 -7
- package/dist/lang/ast/space-seed.d.ts +2 -2
- package/dist/lang/ast/space-seed.js +1 -1
- package/dist/lang/ast/sql-elements/sql-statement.d.ts +4 -4
- package/dist/lang/ast/sql-elements/sql-statement.js +9 -9
- package/dist/lang/ast/sql-elements/sql-string.d.ts +3 -3
- package/dist/lang/ast/sql-elements/sql-string.js +6 -6
- package/dist/lang/ast/struct-utils.d.ts +2 -2
- package/dist/lang/ast/struct-utils.js +3 -3
- package/dist/lang/ast/time-utils.d.ts +6 -6
- package/dist/lang/ast/time-utils.js +46 -46
- package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
- package/dist/lang/ast/types/executor.d.ts +3 -3
- package/dist/lang/ast/types/explore-desc.d.ts +2 -2
- package/dist/lang/ast/types/explore-desc.js +1 -1
- package/dist/lang/ast/types/explore-field.d.ts +3 -3
- package/dist/lang/ast/types/expr-result.d.ts +2 -2
- package/dist/lang/ast/types/expr-value.d.ts +2 -2
- package/dist/lang/ast/types/expression-def.d.ts +4 -4
- package/dist/lang/ast/types/expression-def.js +86 -86
- package/dist/lang/ast/types/field-collection-member.d.ts +3 -3
- package/dist/lang/ast/types/field-decl.d.ts +5 -5
- package/dist/lang/ast/types/field-space.d.ts +5 -5
- package/dist/lang/ast/types/field-space.js +1 -1
- package/dist/lang/ast/types/granular-result.d.ts +3 -3
- package/dist/lang/ast/types/granular-result.js +1 -1
- package/dist/lang/ast/types/lookup-result.d.ts +1 -1
- package/dist/lang/ast/types/malloy-element.d.ts +6 -6
- package/dist/lang/ast/types/malloy-element.js +49 -49
- package/dist/lang/ast/types/model-entry.d.ts +1 -1
- package/dist/lang/ast/types/name-space.d.ts +1 -1
- package/dist/lang/ast/types/nested-query.d.ts +2 -2
- package/dist/lang/ast/types/op-desc.d.ts +2 -2
- package/dist/lang/ast/types/query-comp.d.ts +1 -1
- package/dist/lang/ast/types/query-element.d.ts +3 -3
- package/dist/lang/ast/types/query-item.d.ts +4 -4
- package/dist/lang/ast/types/query-property.d.ts +15 -15
- package/dist/lang/ast/types/source-property.d.ts +8 -8
- package/dist/lang/ast/types/space-entry.d.ts +2 -2
- package/dist/lang/ast/types/space-field.d.ts +4 -4
- package/dist/lang/ast/types/space-field.js +4 -4
- package/dist/lang/ast/types/space-param.d.ts +4 -4
- package/dist/lang/ast/types/space-param.js +4 -4
- package/dist/lang/ast/types/time-result.d.ts +2 -2
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +2 -2
- package/dist/lang/ast/types/turtle-headed-pipe.js +1 -1
- package/dist/lang/ast/types/type-desc.d.ts +3 -3
- package/dist/lang/field-utils.d.ts +1 -1
- package/dist/lang/field-utils.js +4 -4
- package/dist/lang/index.d.ts +10 -10
- package/dist/lang/malloy-to-ast.d.ts +8 -8
- package/dist/lang/malloy-to-ast.js +68 -68
- package/dist/lang/parse-error-handler.d.ts +3 -3
- package/dist/lang/parse-error-handler.js +4 -4
- package/dist/lang/parse-log.d.ts +2 -2
- package/dist/lang/parse-log.js +1 -1
- package/dist/lang/parse-malloy.d.ts +7 -7
- package/dist/lang/parse-malloy.js +81 -81
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +2 -2
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +38 -38
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +1 -1
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +14 -14
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +3 -3
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +85 -85
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +4 -4
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +40 -40
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +3 -3
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +3 -3
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +4 -4
- package/dist/lang/parse-tree-walkers/find-external-references.js +2 -2
- package/dist/lang/reference-list.d.ts +1 -1
- package/dist/lang/test/document-help-context-walker.spec.js +9 -9
- package/dist/lang/test/document-symbol-walker.spec.js +32 -32
- package/dist/lang/test/field-symbols.spec.js +87 -87
- package/dist/lang/test/parse.spec.d.ts +1 -1
- package/dist/lang/test/parse.spec.js +768 -768
- package/dist/lang/test/test-translator.d.ts +6 -6
- package/dist/lang/test/test-translator.js +159 -159
- package/dist/lang/translate-response.d.ts +7 -7
- package/dist/lang/translate-response.js +1 -1
- package/dist/lang/zone.d.ts +5 -5
- package/dist/lang/zone.js +8 -8
- package/dist/malloy.d.ts +7 -7
- package/dist/malloy.js +192 -192
- package/dist/model/index.d.ts +2 -2
- package/dist/model/malloy_query.d.ts +12 -12
- package/dist/model/malloy_query.js +497 -502
- package/dist/model/malloy_types.d.ts +68 -68
- package/dist/model/malloy_types.js +102 -102
- package/dist/model/sql_block.d.ts +1 -1
- package/dist/model/sql_block.js +4 -4
- package/dist/model/utils.d.ts +1 -1
- package/dist/model/utils.js +10 -10
- package/dist/runtime_types.d.ts +2 -2
- package/package.json +4 -1
|
@@ -38,7 +38,7 @@ function paramHasValue(p) {
|
|
|
38
38
|
exports.paramHasValue = paramHasValue;
|
|
39
39
|
function isFilteredAliasedName(f) {
|
|
40
40
|
for (const prop of Object.keys(f)) {
|
|
41
|
-
if (![
|
|
41
|
+
if (!['name', 'as', 'filterList'].includes(prop)) {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -46,95 +46,95 @@ function isFilteredAliasedName(f) {
|
|
|
46
46
|
}
|
|
47
47
|
exports.isFilteredAliasedName = isFilteredAliasedName;
|
|
48
48
|
function isFilterFragment(f) {
|
|
49
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
49
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'filterExpression';
|
|
50
50
|
}
|
|
51
51
|
exports.isFilterFragment = isFilterFragment;
|
|
52
52
|
function isDialectFragment(f) {
|
|
53
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
53
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'dialect';
|
|
54
54
|
}
|
|
55
55
|
exports.isDialectFragment = isDialectFragment;
|
|
56
56
|
function isAggregateFragment(f) {
|
|
57
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
57
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'aggregate';
|
|
58
58
|
}
|
|
59
59
|
exports.isAggregateFragment = isAggregateFragment;
|
|
60
60
|
function isAsymmetricFragment(f) {
|
|
61
|
-
return isAggregateFragment(f) && [
|
|
61
|
+
return isAggregateFragment(f) && ['sum', 'avg', 'count'].includes(f.function);
|
|
62
62
|
}
|
|
63
63
|
exports.isAsymmetricFragment = isAsymmetricFragment;
|
|
64
64
|
function isUngroupFragment(f) {
|
|
65
65
|
const ftype = f === null || f === void 0 ? void 0 : f.type;
|
|
66
|
-
return ftype
|
|
66
|
+
return ftype === 'all' || ftype === 'exclude';
|
|
67
67
|
}
|
|
68
68
|
exports.isUngroupFragment = isUngroupFragment;
|
|
69
69
|
exports.malloyFunctions = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
row_number: {
|
|
71
|
+
returnType: 'number',
|
|
72
|
+
parameters: 'none',
|
|
73
|
+
expressionType: 'analytic',
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
rank: {
|
|
76
|
+
returnType: 'number',
|
|
77
|
+
parameters: 'none',
|
|
78
|
+
expressionType: 'analytic',
|
|
79
79
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
dense_rank: {
|
|
81
|
+
returnType: 'number',
|
|
82
|
+
parameters: 'none',
|
|
83
|
+
expressionType: 'analytic',
|
|
84
84
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
first_value_in_column: {
|
|
86
|
+
returnType: 'number',
|
|
87
|
+
parameters: 'any',
|
|
88
|
+
expressionType: 'analytic',
|
|
89
|
+
sqlName: 'first_value',
|
|
90
90
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
last_value_in_column: {
|
|
92
|
+
returnType: 'number',
|
|
93
|
+
parameters: 'any',
|
|
94
|
+
expressionType: 'analytic',
|
|
95
|
+
sqlName: 'last_value',
|
|
96
96
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
min_in_column: {
|
|
98
|
+
returnType: 'number',
|
|
99
|
+
parameters: 'any',
|
|
100
|
+
expressionType: 'analytic',
|
|
101
|
+
sqlName: 'min',
|
|
102
102
|
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
max_in_column: {
|
|
104
|
+
returnType: 'number',
|
|
105
|
+
parameters: 'any',
|
|
106
|
+
expressionType: 'analytic',
|
|
107
|
+
sqlName: 'max',
|
|
108
108
|
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
ntile: {
|
|
110
|
+
returnType: 'number',
|
|
111
|
+
parameters: ['nconst'],
|
|
112
|
+
expressionType: 'analytic',
|
|
113
|
+
},
|
|
114
|
+
lag: {
|
|
115
|
+
returnType: 'number',
|
|
116
|
+
parameters: ['number', 'nconst'],
|
|
117
|
+
expressionType: 'analytic',
|
|
113
118
|
},
|
|
114
|
-
"lag": {
|
|
115
|
-
"returnType": "number",
|
|
116
|
-
"parameters": ["number", "nconst"],
|
|
117
|
-
"expressionType": "analytic"
|
|
118
|
-
}
|
|
119
119
|
};
|
|
120
120
|
function isAnalyticFragment(f) {
|
|
121
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
121
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'analytic';
|
|
122
122
|
}
|
|
123
123
|
exports.isAnalyticFragment = isAnalyticFragment;
|
|
124
124
|
function isFieldFragment(f) {
|
|
125
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
125
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'field';
|
|
126
126
|
}
|
|
127
127
|
exports.isFieldFragment = isFieldFragment;
|
|
128
128
|
function isParameterFragment(f) {
|
|
129
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
129
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'parameter';
|
|
130
130
|
}
|
|
131
131
|
exports.isParameterFragment = isParameterFragment;
|
|
132
132
|
function isApplyValue(f) {
|
|
133
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
133
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'applyVal';
|
|
134
134
|
}
|
|
135
135
|
exports.isApplyValue = isApplyValue;
|
|
136
136
|
function isApplyFragment(f) {
|
|
137
|
-
return (f === null || f === void 0 ? void 0 : f.type) ===
|
|
137
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'apply';
|
|
138
138
|
}
|
|
139
139
|
exports.isApplyFragment = isApplyFragment;
|
|
140
140
|
/**
|
|
@@ -155,7 +155,7 @@ function mkExpr(src, ...exprs) {
|
|
|
155
155
|
if (src[index].length > 0) {
|
|
156
156
|
ret.push(src[index]);
|
|
157
157
|
}
|
|
158
|
-
if (typeof el
|
|
158
|
+
if (typeof el === 'string') {
|
|
159
159
|
ret.push(el);
|
|
160
160
|
}
|
|
161
161
|
else {
|
|
@@ -169,20 +169,20 @@ function mkExpr(src, ...exprs) {
|
|
|
169
169
|
}
|
|
170
170
|
exports.mkExpr = mkExpr;
|
|
171
171
|
function expressionIsAggregate(e) {
|
|
172
|
-
return e ===
|
|
172
|
+
return e === 'aggregate';
|
|
173
173
|
}
|
|
174
174
|
exports.expressionIsAggregate = expressionIsAggregate;
|
|
175
175
|
function expressionIsCalculation(e) {
|
|
176
|
-
return e ===
|
|
176
|
+
return e === 'aggregate' || e === 'analytic';
|
|
177
177
|
}
|
|
178
178
|
exports.expressionIsCalculation = expressionIsCalculation;
|
|
179
179
|
function maxExpressionType(e1, e2) {
|
|
180
|
-
let ret =
|
|
181
|
-
if (e1 ===
|
|
182
|
-
ret =
|
|
180
|
+
let ret = 'scalar';
|
|
181
|
+
if (e1 === 'aggregate' || e2 === 'aggregate') {
|
|
182
|
+
ret = 'aggregate';
|
|
183
183
|
}
|
|
184
|
-
if (e1 ===
|
|
185
|
-
ret =
|
|
184
|
+
if (e1 === 'analytic' || e2 === 'analytic') {
|
|
185
|
+
ret = 'analytic';
|
|
186
186
|
}
|
|
187
187
|
return ret;
|
|
188
188
|
}
|
|
@@ -193,18 +193,18 @@ function hasExpression(f) {
|
|
|
193
193
|
}
|
|
194
194
|
exports.hasExpression = hasExpression;
|
|
195
195
|
function isTimeFieldType(s) {
|
|
196
|
-
return s
|
|
196
|
+
return s === 'date' || s === 'timestamp';
|
|
197
197
|
}
|
|
198
198
|
exports.isTimeFieldType = isTimeFieldType;
|
|
199
199
|
function isAtomicFieldType(s) {
|
|
200
200
|
return [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
201
|
+
'string',
|
|
202
|
+
'number',
|
|
203
|
+
'date',
|
|
204
|
+
'timestamp',
|
|
205
|
+
'boolean',
|
|
206
|
+
'json',
|
|
207
|
+
'unsupported',
|
|
208
208
|
].includes(s);
|
|
209
209
|
}
|
|
210
210
|
exports.isAtomicFieldType = isAtomicFieldType;
|
|
@@ -213,8 +213,8 @@ function FieldIsIntrinsic(f) {
|
|
|
213
213
|
if (isAtomicFieldType(f.type) && !hasExpression(f)) {
|
|
214
214
|
return true;
|
|
215
215
|
}
|
|
216
|
-
else if (f.type ===
|
|
217
|
-
(f.structSource.type ===
|
|
216
|
+
else if (f.type === 'struct' &&
|
|
217
|
+
(f.structSource.type === 'inline' || f.structSource.type === 'nested')) {
|
|
218
218
|
return true;
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
@@ -223,15 +223,15 @@ function FieldIsIntrinsic(f) {
|
|
|
223
223
|
}
|
|
224
224
|
exports.FieldIsIntrinsic = FieldIsIntrinsic;
|
|
225
225
|
function isDateUnit(str) {
|
|
226
|
-
return [
|
|
226
|
+
return ['day', 'week', 'month', 'quarter', 'year'].includes(str);
|
|
227
227
|
}
|
|
228
228
|
exports.isDateUnit = isDateUnit;
|
|
229
229
|
function isTimestampUnit(s) {
|
|
230
|
-
return isDateUnit(s) || [
|
|
230
|
+
return isDateUnit(s) || ['hour', 'minute', 'second'].includes(s);
|
|
231
231
|
}
|
|
232
232
|
exports.isTimestampUnit = isTimestampUnit;
|
|
233
233
|
function isExtractUnit(s) {
|
|
234
|
-
return isTimestampUnit(s) || s
|
|
234
|
+
return isTimestampUnit(s) || s === 'day_of_week' || s === 'day_of_year';
|
|
235
235
|
}
|
|
236
236
|
exports.isExtractUnit = isExtractUnit;
|
|
237
237
|
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
@@ -246,26 +246,26 @@ function isByName(by) {
|
|
|
246
246
|
if (by === undefined) {
|
|
247
247
|
return false;
|
|
248
248
|
}
|
|
249
|
-
return by.by ===
|
|
249
|
+
return by.by === 'name';
|
|
250
250
|
}
|
|
251
251
|
exports.isByName = isByName;
|
|
252
252
|
function isByExpression(by) {
|
|
253
253
|
if (by === undefined) {
|
|
254
254
|
return false;
|
|
255
255
|
}
|
|
256
|
-
return by.by ===
|
|
256
|
+
return by.by === 'name';
|
|
257
257
|
}
|
|
258
258
|
exports.isByExpression = isByExpression;
|
|
259
259
|
function refIsStructDef(ref) {
|
|
260
|
-
return typeof ref !==
|
|
260
|
+
return typeof ref !== 'string' && ref.type === 'struct';
|
|
261
261
|
}
|
|
262
262
|
exports.refIsStructDef = refIsStructDef;
|
|
263
263
|
function isReduceSegment(pe) {
|
|
264
|
-
return pe.type ===
|
|
264
|
+
return pe.type === 'reduce';
|
|
265
265
|
}
|
|
266
266
|
exports.isReduceSegment = isReduceSegment;
|
|
267
267
|
function isProjectSegment(pe) {
|
|
268
|
-
return pe.type ===
|
|
268
|
+
return pe.type === 'project';
|
|
269
269
|
}
|
|
270
270
|
exports.isProjectSegment = isProjectSegment;
|
|
271
271
|
function isQuerySegment(pe) {
|
|
@@ -285,11 +285,11 @@ function isSamplingEnable(s) {
|
|
|
285
285
|
}
|
|
286
286
|
exports.isSamplingEnable = isSamplingEnable;
|
|
287
287
|
function isIndexSegment(pe) {
|
|
288
|
-
return pe.type ===
|
|
288
|
+
return pe.type === 'index';
|
|
289
289
|
}
|
|
290
290
|
exports.isIndexSegment = isIndexSegment;
|
|
291
291
|
function isJoinOn(sr) {
|
|
292
|
-
return [
|
|
292
|
+
return ['one', 'many', 'cross'].includes(sr.type);
|
|
293
293
|
}
|
|
294
294
|
exports.isJoinOn = isJoinOn;
|
|
295
295
|
function isSQLFragment(f) {
|
|
@@ -298,24 +298,24 @@ function isSQLFragment(f) {
|
|
|
298
298
|
exports.isSQLFragment = isSQLFragment;
|
|
299
299
|
function isSQLBlock(sd) {
|
|
300
300
|
const src = sd.structSource;
|
|
301
|
-
return src.type
|
|
301
|
+
return src.type === 'sql' && src.method === 'subquery';
|
|
302
302
|
}
|
|
303
303
|
exports.isSQLBlock = isSQLBlock;
|
|
304
304
|
function isFieldTypeDef(f) {
|
|
305
|
-
return (f.type ===
|
|
306
|
-
f.type ===
|
|
307
|
-
f.type ===
|
|
308
|
-
f.type ===
|
|
309
|
-
f.type ===
|
|
310
|
-
f.type ===
|
|
305
|
+
return (f.type === 'string' ||
|
|
306
|
+
f.type === 'date' ||
|
|
307
|
+
f.type === 'number' ||
|
|
308
|
+
f.type === 'timestamp' ||
|
|
309
|
+
f.type === 'boolean' ||
|
|
310
|
+
f.type === 'json');
|
|
311
311
|
}
|
|
312
312
|
exports.isFieldTypeDef = isFieldTypeDef;
|
|
313
313
|
function isFieldTimeBased(f) {
|
|
314
|
-
return f.type ===
|
|
314
|
+
return f.type === 'date' || f.type === 'timestamp';
|
|
315
315
|
}
|
|
316
316
|
exports.isFieldTimeBased = isFieldTimeBased;
|
|
317
317
|
function isFieldStructDef(f) {
|
|
318
|
-
return f.type ===
|
|
318
|
+
return f.type === 'struct';
|
|
319
319
|
}
|
|
320
320
|
exports.isFieldStructDef = isFieldStructDef;
|
|
321
321
|
/** Get the output name for a NamedObject */
|
|
@@ -327,13 +327,13 @@ function getIdentifier(n) {
|
|
|
327
327
|
}
|
|
328
328
|
exports.getIdentifier = getIdentifier;
|
|
329
329
|
function isTurtleDef(def) {
|
|
330
|
-
return def.type ===
|
|
330
|
+
return def.type === 'turtle';
|
|
331
331
|
}
|
|
332
332
|
exports.isTurtleDef = isTurtleDef;
|
|
333
333
|
function isDimensional(field) {
|
|
334
334
|
var _a;
|
|
335
|
-
if (
|
|
336
|
-
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) ===
|
|
335
|
+
if ('resultMetadata' in field) {
|
|
336
|
+
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'dimension';
|
|
337
337
|
}
|
|
338
338
|
return false;
|
|
339
339
|
}
|
|
@@ -341,8 +341,8 @@ exports.isDimensional = isDimensional;
|
|
|
341
341
|
function isPhysical(field) {
|
|
342
342
|
return ((isFieldTypeDef(field) && field.e === undefined) ||
|
|
343
343
|
(isFieldStructDef(field) &&
|
|
344
|
-
(field.structSource.type ===
|
|
345
|
-
field.structSource.type
|
|
344
|
+
(field.structSource.type === 'nested' ||
|
|
345
|
+
field.structSource.type === 'inline')));
|
|
346
346
|
}
|
|
347
347
|
exports.isPhysical = isPhysical;
|
|
348
348
|
function getDimensions(structDef) {
|
|
@@ -355,31 +355,31 @@ function getPhysicalFields(structDef) {
|
|
|
355
355
|
exports.getPhysicalFields = getPhysicalFields;
|
|
356
356
|
function isMeasureLike(field) {
|
|
357
357
|
var _a, _b;
|
|
358
|
-
if (
|
|
359
|
-
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) ===
|
|
360
|
-
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) ===
|
|
358
|
+
if ('resultMetadata' in field) {
|
|
359
|
+
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'measure' ||
|
|
360
|
+
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === 'struct');
|
|
361
361
|
}
|
|
362
362
|
return false;
|
|
363
363
|
}
|
|
364
364
|
exports.isMeasureLike = isMeasureLike;
|
|
365
365
|
function isValueString(value, field) {
|
|
366
|
-
return field.type ===
|
|
366
|
+
return field.type === 'string';
|
|
367
367
|
}
|
|
368
368
|
exports.isValueString = isValueString;
|
|
369
369
|
function isValueNumber(value, field) {
|
|
370
|
-
return field.type ===
|
|
370
|
+
return field.type === 'number';
|
|
371
371
|
}
|
|
372
372
|
exports.isValueNumber = isValueNumber;
|
|
373
373
|
function isValueBoolean(value, field) {
|
|
374
|
-
return field.type ===
|
|
374
|
+
return field.type === 'boolean';
|
|
375
375
|
}
|
|
376
376
|
exports.isValueBoolean = isValueBoolean;
|
|
377
377
|
function isValueTimestamp(value, field) {
|
|
378
|
-
return field.type ===
|
|
378
|
+
return field.type === 'timestamp';
|
|
379
379
|
}
|
|
380
380
|
exports.isValueTimestamp = isValueTimestamp;
|
|
381
381
|
function isValueDate(value, field) {
|
|
382
|
-
return field.type ===
|
|
382
|
+
return field.type === 'date';
|
|
383
383
|
}
|
|
384
384
|
exports.isValueDate = isValueDate;
|
|
385
385
|
// clang-format on
|
package/dist/model/sql_block.js
CHANGED
|
@@ -32,8 +32,8 @@ const utils_1 = require("./utils");
|
|
|
32
32
|
*/
|
|
33
33
|
function makeSQLBlock(select, connection) {
|
|
34
34
|
const theBlock = {
|
|
35
|
-
|
|
36
|
-
select
|
|
35
|
+
name: `md5:/${connection || '$default'}//${nameFor(select)}`,
|
|
36
|
+
select,
|
|
37
37
|
};
|
|
38
38
|
if (connection) {
|
|
39
39
|
theBlock.connection = connection;
|
|
@@ -50,7 +50,7 @@ exports.makeSQLBlock = makeSQLBlock;
|
|
|
50
50
|
// here for later, and that the whole "how to determine the name of a query"
|
|
51
51
|
// algorithm needs to change
|
|
52
52
|
function nameFor(select) {
|
|
53
|
-
const phrases = select.map(
|
|
54
|
-
return (0, utils_1.generateHash)(phrases.join(
|
|
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
55
|
}
|
|
56
56
|
//# sourceMappingURL=sql_block.js.map
|
package/dist/model/utils.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ export declare class AndChain {
|
|
|
17
17
|
empty(): boolean;
|
|
18
18
|
present(): boolean;
|
|
19
19
|
sqlOr(): string;
|
|
20
|
-
sql(whereOrHaving?:
|
|
20
|
+
sql(whereOrHaving?: 'where' | 'having'): string;
|
|
21
21
|
}
|
|
22
22
|
export declare function generateHash(input: string): string;
|
package/dist/model/utils.js
CHANGED
|
@@ -31,14 +31,14 @@ const md5_1 = __importDefault(require("md5"));
|
|
|
31
31
|
function indent(s) {
|
|
32
32
|
const re = /(^|\n)/g;
|
|
33
33
|
const lastNewline = /\n {2}$/;
|
|
34
|
-
return s.replace(re,
|
|
34
|
+
return s.replace(re, '$1 ').replace(lastNewline, '\n');
|
|
35
35
|
}
|
|
36
36
|
exports.indent = indent;
|
|
37
37
|
/**
|
|
38
38
|
* Generate a SQL string literal from a given `input` string, safe, e.g., to be used in `WHERE` clauses.
|
|
39
39
|
*/
|
|
40
40
|
function generateSQLStringLiteral(input) {
|
|
41
|
-
const escapedString = input.replace(/\\/g,
|
|
41
|
+
const escapedString = input.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
42
42
|
return `'${escapedString}'`;
|
|
43
43
|
}
|
|
44
44
|
exports.generateSQLStringLiteral = generateSQLStringLiteral;
|
|
@@ -74,24 +74,24 @@ class AndChain {
|
|
|
74
74
|
}
|
|
75
75
|
sqlOr() {
|
|
76
76
|
if (this.empty()) {
|
|
77
|
-
return
|
|
77
|
+
return '';
|
|
78
78
|
}
|
|
79
|
-
return this.clauses.map(
|
|
79
|
+
return this.clauses.map(c => `(${c})`).join('OR ') + '\n';
|
|
80
80
|
}
|
|
81
81
|
sql(whereOrHaving) {
|
|
82
82
|
if (this.empty()) {
|
|
83
|
-
return
|
|
83
|
+
return '';
|
|
84
84
|
}
|
|
85
|
-
let prefix =
|
|
86
|
-
let postfix =
|
|
85
|
+
let prefix = '';
|
|
86
|
+
let postfix = '';
|
|
87
87
|
if (whereOrHaving) {
|
|
88
|
-
prefix = whereOrHaving.toUpperCase() +
|
|
89
|
-
postfix =
|
|
88
|
+
prefix = whereOrHaving.toUpperCase() + ' ';
|
|
89
|
+
postfix = '\n';
|
|
90
90
|
}
|
|
91
91
|
if (this.clauses.length === 1) {
|
|
92
92
|
return prefix + this.clauses[0] + postfix;
|
|
93
93
|
}
|
|
94
|
-
return prefix + this.clauses.map(
|
|
94
|
+
return prefix + this.clauses.map(c => `(${c})`).join('\nAND ') + postfix;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
exports.AndChain = AndChain;
|
package/dist/runtime_types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RunSQLOptions } from
|
|
2
|
-
import { MalloyQueryData, QueryDataRow, SQLBlock, StructDef } from
|
|
1
|
+
import { RunSQLOptions } from './run_sql_options';
|
|
2
|
+
import { MalloyQueryData, QueryDataRow, SQLBlock, StructDef } from './model/malloy_types';
|
|
3
3
|
/**
|
|
4
4
|
* The contents of a Malloy query document.
|
|
5
5
|
*/
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.24-
|
|
3
|
+
"version": "0.0.24-dev230228224434",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"homepage": "https://github.com/malloydata/malloy#readme",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=10"
|
|
10
|
+
},
|
|
8
11
|
"repository": {
|
|
9
12
|
"type": "git",
|
|
10
13
|
"url": "https://github.com/malloydata/malloy"
|