@malloydata/malloy 0.0.24-dev230224184907 → 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
|
@@ -27,43 +27,43 @@ const utils_1 = require("../model/utils");
|
|
|
27
27
|
const malloy_types_1 = require("../model/malloy_types");
|
|
28
28
|
const dialect_1 = require("./dialect");
|
|
29
29
|
const castMap = {
|
|
30
|
-
|
|
30
|
+
number: 'float64',
|
|
31
31
|
};
|
|
32
32
|
// These are the units that "TIMESTAMP_ADD" accepts
|
|
33
33
|
const timestampAddUnits = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
'microsecond',
|
|
35
|
+
'millisecond',
|
|
36
|
+
'second',
|
|
37
|
+
'minute',
|
|
38
|
+
'hour',
|
|
39
|
+
'day',
|
|
40
40
|
];
|
|
41
41
|
const extractMap = {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
day_of_week: 'dayofweek',
|
|
43
|
+
day_of_year: 'dayofyear',
|
|
44
44
|
};
|
|
45
45
|
class StandardSQLDialect extends dialect_1.Dialect {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
|
-
this.name =
|
|
49
|
-
this.defaultNumberType =
|
|
50
|
-
this.udfPrefix =
|
|
48
|
+
this.name = 'standardsql';
|
|
49
|
+
this.defaultNumberType = 'FLOAT64';
|
|
50
|
+
this.udfPrefix = '__udf';
|
|
51
51
|
this.hasFinalStage = false;
|
|
52
|
-
this.stringTypeName =
|
|
52
|
+
this.stringTypeName = 'STRING';
|
|
53
53
|
this.divisionIsInteger = false;
|
|
54
54
|
this.supportsSumDistinctFunction = false;
|
|
55
55
|
this.unnestWithNumbers = false;
|
|
56
|
-
this.defaultSampling = {
|
|
56
|
+
this.defaultSampling = { enable: false };
|
|
57
57
|
this.supportUnnestArrayAgg = false;
|
|
58
58
|
this.supportsCTEinCoorelatedSubQueries = false;
|
|
59
59
|
this.dontUnionIndex = true; // bigquery can't use a sample table more than once in a query.
|
|
60
60
|
this.supportsQualify = true;
|
|
61
61
|
// I think we want an optional list of parameters types that we force a cast to.
|
|
62
62
|
this.functionInfo = {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
timestamp_seconds: {
|
|
64
|
+
returnType: 'timestamp',
|
|
65
65
|
},
|
|
66
|
-
|
|
66
|
+
concat: { returnType: 'string' },
|
|
67
67
|
};
|
|
68
68
|
this.keywords = `
|
|
69
69
|
ALL
|
|
@@ -173,19 +173,19 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
173
173
|
}
|
|
174
174
|
// can array agg or any_value a struct...
|
|
175
175
|
sqlAggregateTurtle(groupSet, fieldList, orderBy, limit) {
|
|
176
|
-
let tail =
|
|
176
|
+
let tail = '';
|
|
177
177
|
if (limit !== undefined) {
|
|
178
178
|
tail += ` LIMIT ${limit}`;
|
|
179
179
|
}
|
|
180
180
|
const fields = fieldList
|
|
181
|
-
.map(
|
|
182
|
-
.join(
|
|
181
|
+
.map(f => `\n ${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
182
|
+
.join(', ');
|
|
183
183
|
return `ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}\n ) END IGNORE NULLS ${orderBy} ${tail})`;
|
|
184
184
|
}
|
|
185
185
|
sqlAnyValueTurtle(groupSet, fieldList) {
|
|
186
186
|
const fields = fieldList
|
|
187
|
-
.map(
|
|
188
|
-
.join(
|
|
187
|
+
.map(f => `${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
188
|
+
.join(', ');
|
|
189
189
|
return `ANY_VALUE(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}))`;
|
|
190
190
|
}
|
|
191
191
|
sqlAnyValueLastTurtle(name, groupSet, sqlName) {
|
|
@@ -193,11 +193,11 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
193
193
|
}
|
|
194
194
|
sqlCoaleseMeasuresInline(groupSet, fieldList) {
|
|
195
195
|
const fields = fieldList
|
|
196
|
-
.map(
|
|
197
|
-
.join(
|
|
196
|
+
.map(f => `${f.sqlExpression} as ${f.sqlOutputName}`)
|
|
197
|
+
.join(', ');
|
|
198
198
|
const nullValues = fieldList
|
|
199
|
-
.map(
|
|
200
|
-
.join(
|
|
199
|
+
.map(f => `NULL as ${f.sqlOutputName}`)
|
|
200
|
+
.join(', ');
|
|
201
201
|
return `COALESCE(ANY_VALUE(CASE WHEN group_set=${groupSet} THEN STRUCT(${fields}) END), STRUCT(${nullValues}))`;
|
|
202
202
|
}
|
|
203
203
|
//
|
|
@@ -228,11 +228,11 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
228
228
|
const upperPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 1, 15)) as int64) as numeric) * 4294967296`;
|
|
229
229
|
const lowerPart = `cast(cast(concat('0x', substr(to_hex(md5(${sqlDistinctKey})), 16, 8)) as int64) as numeric)`;
|
|
230
230
|
// See the comment below on `sql_sum_distinct` for why we multiply by this decimal
|
|
231
|
-
const precisionShiftMultiplier =
|
|
231
|
+
const precisionShiftMultiplier = '0.000000001';
|
|
232
232
|
return `(${upperPart} + ${lowerPart}) * ${precisionShiftMultiplier}`;
|
|
233
233
|
}
|
|
234
234
|
sqlGenerateUUID() {
|
|
235
|
-
return
|
|
235
|
+
return 'GENERATE_UUID()';
|
|
236
236
|
}
|
|
237
237
|
sqlFieldReference(alias, fieldName, _fieldType, _isNested, _isArray) {
|
|
238
238
|
return `${alias}.${fieldName}`;
|
|
@@ -266,14 +266,14 @@ ${(0, utils_1.indent)(sql)}
|
|
|
266
266
|
}
|
|
267
267
|
sqlMaybeQuoteIdentifier(identifier) {
|
|
268
268
|
return this.keywords.indexOf(identifier.toUpperCase()) > 0
|
|
269
|
-
?
|
|
269
|
+
? '`' + identifier + '`'
|
|
270
270
|
: identifier;
|
|
271
271
|
}
|
|
272
272
|
sqlNow() {
|
|
273
273
|
return (0, malloy_types_1.mkExpr) `CURRENT_TIMESTAMP()`;
|
|
274
274
|
}
|
|
275
275
|
sqlTrunc(sqlTime, units) {
|
|
276
|
-
if (sqlTime.valueType
|
|
276
|
+
if (sqlTime.valueType === 'date') {
|
|
277
277
|
if ((0, malloy_types_1.isDateUnit)(units)) {
|
|
278
278
|
return (0, malloy_types_1.mkExpr) `DATE_TRUNC(${sqlTime.value},${units})`;
|
|
279
279
|
}
|
|
@@ -288,35 +288,35 @@ ${(0, utils_1.indent)(sql)}
|
|
|
288
288
|
sqlAlterTime(op, expr, n, timeframe) {
|
|
289
289
|
let theTime = expr.value;
|
|
290
290
|
let computeType = expr.valueType;
|
|
291
|
-
if (timeframe
|
|
291
|
+
if (timeframe !== 'day' && timestampAddUnits.includes(timeframe)) {
|
|
292
292
|
// The units must be done in timestamp, no matter the input type
|
|
293
|
-
computeType =
|
|
294
|
-
if (expr.valueType
|
|
293
|
+
computeType = 'timestamp';
|
|
294
|
+
if (expr.valueType !== 'timestamp') {
|
|
295
295
|
theTime = (0, malloy_types_1.mkExpr) `TIMESTAMP(${theTime})`;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
else if (expr.valueType
|
|
298
|
+
else if (expr.valueType === 'timestamp') {
|
|
299
299
|
theTime = (0, malloy_types_1.mkExpr) `DATETIME(${theTime})`;
|
|
300
|
-
computeType =
|
|
300
|
+
computeType = 'datetime';
|
|
301
301
|
}
|
|
302
|
-
const funcName = computeType.toUpperCase() + (op
|
|
302
|
+
const funcName = computeType.toUpperCase() + (op === '+' ? '_ADD' : '_SUB');
|
|
303
303
|
const newTime = (0, malloy_types_1.mkExpr) `${funcName}(${theTime}, INTERVAL ${n} ${timeframe})`;
|
|
304
|
-
return computeType
|
|
304
|
+
return computeType === 'datetime' ? (0, malloy_types_1.mkExpr) `TIMESTAMP(${newTime})` : newTime;
|
|
305
305
|
}
|
|
306
306
|
ignoreInProject(fieldName) {
|
|
307
|
-
return fieldName ===
|
|
307
|
+
return fieldName === '_PARTITIONTIME';
|
|
308
308
|
}
|
|
309
309
|
sqlCast(cast) {
|
|
310
310
|
if (cast.srcType !== cast.dstType) {
|
|
311
311
|
const dstType = castMap[cast.dstType] || cast.dstType;
|
|
312
312
|
// This just makes the code look a little prettier ...
|
|
313
313
|
if (!cast.safe && cast.srcType && (0, malloy_types_1.isTimeFieldType)(cast.srcType)) {
|
|
314
|
-
if (dstType
|
|
314
|
+
if (dstType === 'date') {
|
|
315
315
|
return (0, malloy_types_1.mkExpr) `DATE(${cast.expr})`;
|
|
316
316
|
}
|
|
317
317
|
return (0, malloy_types_1.mkExpr) `TIMESTAMP(${cast.expr})`;
|
|
318
318
|
}
|
|
319
|
-
const castFunc = cast.safe ?
|
|
319
|
+
const castFunc = cast.safe ? 'SAFE_CAST' : 'CAST';
|
|
320
320
|
return (0, malloy_types_1.mkExpr) `${castFunc}(${cast.expr} AS ${dstType})`;
|
|
321
321
|
}
|
|
322
322
|
return cast.expr;
|
|
@@ -325,10 +325,10 @@ ${(0, utils_1.indent)(sql)}
|
|
|
325
325
|
return (0, malloy_types_1.mkExpr) `REGEXP_CONTAINS(${expr}, r${regexp})`;
|
|
326
326
|
}
|
|
327
327
|
sqlLiteralTime(timeString, type, timezone) {
|
|
328
|
-
if (type ===
|
|
328
|
+
if (type === 'date') {
|
|
329
329
|
return `DATE('${timeString}')`;
|
|
330
330
|
}
|
|
331
|
-
else if (type ===
|
|
331
|
+
else if (type === 'timestamp') {
|
|
332
332
|
return `TIMESTAMP('${timeString}', '${timezone}')`;
|
|
333
333
|
}
|
|
334
334
|
else {
|
|
@@ -338,21 +338,21 @@ ${(0, utils_1.indent)(sql)}
|
|
|
338
338
|
sqlMeasureTime(from, to, units) {
|
|
339
339
|
let lVal = from.value;
|
|
340
340
|
let rVal = to.value;
|
|
341
|
-
let diffUsing =
|
|
342
|
-
if (units
|
|
343
|
-
if (from.valueType
|
|
341
|
+
let diffUsing = 'TIMESTAMP_DIFF';
|
|
342
|
+
if (units === 'second' || units === 'minute' || units === 'hour') {
|
|
343
|
+
if (from.valueType !== 'timestamp') {
|
|
344
344
|
lVal = (0, malloy_types_1.mkExpr) `TIMESTAMP(${lVal})`;
|
|
345
345
|
}
|
|
346
|
-
if (to.valueType
|
|
346
|
+
if (to.valueType !== 'timestamp') {
|
|
347
347
|
rVal = (0, malloy_types_1.mkExpr) `TIMESTAMP(${rVal})`;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
else {
|
|
351
|
-
diffUsing =
|
|
352
|
-
if (from.valueType
|
|
351
|
+
diffUsing = 'DATE_DIFF';
|
|
352
|
+
if (from.valueType !== 'date') {
|
|
353
353
|
lVal = (0, malloy_types_1.mkExpr) `DATE(${lVal})`;
|
|
354
354
|
}
|
|
355
|
-
if (to.valueType
|
|
355
|
+
if (to.valueType !== 'date') {
|
|
356
356
|
rVal = (0, malloy_types_1.mkExpr) `DATE(${rVal})`;
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -364,7 +364,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
364
364
|
sample = this.defaultSampling;
|
|
365
365
|
}
|
|
366
366
|
if ((0, malloy_types_1.isSamplingRows)(sample)) {
|
|
367
|
-
throw new Error(
|
|
367
|
+
throw new Error("StandardSQL doesn't support sampling by rows only percent");
|
|
368
368
|
}
|
|
369
369
|
else if ((0, malloy_types_1.isSamplingPercent)(sample)) {
|
|
370
370
|
return `(SELECT * FROM ${tableSQL} TABLESAMPLE SYSTEM (${sample.percent} PERCENT))`;
|
|
@@ -373,7 +373,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
373
373
|
return tableSQL;
|
|
374
374
|
}
|
|
375
375
|
sqlLiteralString(literal) {
|
|
376
|
-
const noVirgule = literal.replace(/\\/g,
|
|
376
|
+
const noVirgule = literal.replace(/\\/g, '\\\\');
|
|
377
377
|
return "'" + noVirgule.replace(/'/g, "\\'") + "'";
|
|
378
378
|
}
|
|
379
379
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +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
|
|
2
|
-
export { Segment, isFilteredAliasedName, flattenQuery, expressionIsCalculation } from
|
|
3
|
-
export { HighlightType, MalloyTranslator } from
|
|
4
|
-
export type { LogMessage, TranslateResponse } from
|
|
5
|
-
export { Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, Result, parseTableURI, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter } from
|
|
6
|
-
export type { Explore, Model, PreparedQuery, PreparedResult, Field, AtomicField, ExploreField, QueryField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, ModelMaterializer, DocumentSymbol, DocumentHighlight, ResultJSON, PreparedResultMaterializer, SQLBlockMaterializer, ExploreMaterializer, WriteStream } from
|
|
7
|
-
export type { RunSQLOptions } from
|
|
8
|
-
export type { URLReader, InfoConnection, LookupConnection, Connection, QueryString, ModelString, QueryURL, ModelURL, PooledConnection, TestableConnection, PersistSQLResults, StreamingConnection } from
|
|
9
|
-
export type { Loggable } from
|
|
10
|
-
export { toAsyncGenerator } from
|
|
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, Parse, 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';
|
|
@@ -33,9 +33,9 @@ exports.errorFor = void 0;
|
|
|
33
33
|
*/
|
|
34
34
|
function errorFor(reason) {
|
|
35
35
|
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
dataType: 'unknown',
|
|
37
|
+
expressionType: 'scalar',
|
|
38
|
+
value: [`_ERROR_${reason.replace(/ /g, '_')}`],
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
exports.errorFor = errorFor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ModelDataRequest } from
|
|
2
|
-
import { DocStatement, Document, MalloyElement, RunList } from
|
|
3
|
-
import { QueryElement } from
|
|
1
|
+
import { ModelDataRequest } from '../../translate-response';
|
|
2
|
+
import { DocStatement, Document, MalloyElement, RunList } from '../types/malloy-element';
|
|
3
|
+
import { QueryElement } from '../types/query-element';
|
|
4
4
|
export declare class DefineQuery extends MalloyElement implements DocStatement {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly queryDetails: QueryElement;
|
|
@@ -26,17 +26,17 @@ exports.DefineQueryList = exports.DefineQuery = void 0;
|
|
|
26
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
27
27
|
class DefineQuery extends malloy_element_1.MalloyElement {
|
|
28
28
|
constructor(name, queryDetails) {
|
|
29
|
-
super({
|
|
29
|
+
super({ queryDetails: queryDetails });
|
|
30
30
|
this.name = name;
|
|
31
31
|
this.queryDetails = queryDetails;
|
|
32
|
-
this.elementType =
|
|
32
|
+
this.elementType = 'defineQuery';
|
|
33
33
|
}
|
|
34
34
|
execute(doc) {
|
|
35
35
|
const entry = {
|
|
36
36
|
...this.queryDetails.query(),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
type: 'query',
|
|
38
|
+
name: this.name,
|
|
39
|
+
location: this.location,
|
|
40
40
|
};
|
|
41
41
|
const exported = false;
|
|
42
42
|
doc.setEntry(this.name, { entry, exported });
|
|
@@ -46,7 +46,7 @@ class DefineQuery extends malloy_element_1.MalloyElement {
|
|
|
46
46
|
exports.DefineQuery = DefineQuery;
|
|
47
47
|
class DefineQueryList extends malloy_element_1.RunList {
|
|
48
48
|
constructor(queryList) {
|
|
49
|
-
super(
|
|
49
|
+
super('defineQueries', queryList);
|
|
50
50
|
}
|
|
51
51
|
execute(doc) {
|
|
52
52
|
return this.executeList(doc);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModelDataRequest } from
|
|
2
|
-
import { HasParameter } from
|
|
3
|
-
import { DocStatement, Document, MalloyElement, RunList } from
|
|
4
|
-
import { Source } from
|
|
1
|
+
import { ModelDataRequest } from '../../translate-response';
|
|
2
|
+
import { HasParameter } from '../parameters/has-parameter';
|
|
3
|
+
import { DocStatement, Document, MalloyElement, RunList } from '../types/malloy-element';
|
|
4
|
+
import { Source } from './source';
|
|
5
5
|
export declare class DefineSource extends MalloyElement implements DocStatement {
|
|
6
6
|
readonly name: string;
|
|
7
7
|
readonly theSource: Source;
|
|
@@ -28,11 +28,11 @@ const has_parameter_1 = require("../parameters/has-parameter");
|
|
|
28
28
|
const malloy_element_1 = require("../types/malloy-element");
|
|
29
29
|
class DefineSource extends malloy_element_1.MalloyElement {
|
|
30
30
|
constructor(name, theSource, exported, params) {
|
|
31
|
-
super({
|
|
31
|
+
super({ explore: theSource });
|
|
32
32
|
this.name = name;
|
|
33
33
|
this.theSource = theSource;
|
|
34
34
|
this.exported = exported;
|
|
35
|
-
this.elementType =
|
|
35
|
+
this.elementType = 'defineSource';
|
|
36
36
|
if (params) {
|
|
37
37
|
this.parameters = [];
|
|
38
38
|
for (const el of params) {
|
|
@@ -43,7 +43,7 @@ class DefineSource extends malloy_element_1.MalloyElement {
|
|
|
43
43
|
this.log(`Unexpected element type in define statement: ${el.elementType}`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
this.has({
|
|
46
|
+
this.has({ parameters: this.parameters });
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
execute(doc) {
|
|
@@ -56,12 +56,12 @@ class DefineSource extends malloy_element_1.MalloyElement {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
doc.setEntry(this.name, {
|
|
59
|
-
|
|
59
|
+
entry: {
|
|
60
60
|
...structDef,
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
as: this.name,
|
|
62
|
+
location: this.location,
|
|
63
63
|
},
|
|
64
|
-
|
|
64
|
+
exported: this.exported,
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -69,7 +69,7 @@ class DefineSource extends malloy_element_1.MalloyElement {
|
|
|
69
69
|
exports.DefineSource = DefineSource;
|
|
70
70
|
class DefineSourceList extends malloy_element_1.RunList {
|
|
71
71
|
constructor(sourceList) {
|
|
72
|
-
super(
|
|
72
|
+
super('defineSources', sourceList);
|
|
73
73
|
}
|
|
74
74
|
execute(doc) {
|
|
75
75
|
return this.executeList(doc);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModelDataRequest } from
|
|
2
|
-
import { DocStatement, Document, MalloyElement } from
|
|
1
|
+
import { ModelDataRequest } from '../../translate-response';
|
|
2
|
+
import { DocStatement, Document, MalloyElement } from '../types/malloy-element';
|
|
3
3
|
export declare class ImportStatement extends MalloyElement implements DocStatement {
|
|
4
4
|
readonly url: string;
|
|
5
5
|
elementType: string;
|
|
@@ -36,22 +36,22 @@ class ImportStatement extends malloy_element_1.MalloyElement {
|
|
|
36
36
|
constructor(url, baseURL) {
|
|
37
37
|
super();
|
|
38
38
|
this.url = url;
|
|
39
|
-
this.elementType =
|
|
39
|
+
this.elementType = 'import statement';
|
|
40
40
|
try {
|
|
41
41
|
this.fullURL = decodeURI(new URL(url, baseURL).toString());
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
this.log(
|
|
44
|
+
this.log('Invalid URI in import statement');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
execute(doc) {
|
|
48
48
|
const trans = this.translator();
|
|
49
49
|
if (!trans) {
|
|
50
|
-
this.log(
|
|
50
|
+
this.log('Cannot import without translation context');
|
|
51
51
|
}
|
|
52
52
|
else if (this.fullURL) {
|
|
53
53
|
const src = trans.root.importZone.getEntry(this.fullURL);
|
|
54
|
-
if (src.status ===
|
|
54
|
+
if (src.status === 'present') {
|
|
55
55
|
const childNeeds = trans.childRequest(this.fullURL);
|
|
56
56
|
if (childNeeds) {
|
|
57
57
|
return childNeeds;
|
|
@@ -59,12 +59,12 @@ class ImportStatement extends malloy_element_1.MalloyElement {
|
|
|
59
59
|
const importStructs = trans.getChildExports(this.fullURL);
|
|
60
60
|
for (const importing in importStructs) {
|
|
61
61
|
doc.setEntry(importing, {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
entry: importStructs[importing],
|
|
63
|
+
exported: false,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
else if (src.status ===
|
|
67
|
+
else if (src.status === 'error') {
|
|
68
68
|
this.log(`import failed: '${src.message}'`);
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DocumentLocation, PipeSegment, Pipeline, StructDef } from
|
|
2
|
-
import { FieldSpace } from
|
|
3
|
-
import { MalloyElement } from
|
|
4
|
-
import { QOPDesc } from
|
|
5
|
-
import { QueryInputSpace } from
|
|
1
|
+
import { DocumentLocation, PipeSegment, Pipeline, StructDef } from '../../../model/malloy_types';
|
|
2
|
+
import { FieldSpace } from '../types/field-space';
|
|
3
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
4
|
+
import { QOPDesc } from '../query-properties/qop-desc';
|
|
5
|
+
import { QueryInputSpace } from '../field-space/query-spaces';
|
|
6
6
|
interface AppendResult {
|
|
7
7
|
opList: PipeSegment[];
|
|
8
8
|
structDef: StructDef;
|
|
@@ -33,32 +33,32 @@ const struct_utils_1 = require("../struct-utils");
|
|
|
33
33
|
class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
34
34
|
constructor() {
|
|
35
35
|
super(...arguments);
|
|
36
|
-
this.elementType =
|
|
36
|
+
this.elementType = 'pipelineDesc';
|
|
37
37
|
this.qops = [];
|
|
38
38
|
}
|
|
39
39
|
refineHead(refinement) {
|
|
40
40
|
this.headRefinement = refinement;
|
|
41
|
-
this.has({
|
|
41
|
+
this.has({ headRefinement: refinement });
|
|
42
42
|
}
|
|
43
43
|
addSegments(...segDesc) {
|
|
44
44
|
this.qops.push(...segDesc);
|
|
45
|
-
this.has({
|
|
45
|
+
this.has({ segments: this.qops });
|
|
46
46
|
}
|
|
47
47
|
appendOps(modelPipe, existingEndSpace) {
|
|
48
48
|
let nextFS = existingEndSpace;
|
|
49
49
|
let returnPipe;
|
|
50
50
|
for (const qop of this.qops) {
|
|
51
|
-
const qopIsNested = modelPipe.length
|
|
51
|
+
const qopIsNested = modelPipe.length === 0;
|
|
52
52
|
const next = qop.getOp(nextFS, qopIsNested ? this : null);
|
|
53
|
-
if (returnPipe
|
|
53
|
+
if (returnPipe === undefined) {
|
|
54
54
|
returnPipe = [...modelPipe];
|
|
55
55
|
}
|
|
56
56
|
returnPipe.push(next.segment);
|
|
57
57
|
nextFS = next.outputSpace();
|
|
58
58
|
}
|
|
59
59
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
opList: returnPipe || modelPipe,
|
|
61
|
+
structDef: nextFS.structDef(),
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
refinePipeline(fs, modelPipe) {
|
|
@@ -67,7 +67,7 @@ class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
|
67
67
|
}
|
|
68
68
|
const pipeline = [];
|
|
69
69
|
if (modelPipe.pipeHead) {
|
|
70
|
-
const {
|
|
70
|
+
const { pipeline: turtlePipe } = this.expandTurtle(modelPipe.pipeHead.name, fs.structDef());
|
|
71
71
|
pipeline.push(...turtlePipe);
|
|
72
72
|
}
|
|
73
73
|
pipeline.push(...modelPipe.pipeline);
|
|
@@ -83,13 +83,13 @@ class PipelineDesc extends malloy_element_1.MalloyElement {
|
|
|
83
83
|
if (!turtle) {
|
|
84
84
|
this.log(`Query '${turtleName}' is not defined in source`);
|
|
85
85
|
}
|
|
86
|
-
else if (turtle.type !==
|
|
86
|
+
else if (turtle.type !== 'turtle') {
|
|
87
87
|
this.log(`'${turtleName}' is not a query`);
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
return {
|
|
90
|
+
return { pipeline: turtle.pipeline, location: turtle.location };
|
|
91
91
|
}
|
|
92
|
-
return {
|
|
92
|
+
return { pipeline: [], location: undefined };
|
|
93
93
|
}
|
|
94
94
|
getOutputStruct(walkStruct, pipeline) {
|
|
95
95
|
for (const modelQop of pipeline) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { StructDef } from
|
|
2
|
-
import { HasParameter } from
|
|
3
|
-
import { ExploreDesc } from
|
|
4
|
-
import { Source } from
|
|
1
|
+
import { StructDef } from '../../../model/malloy_types';
|
|
2
|
+
import { HasParameter } from '../parameters/has-parameter';
|
|
3
|
+
import { ExploreDesc } from '../types/explore-desc';
|
|
4
|
+
import { Source } from './source';
|
|
5
5
|
/**
|
|
6
6
|
* A Source made from a source reference and a set of refinements
|
|
7
7
|
*/
|
|
@@ -42,10 +42,10 @@ const source_1 = require("./source");
|
|
|
42
42
|
*/
|
|
43
43
|
class RefinedSource extends source_1.Source {
|
|
44
44
|
constructor(source, refinement) {
|
|
45
|
-
super({
|
|
45
|
+
super({ source: source, refinement: refinement });
|
|
46
46
|
this.source = source;
|
|
47
47
|
this.refinement = refinement;
|
|
48
|
-
this.elementType =
|
|
48
|
+
this.elementType = 'refinedSource';
|
|
49
49
|
}
|
|
50
50
|
structDef() {
|
|
51
51
|
return this.withParameters([]);
|
|
@@ -59,15 +59,15 @@ class RefinedSource extends source_1.Source {
|
|
|
59
59
|
const errTo = el;
|
|
60
60
|
if (el instanceof primary_key_1.PrimaryKey) {
|
|
61
61
|
if (primaryKey) {
|
|
62
|
-
primaryKey.log(
|
|
63
|
-
el.log(
|
|
62
|
+
primaryKey.log('Primary key already defined');
|
|
63
|
+
el.log('Primary key redefined');
|
|
64
64
|
}
|
|
65
65
|
primaryKey = el;
|
|
66
66
|
}
|
|
67
67
|
else if (el instanceof field_list_edit_1.FieldListEdit) {
|
|
68
68
|
if (fieldListEdit) {
|
|
69
|
-
fieldListEdit.log(
|
|
70
|
-
el.log(
|
|
69
|
+
fieldListEdit.log('Too many accept/except statements');
|
|
70
|
+
el.log('Too many accept/except statements');
|
|
71
71
|
}
|
|
72
72
|
fieldListEdit = el;
|
|
73
73
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StructDef, StructRef } from
|
|
2
|
-
import { MalloyElement } from
|
|
3
|
-
import { HasParameter } from
|
|
1
|
+
import { StructDef, StructRef } from '../../../model/malloy_types';
|
|
2
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
3
|
+
import { HasParameter } from '../parameters/has-parameter';
|
|
4
4
|
/**
|
|
5
5
|
* A "Source" is a thing which you can run queries against. The main
|
|
6
6
|
* function of a source is to represent an eventual StructDef
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IndexSegment, ProjectSegment, Query, ReduceSegment, StructDef } from
|
|
1
|
+
import { IndexSegment, ProjectSegment, Query, ReduceSegment, StructDef } from '../../model/malloy_types';
|
|
2
2
|
export declare class ErrorFactory {
|
|
3
3
|
static get structDef(): StructDef;
|
|
4
4
|
static isErrorStructDef(s: StructDef): boolean;
|