@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
|
@@ -39,70 +39,70 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
39
39
|
this.moment = moment;
|
|
40
40
|
this.until = until;
|
|
41
41
|
this.units = units;
|
|
42
|
-
this.elementType =
|
|
42
|
+
this.elementType = 'timeLiteral';
|
|
43
43
|
}
|
|
44
44
|
granular() {
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
static parse(possibleLiteral) {
|
|
48
48
|
const s = possibleLiteral.slice(1);
|
|
49
|
-
const fYear =
|
|
49
|
+
const fYear = 'yyyy';
|
|
50
50
|
const fMonth = `${fYear}-LL`;
|
|
51
51
|
const fDay = `${fMonth}-dd`;
|
|
52
52
|
const fMinute = `${fDay} HH:mm`;
|
|
53
53
|
const fSecond = `${fMinute}:ss`;
|
|
54
54
|
const tss = luxon_1.DateTime.fromFormat(s, fSecond);
|
|
55
55
|
if (tss.isValid) {
|
|
56
|
-
const nextSecond = tss.plus({
|
|
57
|
-
const tsLit = new GranularLiteral(s, nextSecond,
|
|
58
|
-
tsLit.timeType =
|
|
56
|
+
const nextSecond = tss.plus({ second: 1 }).toFormat(fSecond);
|
|
57
|
+
const tsLit = new GranularLiteral(s, nextSecond, 'second');
|
|
58
|
+
tsLit.timeType = 'timestamp';
|
|
59
59
|
return tsLit;
|
|
60
60
|
}
|
|
61
61
|
const tsm = luxon_1.DateTime.fromFormat(s, fMinute);
|
|
62
62
|
if (tsm.isValid) {
|
|
63
63
|
// working around a weird bigquery bug ...
|
|
64
|
-
const thisMin = s +
|
|
65
|
-
const nextMinute = tsm.plus({
|
|
66
|
-
const tsLit = new GranularLiteral(thisMin, nextMinute,
|
|
67
|
-
tsLit.timeType =
|
|
64
|
+
const thisMin = s + ':00';
|
|
65
|
+
const nextMinute = tsm.plus({ minute: 1 }).toFormat(fMinute) + ':00';
|
|
66
|
+
const tsLit = new GranularLiteral(thisMin, nextMinute, 'minute');
|
|
67
|
+
tsLit.timeType = 'timestamp';
|
|
68
68
|
return tsLit;
|
|
69
69
|
}
|
|
70
70
|
const quarter = s.match(/(\d{4})-[qQ](\d)$/);
|
|
71
71
|
if (quarter) {
|
|
72
72
|
const qplus = Number.parseInt(quarter[2]) - 1;
|
|
73
|
-
let qstart = luxon_1.DateTime.fromFormat(quarter[1],
|
|
73
|
+
let qstart = luxon_1.DateTime.fromFormat(quarter[1], 'yyyy');
|
|
74
74
|
if (qplus > 0) {
|
|
75
|
-
qstart = qstart.plus({
|
|
75
|
+
qstart = qstart.plus({ quarters: qplus });
|
|
76
76
|
}
|
|
77
|
-
const qend = qstart.plus({
|
|
78
|
-
return new GranularLiteral(`${qstart.toFormat(fDay)}`, `${qend.toFormat(fDay)}`,
|
|
77
|
+
const qend = qstart.plus({ quarter: 1 });
|
|
78
|
+
return new GranularLiteral(`${qstart.toFormat(fDay)}`, `${qend.toFormat(fDay)}`, 'quarter');
|
|
79
79
|
}
|
|
80
80
|
const yyyymmdd = luxon_1.DateTime.fromFormat(s, fDay);
|
|
81
81
|
if (yyyymmdd.isValid) {
|
|
82
|
-
const next = yyyymmdd.plus({
|
|
83
|
-
return new GranularLiteral(`${yyyymmdd.toFormat(fDay)}`, `${next.toFormat(fDay)}`,
|
|
82
|
+
const next = yyyymmdd.plus({ days: 1 });
|
|
83
|
+
return new GranularLiteral(`${yyyymmdd.toFormat(fDay)}`, `${next.toFormat(fDay)}`, 'day');
|
|
84
84
|
}
|
|
85
85
|
const yyyymm = luxon_1.DateTime.fromFormat(s, fMonth);
|
|
86
86
|
if (yyyymm.isValid) {
|
|
87
|
-
const next = yyyymm.plus({
|
|
88
|
-
return new GranularLiteral(`${yyyymm.toFormat(fDay)}`, `${next.toFormat(fDay)}`,
|
|
87
|
+
const next = yyyymm.plus({ months: 1 });
|
|
88
|
+
return new GranularLiteral(`${yyyymm.toFormat(fDay)}`, `${next.toFormat(fDay)}`, 'month');
|
|
89
89
|
}
|
|
90
90
|
const yyyy = luxon_1.DateTime.fromFormat(s, fYear);
|
|
91
91
|
if (yyyy.isValid) {
|
|
92
|
-
const year = yyyy.toFormat(
|
|
93
|
-
const nextYear = yyyy.plus({
|
|
94
|
-
return new GranularLiteral(year, nextYear,
|
|
92
|
+
const year = yyyy.toFormat('yyyy-01-01');
|
|
93
|
+
const nextYear = yyyy.plus({ year: 1 }).toFormat('yyyy-01-01');
|
|
94
|
+
return new GranularLiteral(year, nextYear, 'year');
|
|
95
95
|
}
|
|
96
|
-
if (s.startsWith(
|
|
96
|
+
if (s.startsWith('WK')) {
|
|
97
97
|
const yyyymmdd = luxon_1.DateTime.fromFormat(s.slice(2), fDay);
|
|
98
98
|
if (yyyymmdd.isValid) {
|
|
99
99
|
// wonky because luxon uses monday weeks and bigquery uses sunday weeks
|
|
100
100
|
let sunday = yyyymmdd;
|
|
101
101
|
if (yyyymmdd.weekday !== 7) {
|
|
102
|
-
sunday = yyyymmdd.startOf(
|
|
102
|
+
sunday = yyyymmdd.startOf('week').minus({ day: 1 });
|
|
103
103
|
}
|
|
104
|
-
const next = sunday.plus({
|
|
105
|
-
return new GranularLiteral(`${sunday.toFormat(fDay)}`, `${next.toFormat(fDay)}`,
|
|
104
|
+
const next = sunday.plus({ days: 7 });
|
|
105
|
+
return new GranularLiteral(`${sunday.toFormat(fDay)}`, `${next.toFormat(fDay)}`, 'week');
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
return undefined;
|
|
@@ -110,21 +110,21 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
110
110
|
apply(fs, op, left) {
|
|
111
111
|
const lhs = left.getExpression(fs);
|
|
112
112
|
if ((0, malloy_types_1.isTimeFieldType)(lhs.dataType)) {
|
|
113
|
-
let rangeType =
|
|
114
|
-
if (lhs.dataType ===
|
|
115
|
-
rangeType =
|
|
113
|
+
let rangeType = 'timestamp';
|
|
114
|
+
if (lhs.dataType === 'date' && !this.timeType) {
|
|
115
|
+
rangeType = 'date';
|
|
116
116
|
}
|
|
117
|
-
const range = new range_1.Range(new expr_time_1.ExprTime(rangeType, (0, time_utils_1.timeLiteral)(this.moment, rangeType,
|
|
117
|
+
const range = new range_1.Range(new expr_time_1.ExprTime(rangeType, (0, time_utils_1.timeLiteral)(this.moment, rangeType, 'UTC')), new expr_time_1.ExprTime(rangeType, (0, time_utils_1.timeLiteral)(this.until, rangeType, 'UTC')));
|
|
118
118
|
return range.apply(fs, op, left);
|
|
119
119
|
}
|
|
120
120
|
return super.apply(fs, op, left);
|
|
121
121
|
}
|
|
122
122
|
getExpression(_fs) {
|
|
123
|
-
const dataType = this.timeType ||
|
|
123
|
+
const dataType = this.timeType || 'date';
|
|
124
124
|
const value = {
|
|
125
125
|
dataType,
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
expressionType: 'scalar',
|
|
127
|
+
value: (0, time_utils_1.timeLiteral)(this.moment, dataType, 'UTC'),
|
|
128
128
|
};
|
|
129
129
|
// Literals with date resolution can be used as timestamps or dates,
|
|
130
130
|
// this is the third attempt to make that work. It still feels like
|
|
@@ -132,13 +132,13 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
132
132
|
// at which the data is needed, the handle is gone to the ExpressionDef
|
|
133
133
|
// which would allow a method call into this class. I think the second
|
|
134
134
|
// if clause is redundant (see "parse" above, but I'm paranoid)
|
|
135
|
-
if (dataType
|
|
135
|
+
if (dataType === 'date' && (0, malloy_types_1.isDateUnit)(this.units)) {
|
|
136
136
|
value.alsoTimestamp = true;
|
|
137
137
|
}
|
|
138
|
-
if (this.units
|
|
138
|
+
if (this.units !== 'second') {
|
|
139
139
|
return {
|
|
140
140
|
...value,
|
|
141
|
-
|
|
141
|
+
timeframe: this.units,
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
return value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Comparison } from
|
|
2
|
-
import { ExprValue } from
|
|
3
|
-
import { ExpressionDef } from
|
|
4
|
-
import { FieldSpace } from
|
|
1
|
+
import { Comparison } from '../types/comparison';
|
|
2
|
+
import { ExprValue } from '../types/expr-value';
|
|
3
|
+
import { ExpressionDef } from '../types/expression-def';
|
|
4
|
+
import { FieldSpace } from '../types/field-space';
|
|
5
5
|
export declare class PartialCompare extends ExpressionDef {
|
|
6
6
|
readonly op: Comparison;
|
|
7
7
|
readonly right: ExpressionDef;
|
|
@@ -27,10 +27,10 @@ const ast_utils_1 = require("../ast-utils");
|
|
|
27
27
|
const expression_def_1 = require("../types/expression-def");
|
|
28
28
|
class PartialCompare extends expression_def_1.ExpressionDef {
|
|
29
29
|
constructor(op, right) {
|
|
30
|
-
super({
|
|
30
|
+
super({ right: right });
|
|
31
31
|
this.op = op;
|
|
32
32
|
this.right = right;
|
|
33
|
-
this.elementType =
|
|
33
|
+
this.elementType = '<=> a';
|
|
34
34
|
}
|
|
35
35
|
granular() {
|
|
36
36
|
return this.right.granular();
|
|
@@ -42,8 +42,8 @@ class PartialCompare extends expression_def_1.ExpressionDef {
|
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
44
|
getExpression(_fs) {
|
|
45
|
-
this.log(
|
|
46
|
-
return (0, ast_utils_1.errorFor)(
|
|
45
|
+
this.log('Partial comparison does not have a value');
|
|
46
|
+
return (0, ast_utils_1.errorFor)('no value for partial compare');
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
exports.PartialCompare = PartialCompare;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExprValue } from
|
|
2
|
-
import { ExpressionDef } from
|
|
3
|
-
import { FieldSpace } from
|
|
4
|
-
import { MalloyElement } from
|
|
1
|
+
import { ExprValue } from '../types/expr-value';
|
|
2
|
+
import { ExpressionDef } from '../types/expression-def';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
5
5
|
export declare class Pick extends ExpressionDef {
|
|
6
6
|
readonly choices: PickWhen[];
|
|
7
7
|
readonly elsePick?: ExpressionDef | undefined;
|
|
@@ -34,7 +34,7 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
34
34
|
super({ choices });
|
|
35
35
|
this.choices = choices;
|
|
36
36
|
this.elsePick = elsePick;
|
|
37
|
-
this.elementType =
|
|
37
|
+
this.elementType = 'pick';
|
|
38
38
|
this.has({ elsePick });
|
|
39
39
|
}
|
|
40
40
|
requestExpression(fs) {
|
|
@@ -44,11 +44,11 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
46
|
for (const c of this.choices) {
|
|
47
|
-
if (c.pick
|
|
47
|
+
if (c.pick === undefined) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
const whenResp = c.when.requestExpression(fs);
|
|
51
|
-
if (whenResp
|
|
51
|
+
if (whenResp === undefined || whenResp.dataType !== 'boolean') {
|
|
52
52
|
// If when is not a boolean, we'll treat it like a partial compare
|
|
53
53
|
return undefined;
|
|
54
54
|
}
|
|
@@ -56,11 +56,11 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
56
56
|
return this.getExpression(fs);
|
|
57
57
|
}
|
|
58
58
|
apply(fs, op, expr) {
|
|
59
|
-
const caseValue = [
|
|
59
|
+
const caseValue = ['CASE'];
|
|
60
60
|
let returnType;
|
|
61
|
-
let anyExpressionType =
|
|
61
|
+
let anyExpressionType = 'scalar';
|
|
62
62
|
for (const choice of this.choices) {
|
|
63
|
-
const whenExpr = choice.when.apply(fs,
|
|
63
|
+
const whenExpr = choice.when.apply(fs, '=', expr);
|
|
64
64
|
const thenExpr = choice.pick
|
|
65
65
|
? choice.pick.getExpression(fs)
|
|
66
66
|
: expr.getExpression(fs);
|
|
@@ -69,87 +69,87 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
69
69
|
if (!fragtype_utils_1.FT.typeEq(returnType, thenExpr, true)) {
|
|
70
70
|
const whenType = fragtype_utils_1.FT.inspect(thenExpr);
|
|
71
71
|
this.log(`pick type '${whenType}', expected '${returnType.dataType}'`);
|
|
72
|
-
return (0, ast_utils_1.errorFor)(
|
|
72
|
+
return (0, ast_utils_1.errorFor)('pick when type');
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
returnType = thenExpr;
|
|
77
77
|
}
|
|
78
|
-
caseValue.push(
|
|
78
|
+
caseValue.push(' WHEN ', ...whenExpr.value, ' THEN ', ...thenExpr.value);
|
|
79
79
|
}
|
|
80
80
|
const elsePart = this.elsePick || expr;
|
|
81
81
|
const elseVal = elsePart.getExpression(fs);
|
|
82
82
|
returnType || (returnType = elseVal);
|
|
83
83
|
if (!fragtype_utils_1.FT.typeEq(returnType, elseVal, true)) {
|
|
84
|
-
const errSrc = this.elsePick ?
|
|
84
|
+
const errSrc = this.elsePick ? 'else' : 'pick default';
|
|
85
85
|
this.log(`${errSrc} type '${fragtype_utils_1.FT.inspect(elseVal)}', expected '${returnType.dataType}'`);
|
|
86
|
-
return (0, ast_utils_1.errorFor)(
|
|
86
|
+
return (0, ast_utils_1.errorFor)('pick else type');
|
|
87
87
|
}
|
|
88
88
|
return {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
dataType: returnType.dataType,
|
|
90
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(anyExpressionType, elseVal.expressionType),
|
|
91
|
+
value: (0, utils_1.compressExpr)([...caseValue, ' ELSE ', ...elseVal.value, ' END']),
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
getExpression(fs) {
|
|
95
95
|
if (this.elsePick === undefined) {
|
|
96
96
|
this.log("pick incomplete, missing 'else'");
|
|
97
|
-
return (0, ast_utils_1.errorFor)(
|
|
97
|
+
return (0, ast_utils_1.errorFor)('no value for partial pick');
|
|
98
98
|
}
|
|
99
99
|
const choiceValues = [];
|
|
100
100
|
for (const c of this.choices) {
|
|
101
101
|
if (c.pick === undefined) {
|
|
102
|
-
this.log(
|
|
103
|
-
return (0, ast_utils_1.errorFor)(
|
|
102
|
+
this.log('pick with no value can only be used with apply');
|
|
103
|
+
return (0, ast_utils_1.errorFor)('no value for partial pick');
|
|
104
104
|
}
|
|
105
105
|
const pickWhen = c.when.requestExpression(fs);
|
|
106
106
|
if (pickWhen === undefined) {
|
|
107
|
-
this.log(
|
|
108
|
-
return (0, ast_utils_1.errorFor)(
|
|
107
|
+
this.log('pick with partial when can only be used with apply');
|
|
108
|
+
return (0, ast_utils_1.errorFor)('partial when');
|
|
109
109
|
}
|
|
110
110
|
choiceValues.push({
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
pick: c.pick.getExpression(fs),
|
|
112
|
+
when: c.when.getExpression(fs),
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
const returnType = choiceValues[0].pick;
|
|
116
|
-
const caseValue = [
|
|
116
|
+
const caseValue = ['CASE'];
|
|
117
117
|
let anyExpressionType = returnType.expressionType;
|
|
118
118
|
for (const aChoice of choiceValues) {
|
|
119
119
|
if (!fragtype_utils_1.FT.typeEq(aChoice.when, fragtype_utils_1.FT.boolT)) {
|
|
120
120
|
this.log(`when expression must be boolean, not '${fragtype_utils_1.FT.inspect(aChoice.when)}`);
|
|
121
|
-
return (0, ast_utils_1.errorFor)(
|
|
121
|
+
return (0, ast_utils_1.errorFor)('pick when type');
|
|
122
122
|
}
|
|
123
123
|
if (!fragtype_utils_1.FT.typeEq(returnType, aChoice.pick, true)) {
|
|
124
124
|
const whenType = fragtype_utils_1.FT.inspect(aChoice.pick);
|
|
125
125
|
this.log(`pick type '${whenType}', expected '${returnType.dataType}'`);
|
|
126
|
-
return (0, ast_utils_1.errorFor)(
|
|
126
|
+
return (0, ast_utils_1.errorFor)('pick value type');
|
|
127
127
|
}
|
|
128
128
|
anyExpressionType = (0, malloy_types_1.maxExpressionType)(anyExpressionType, (0, malloy_types_1.maxExpressionType)(aChoice.pick.expressionType, aChoice.when.expressionType));
|
|
129
|
-
caseValue.push(
|
|
129
|
+
caseValue.push(' WHEN ', ...aChoice.when.value, ' THEN ', ...aChoice.pick.value);
|
|
130
130
|
}
|
|
131
131
|
const defVal = this.elsePick.getExpression(fs);
|
|
132
132
|
anyExpressionType = (0, malloy_types_1.maxExpressionType)(anyExpressionType, defVal.expressionType);
|
|
133
133
|
if (!fragtype_utils_1.FT.typeEq(returnType, defVal, true)) {
|
|
134
134
|
this.elsePick.log(`else type '${fragtype_utils_1.FT.inspect(defVal)}', expected '${returnType.dataType}'`);
|
|
135
|
-
return (0, ast_utils_1.errorFor)(
|
|
135
|
+
return (0, ast_utils_1.errorFor)('pick value type mismatch');
|
|
136
136
|
}
|
|
137
|
-
caseValue.push(
|
|
137
|
+
caseValue.push(' ELSE ', ...defVal.value, ' END');
|
|
138
138
|
return {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
dataType: returnType.dataType,
|
|
140
|
+
expressionType: anyExpressionType,
|
|
141
|
+
value: (0, utils_1.compressExpr)(caseValue),
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
exports.Pick = Pick;
|
|
146
146
|
class PickWhen extends malloy_element_1.MalloyElement {
|
|
147
147
|
constructor(pick, when) {
|
|
148
|
-
super({
|
|
148
|
+
super({ when: when });
|
|
149
149
|
this.pick = pick;
|
|
150
150
|
this.when = when;
|
|
151
|
-
this.elementType =
|
|
152
|
-
this.has({
|
|
151
|
+
this.elementType = 'pickWhen';
|
|
152
|
+
this.has({ pick: pick });
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
exports.PickWhen = PickWhen;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ExprValue } from
|
|
2
|
-
import { ExpressionDef } from
|
|
3
|
-
import { FieldSpace } from
|
|
1
|
+
import { ExprValue } from '../types/expr-value';
|
|
2
|
+
import { ExpressionDef } from '../types/expression-def';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
4
|
export declare class Range extends ExpressionDef {
|
|
5
5
|
readonly first: ExpressionDef;
|
|
6
6
|
readonly last: ExpressionDef;
|
|
@@ -29,24 +29,24 @@ const expression_def_1 = require("../types/expression-def");
|
|
|
29
29
|
const utils_1 = require("./utils");
|
|
30
30
|
class Range extends expression_def_1.ExpressionDef {
|
|
31
31
|
constructor(first, last) {
|
|
32
|
-
super({
|
|
32
|
+
super({ first: first, last: last });
|
|
33
33
|
this.first = first;
|
|
34
34
|
this.last = last;
|
|
35
|
-
this.elementType =
|
|
35
|
+
this.elementType = 'range';
|
|
36
36
|
}
|
|
37
37
|
apply(fs, op, expr) {
|
|
38
38
|
switch (op) {
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
const op1 = op ===
|
|
42
|
-
const op2 = op ===
|
|
43
|
-
const op3 = op ===
|
|
39
|
+
case '=':
|
|
40
|
+
case '!=': {
|
|
41
|
+
const op1 = op === '=' ? '>=' : '<';
|
|
42
|
+
const op2 = op === '=' ? 'and' : 'or';
|
|
43
|
+
const op3 = op === '=' ? '<' : '>=';
|
|
44
44
|
const fromValue = this.first.apply(fs, op1, expr);
|
|
45
45
|
const toValue = this.last.apply(fs, op3, expr);
|
|
46
46
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
dataType: 'boolean',
|
|
48
|
+
expressionType: (0, malloy_types_1.maxExpressionType)(fromValue.expressionType, toValue.expressionType),
|
|
49
|
+
value: (0, utils_1.compose)(fromValue.value, op2, toValue.value),
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -58,22 +58,22 @@ class Range extends expression_def_1.ExpressionDef {
|
|
|
58
58
|
* val < begin to end val < begin
|
|
59
59
|
* val <= begin to end val < end
|
|
60
60
|
*/
|
|
61
|
-
case
|
|
62
|
-
return this.last.apply(fs,
|
|
63
|
-
case
|
|
64
|
-
return this.first.apply(fs,
|
|
65
|
-
case
|
|
66
|
-
return this.first.apply(fs,
|
|
67
|
-
case
|
|
68
|
-
return this.last.apply(fs,
|
|
61
|
+
case '>':
|
|
62
|
+
return this.last.apply(fs, '>=', expr);
|
|
63
|
+
case '>=':
|
|
64
|
+
return this.first.apply(fs, '>=', expr);
|
|
65
|
+
case '<':
|
|
66
|
+
return this.first.apply(fs, '<', expr);
|
|
67
|
+
case '<=':
|
|
68
|
+
return this.last.apply(fs, '<', expr);
|
|
69
69
|
}
|
|
70
|
-
throw new Error(
|
|
70
|
+
throw new Error('mysterious error in range computation');
|
|
71
71
|
}
|
|
72
72
|
requestExpression(_fs) {
|
|
73
73
|
return undefined;
|
|
74
74
|
}
|
|
75
75
|
getExpression(_fs) {
|
|
76
|
-
return (0, ast_utils_1.errorFor)(
|
|
76
|
+
return (0, ast_utils_1.errorFor)('a range is not a value');
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
exports.Range = Range;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TimestampUnit } from
|
|
2
|
-
import { MalloyElement } from
|
|
1
|
+
import { TimestampUnit } from '../../../model/malloy_types';
|
|
2
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
3
3
|
export declare class Timeframe extends MalloyElement {
|
|
4
4
|
elementType: string;
|
|
5
5
|
readonly text: TimestampUnit;
|
|
@@ -28,12 +28,12 @@ const malloy_element_1 = require("../types/malloy-element");
|
|
|
28
28
|
class Timeframe extends malloy_element_1.MalloyElement {
|
|
29
29
|
constructor(timeframeName) {
|
|
30
30
|
super();
|
|
31
|
-
this.elementType =
|
|
31
|
+
this.elementType = 'timeframe';
|
|
32
32
|
let tf = timeframeName.toLowerCase();
|
|
33
|
-
if (tf.endsWith(
|
|
33
|
+
if (tf.endsWith('s')) {
|
|
34
34
|
tf = tf.slice(0, -1);
|
|
35
35
|
}
|
|
36
|
-
this.text = (0, malloy_types_1.isTimestampUnit)(tf) ? tf :
|
|
36
|
+
this.text = (0, malloy_types_1.isTimestampUnit)(tf) ? tf : 'second';
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.Timeframe = Timeframe;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { By } from
|
|
2
|
-
import { ExpressionDef } from
|
|
3
|
-
import { FieldSpace } from
|
|
4
|
-
import { MalloyElement } from
|
|
1
|
+
import { By } from '../../../model/malloy_types';
|
|
2
|
+
import { ExpressionDef } from '../types/expression-def';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
5
5
|
export declare class TopBy extends MalloyElement {
|
|
6
6
|
readonly by: string | ExpressionDef;
|
|
7
7
|
elementType: string;
|
|
@@ -31,20 +31,20 @@ class TopBy extends malloy_element_1.MalloyElement {
|
|
|
31
31
|
constructor(by) {
|
|
32
32
|
super();
|
|
33
33
|
this.by = by;
|
|
34
|
-
this.elementType =
|
|
34
|
+
this.elementType = 'topBy';
|
|
35
35
|
if (by instanceof expression_def_1.ExpressionDef) {
|
|
36
|
-
this.has({
|
|
36
|
+
this.has({ by: by });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
getBy(fs) {
|
|
40
40
|
if (this.by instanceof expression_def_1.ExpressionDef) {
|
|
41
41
|
const byExpr = this.by.getExpression(fs);
|
|
42
42
|
if (!(0, malloy_types_1.expressionIsAggregate)(byExpr.expressionType)) {
|
|
43
|
-
this.log(
|
|
43
|
+
this.log('top by expression must be an aggregate');
|
|
44
44
|
}
|
|
45
|
-
return {
|
|
45
|
+
return { by: 'expression', e: (0, utils_1.compressExpr)(byExpr.value) };
|
|
46
46
|
}
|
|
47
|
-
return {
|
|
47
|
+
return { by: 'name', name: this.by };
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
exports.TopBy = TopBy;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Expr, Fragment } from
|
|
2
|
-
import { Equality } from
|
|
1
|
+
import { Expr, Fragment } from '../../../model/malloy_types';
|
|
2
|
+
import { Equality } from '../types/equality';
|
|
3
3
|
/**
|
|
4
4
|
* Compose a binary expression. Tries to write them safely and concisely
|
|
5
5
|
* @param left
|
|
@@ -30,13 +30,13 @@ const malloy_types_1 = require("../../../model/malloy_types");
|
|
|
30
30
|
*/
|
|
31
31
|
function term(f) {
|
|
32
32
|
if (f.length > 1) {
|
|
33
|
-
return [
|
|
33
|
+
return ['(', ...f, ')'];
|
|
34
34
|
}
|
|
35
35
|
if (f.length === 0) {
|
|
36
36
|
// Trying to compose a binary expresion with an entity that has no value
|
|
37
37
|
// this should at least cause the generated SQL to error, but likely
|
|
38
38
|
// there has already been a semantic error reported.
|
|
39
|
-
return [
|
|
39
|
+
return ['__MISSING_VALUE__'];
|
|
40
40
|
}
|
|
41
41
|
return f;
|
|
42
42
|
}
|
|
@@ -49,8 +49,8 @@ function term(f) {
|
|
|
49
49
|
*/
|
|
50
50
|
function compose(left, op, right) {
|
|
51
51
|
const opAlpha = op.match(/^[A-Za-z]/);
|
|
52
|
-
const leftSpace = left.length === 1 && opAlpha ?
|
|
53
|
-
const rightSpace = right.length === 1 && opAlpha ?
|
|
52
|
+
const leftSpace = left.length === 1 && opAlpha ? ' ' : '';
|
|
53
|
+
const rightSpace = right.length === 1 && opAlpha ? ' ' : '';
|
|
54
54
|
const newOp = leftSpace + op + rightSpace;
|
|
55
55
|
return [...term(left), newOp, ...term(right)];
|
|
56
56
|
}
|
|
@@ -60,7 +60,7 @@ function compressExpr(expr) {
|
|
|
60
60
|
const compressValue = [];
|
|
61
61
|
let buildString;
|
|
62
62
|
for (const fragment of expr.flat()) {
|
|
63
|
-
if (typeof fragment ===
|
|
63
|
+
if (typeof fragment === 'string') {
|
|
64
64
|
buildString = buildString ? buildString + fragment : fragment;
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
@@ -78,7 +78,7 @@ function compressExpr(expr) {
|
|
|
78
78
|
}
|
|
79
79
|
exports.compressExpr = compressExpr;
|
|
80
80
|
function nullsafeNot(expr, op) {
|
|
81
|
-
if (op === undefined || op ===
|
|
81
|
+
if (op === undefined || op === '!=' || op === '!~') {
|
|
82
82
|
return (0, malloy_types_1.mkExpr) `COALESCE(NOT(${expr}),FALSE)`;
|
|
83
83
|
}
|
|
84
84
|
return expr;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldDef, FieldTypeDef } from
|
|
2
|
-
import { SpaceField } from
|
|
3
|
-
import { TypeDesc } from
|
|
1
|
+
import { FieldDef, FieldTypeDef } from '../../../model/malloy_types';
|
|
2
|
+
import { SpaceField } from '../types/space-field';
|
|
3
|
+
import { TypeDesc } from '../types/type-desc';
|
|
4
4
|
export declare class ColumnSpaceField extends SpaceField {
|
|
5
5
|
protected def: FieldTypeDef;
|
|
6
6
|
constructor(def: FieldTypeDef);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as model from
|
|
2
|
-
import { SpaceEntry } from
|
|
3
|
-
import { FieldSpace } from
|
|
4
|
-
import { HasParameter } from
|
|
5
|
-
import { MalloyElement } from
|
|
6
|
-
import { SourceSpec, SpaceSeed } from
|
|
7
|
-
import { StaticSpace } from
|
|
1
|
+
import * as model from '../../../model/malloy_types';
|
|
2
|
+
import { SpaceEntry } from '../types/space-entry';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
import { HasParameter } from '../parameters/has-parameter';
|
|
5
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
6
|
+
import { SourceSpec, SpaceSeed } from '../space-seed';
|
|
7
|
+
import { StaticSpace } from './static-space';
|
|
8
8
|
export declare abstract class DynamicSpace extends StaticSpace {
|
|
9
9
|
protected final: model.StructDef | undefined;
|
|
10
10
|
protected source: SpaceSeed;
|
|
@@ -62,7 +62,7 @@ class DynamicSpace extends static_space_1.StaticSpace {
|
|
|
62
62
|
}
|
|
63
63
|
setEntry(name, value) {
|
|
64
64
|
if (this.final) {
|
|
65
|
-
throw new Error(
|
|
65
|
+
throw new Error('Space already final');
|
|
66
66
|
}
|
|
67
67
|
super.setEntry(name, value);
|
|
68
68
|
}
|
|
@@ -87,7 +87,7 @@ class DynamicSpace extends static_space_1.StaticSpace {
|
|
|
87
87
|
if (this.final === undefined) {
|
|
88
88
|
this.final = {
|
|
89
89
|
...this.fromStruct,
|
|
90
|
-
|
|
90
|
+
fields: [],
|
|
91
91
|
};
|
|
92
92
|
// Need to process the entities in specific order
|
|
93
93
|
const fields = [];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as model from
|
|
2
|
-
import { FieldDeclaration } from
|
|
3
|
-
import { FieldSpace } from
|
|
4
|
-
import { SpaceField } from
|
|
5
|
-
import { TypeDesc } from
|
|
1
|
+
import * as model from '../../../model/malloy_types';
|
|
2
|
+
import { FieldDeclaration } from '../query-items/field-declaration';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
import { SpaceField } from '../types/space-field';
|
|
5
|
+
import { TypeDesc } from '../types/type-desc';
|
|
6
6
|
export declare class FieldDefinitionValue extends SpaceField {
|
|
7
7
|
readonly space: FieldSpace;
|
|
8
8
|
readonly exprDef: FieldDeclaration;
|