@malloydata/malloy 0.0.39-dev230613161129 → 0.0.39
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/dialect/dialect.d.ts +9 -13
- package/dist/dialect/dialect.js +16 -3
- package/dist/dialect/dialect_map.d.ts +2 -0
- package/dist/dialect/dialect_map.js +61 -1
- package/dist/dialect/{duckdb.d.ts → duckdb/duckdb.d.ts} +8 -5
- package/dist/dialect/{duckdb.js → duckdb/duckdb.js} +21 -9
- package/dist/dialect/duckdb/functions/byte_length.d.ts +2 -0
- package/dist/dialect/duckdb/functions/byte_length.js +33 -0
- package/dist/dialect/duckdb/functions/div.d.ts +2 -0
- package/dist/dialect/duckdb/functions/div.js +38 -0
- package/dist/dialect/duckdb/functions/duckdb_functions.d.ts +1 -0
- package/dist/dialect/duckdb/functions/duckdb_functions.js +52 -0
- package/dist/dialect/duckdb/functions/ends_with.d.ts +2 -0
- package/dist/dialect/duckdb/functions/ends_with.js +35 -0
- package/dist/dialect/duckdb/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/duckdb/functions/greatest_and_least.js +58 -0
- package/dist/dialect/duckdb/functions/index.d.ts +1 -0
- package/dist/dialect/duckdb/functions/index.js +28 -0
- package/dist/dialect/duckdb/functions/is_inf.d.ts +2 -0
- package/dist/dialect/duckdb/functions/is_inf.js +33 -0
- package/dist/dialect/duckdb/functions/is_nan.d.ts +2 -0
- package/dist/dialect/duckdb/functions/is_nan.js +33 -0
- package/dist/dialect/duckdb/functions/log.d.ts +2 -0
- package/dist/dialect/duckdb/functions/log.js +38 -0
- package/dist/dialect/duckdb/functions/rand.d.ts +2 -0
- package/dist/dialect/duckdb/functions/rand.js +31 -0
- package/dist/dialect/duckdb/functions/replace.d.ts +2 -0
- package/dist/dialect/duckdb/functions/replace.js +40 -0
- package/dist/dialect/duckdb/functions/trunc.d.ts +2 -0
- package/dist/dialect/duckdb/functions/trunc.js +39 -0
- package/dist/dialect/duckdb/functions/unicode.d.ts +2 -0
- package/dist/dialect/duckdb/functions/unicode.js +35 -0
- package/dist/dialect/duckdb/index.d.ts +1 -0
- package/dist/dialect/duckdb/index.js +40 -0
- package/dist/dialect/functions/all_functions.d.ts +8 -0
- package/dist/dialect/functions/all_functions.js +135 -0
- package/dist/dialect/functions/atan2.d.ts +2 -0
- package/dist/dialect/functions/atan2.js +33 -0
- package/dist/dialect/functions/avg_moving.d.ts +2 -0
- package/dist/dialect/functions/avg_moving.js +46 -0
- package/dist/dialect/functions/chr.d.ts +4 -0
- package/dist/dialect/functions/chr.js +45 -0
- package/dist/dialect/functions/coalesce.d.ts +2 -0
- package/dist/dialect/functions/coalesce.js +38 -0
- package/dist/dialect/functions/concat.d.ts +2 -0
- package/dist/dialect/functions/concat.js +38 -0
- package/dist/dialect/functions/div.d.ts +2 -0
- package/dist/dialect/functions/div.js +36 -0
- package/dist/dialect/functions/first_value_window.d.ts +3 -0
- package/dist/dialect/functions/first_value_window.js +49 -0
- package/dist/dialect/functions/function_map.d.ts +16 -0
- package/dist/dialect/functions/function_map.js +50 -0
- package/dist/dialect/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/functions/greatest_and_least.js +44 -0
- package/dist/dialect/functions/ifnull.d.ts +2 -0
- package/dist/dialect/functions/ifnull.js +38 -0
- package/dist/dialect/functions/index.d.ts +2 -0
- package/dist/dialect/functions/index.js +28 -0
- package/dist/dialect/functions/is_inf.d.ts +2 -0
- package/dist/dialect/functions/is_inf.js +33 -0
- package/dist/dialect/functions/is_nan.d.ts +2 -0
- package/dist/dialect/functions/is_nan.js +33 -0
- package/dist/dialect/functions/lag.d.ts +2 -0
- package/dist/dialect/functions/lag.js +53 -0
- package/dist/dialect/functions/lead.d.ts +2 -0
- package/dist/dialect/functions/lead.js +50 -0
- package/dist/dialect/functions/length.d.ts +3 -0
- package/dist/dialect/functions/length.js +39 -0
- package/dist/dialect/functions/log.d.ts +2 -0
- package/dist/dialect/functions/log.js +35 -0
- package/dist/dialect/functions/lower.d.ts +2 -0
- package/dist/dialect/functions/lower.js +34 -0
- package/dist/dialect/functions/nullif.d.ts +2 -0
- package/dist/dialect/functions/nullif.js +42 -0
- package/dist/dialect/functions/pi.d.ts +2 -0
- package/dist/{lang/ast/types/type-desc.js → dialect/functions/pi.js} +7 -1
- package/dist/dialect/functions/pow.d.ts +2 -0
- package/dist/dialect/functions/pow.js +35 -0
- package/dist/dialect/functions/rand.d.ts +2 -0
- package/dist/dialect/functions/rand.js +31 -0
- package/dist/dialect/functions/rank.d.ts +2 -0
- package/dist/dialect/functions/rank.js +36 -0
- package/dist/dialect/functions/regexp_extract.d.ts +2 -0
- package/dist/dialect/functions/regexp_extract.js +41 -0
- package/dist/dialect/functions/repeat.d.ts +2 -0
- package/dist/dialect/functions/repeat.js +35 -0
- package/dist/dialect/functions/replace.d.ts +2 -0
- package/dist/dialect/functions/replace.js +42 -0
- package/dist/dialect/functions/reverse.d.ts +2 -0
- package/dist/dialect/functions/reverse.js +34 -0
- package/dist/dialect/functions/round.d.ts +2 -0
- package/dist/dialect/functions/round.js +40 -0
- package/dist/dialect/functions/row_number.d.ts +2 -0
- package/dist/dialect/functions/row_number.js +40 -0
- package/dist/dialect/functions/simple_numeric_functions.d.ts +15 -0
- package/dist/dialect/functions/simple_numeric_functions.js +60 -0
- package/dist/dialect/functions/starts_ends_with.d.ts +3 -0
- package/dist/dialect/functions/starts_ends_with.js +43 -0
- package/dist/dialect/functions/stddev.d.ts +2 -0
- package/dist/dialect/functions/stddev.js +34 -0
- package/dist/dialect/functions/strpos.d.ts +2 -0
- package/dist/dialect/functions/strpos.js +35 -0
- package/dist/dialect/functions/substr.d.ts +2 -0
- package/dist/dialect/functions/substr.js +37 -0
- package/dist/dialect/functions/sum_min_max_window.d.ts +7 -0
- package/dist/dialect/functions/sum_min_max_window.js +94 -0
- package/dist/dialect/functions/trim_functions.d.ts +4 -0
- package/dist/dialect/functions/trim_functions.js +42 -0
- package/dist/dialect/functions/trunc.d.ts +2 -0
- package/dist/dialect/functions/trunc.js +38 -0
- package/dist/dialect/functions/upper.d.ts +2 -0
- package/dist/dialect/functions/upper.js +34 -0
- package/dist/dialect/functions/util.d.ts +45 -0
- package/dist/dialect/functions/util.js +187 -0
- package/dist/dialect/index.d.ts +1 -1
- package/dist/dialect/index.js +2 -1
- package/dist/dialect/postgres/functions/byte_length.d.ts +2 -0
- package/dist/dialect/postgres/functions/byte_length.js +33 -0
- package/dist/dialect/postgres/functions/ends_with.d.ts +2 -0
- package/dist/dialect/postgres/functions/ends_with.js +38 -0
- package/dist/dialect/postgres/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/postgres/functions/greatest_and_least.js +45 -0
- package/dist/dialect/postgres/functions/ifnull.d.ts +2 -0
- package/dist/dialect/postgres/functions/ifnull.js +40 -0
- package/dist/dialect/postgres/functions/index.d.ts +1 -0
- package/dist/dialect/postgres/functions/index.js +28 -0
- package/dist/dialect/postgres/functions/is_inf.d.ts +2 -0
- package/dist/dialect/postgres/functions/is_inf.js +34 -0
- package/dist/dialect/postgres/functions/is_nan.d.ts +2 -0
- package/dist/dialect/postgres/functions/is_nan.js +33 -0
- package/dist/dialect/postgres/functions/log.d.ts +2 -0
- package/dist/dialect/postgres/functions/log.js +37 -0
- package/dist/dialect/postgres/functions/postgres_functions.d.ts +1 -0
- package/dist/dialect/postgres/functions/postgres_functions.js +60 -0
- package/dist/dialect/postgres/functions/rand.d.ts +2 -0
- package/dist/dialect/postgres/functions/rand.js +31 -0
- package/dist/dialect/postgres/functions/regexp_extract.d.ts +2 -0
- package/dist/dialect/postgres/functions/regexp_extract.js +35 -0
- package/dist/dialect/postgres/functions/replace.d.ts +2 -0
- package/dist/dialect/postgres/functions/replace.js +40 -0
- package/dist/dialect/postgres/functions/round.d.ts +2 -0
- package/dist/dialect/postgres/functions/round.js +39 -0
- package/dist/dialect/postgres/functions/stddev.d.ts +2 -0
- package/dist/dialect/postgres/functions/stddev.js +37 -0
- package/dist/dialect/postgres/functions/substr.d.ts +2 -0
- package/dist/dialect/postgres/functions/substr.js +38 -0
- package/dist/dialect/postgres/functions/trunc.d.ts +2 -0
- package/dist/dialect/postgres/functions/trunc.js +40 -0
- package/dist/dialect/postgres/functions/unicode.d.ts +2 -0
- package/dist/dialect/postgres/functions/unicode.js +34 -0
- package/dist/dialect/postgres/index.d.ts +1 -0
- package/dist/dialect/postgres/index.js +40 -0
- package/dist/dialect/{postgres.d.ts → postgres/postgres.d.ts} +9 -5
- package/dist/dialect/{postgres.js → postgres/postgres.js} +24 -10
- package/dist/dialect/standardsql/functions/chr.d.ts +2 -0
- package/dist/dialect/standardsql/functions/chr.js +37 -0
- package/dist/dialect/standardsql/functions/index.d.ts +1 -0
- package/dist/dialect/standardsql/functions/index.js +28 -0
- package/dist/dialect/standardsql/functions/pi.d.ts +2 -0
- package/dist/dialect/standardsql/functions/pi.js +32 -0
- package/dist/dialect/standardsql/functions/standardsql_functions.d.ts +1 -0
- package/dist/dialect/standardsql/functions/standardsql_functions.js +33 -0
- package/dist/dialect/standardsql/index.d.ts +1 -0
- package/dist/dialect/standardsql/index.js +40 -0
- package/dist/dialect/{standardsql.d.ts → standardsql/standardsql.d.ts} +7 -4
- package/dist/dialect/{standardsql.js → standardsql/standardsql.js} +13 -11
- package/dist/index.d.ts +1 -1
- package/dist/lang/ast/ast-utils.js +1 -0
- package/dist/lang/ast/elements/define-query.js +1 -1
- package/dist/lang/ast/elements/import-statement.js +6 -1
- package/dist/lang/ast/executors/index-executor.d.ts +1 -1
- package/dist/lang/ast/executors/index-executor.js +2 -2
- package/dist/lang/ast/executors/project-executor.d.ts +1 -1
- package/dist/lang/ast/executors/project-executor.js +2 -2
- package/dist/lang/ast/executors/reduce-executor.d.ts +2 -4
- package/dist/lang/ast/executors/reduce-executor.js +8 -4
- package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-boolean.js +2 -0
- package/dist/lang/ast/expressions/constant-sub-expression.js +10 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-aggregate-function.js +28 -2
- package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -0
- package/dist/lang/ast/expressions/expr-cast.js +1 -0
- package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-coalesce.js +1 -0
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-count.js +1 -0
- package/dist/lang/ast/expressions/expr-filter.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-filter.js +1 -1
- package/dist/lang/ast/expressions/expr-func.d.ts +6 -1
- package/dist/lang/ast/expressions/expr-func.js +266 -16
- package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-id-reference.js +12 -0
- package/dist/lang/ast/expressions/expr-logical-op.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-max.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-min.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-now.js +2 -0
- package/dist/lang/ast/expressions/expr-null.js +1 -0
- package/dist/lang/ast/expressions/expr-number.js +5 -1
- package/dist/lang/ast/expressions/expr-regex.js +4 -1
- package/dist/lang/ast/expressions/expr-string.js +1 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +2 -0
- package/dist/lang/ast/expressions/expr-time.js +1 -0
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-ungroup.js +15 -7
- package/dist/lang/ast/expressions/for-range.d.ts +1 -1
- package/dist/lang/ast/expressions/pick-when.js +7 -0
- package/dist/lang/ast/expressions/range.js +1 -0
- package/dist/lang/ast/expressions/time-literal.js +9 -3
- package/dist/lang/ast/field-space/column-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/dynamic-space.js +6 -4
- package/dist/lang/ast/field-space/field-definition-value.d.ts +1 -1
- package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
- package/dist/lang/ast/field-space/project-field-space.js +12 -13
- package/dist/lang/ast/field-space/query-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.d.ts +16 -2
- package/dist/lang/ast/field-space/query-spaces.js +175 -10
- package/dist/lang/ast/field-space/reference-field.d.ts +3 -2
- package/dist/lang/ast/field-space/reference-field.js +8 -1
- package/dist/lang/ast/field-space/rename-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/static-space.d.ts +4 -3
- package/dist/lang/ast/field-space/static-space.js +4 -0
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +1 -2
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/field-space/wild-space-field.d.ts +1 -2
- package/dist/lang/ast/fragtype-utils.d.ts +1 -1
- package/dist/lang/ast/fragtype-utils.js +4 -3
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/ast/query-items/field-declaration.d.ts +40 -4
- package/dist/lang/ast/query-items/field-declaration.js +102 -3
- package/dist/lang/ast/query-items/field-references.d.ts +44 -2
- package/dist/lang/ast/query-items/field-references.js +110 -2
- package/dist/lang/ast/query-items/typecheck_utils.d.ts +10 -0
- package/dist/lang/ast/query-items/typecheck_utils.js +177 -0
- package/dist/lang/ast/query-properties/aggregate.js +0 -6
- package/dist/lang/ast/query-properties/calculate.d.ts +5 -0
- package/dist/lang/ast/query-properties/calculate.js +33 -0
- package/dist/lang/ast/query-properties/dimmensions.js +0 -3
- package/dist/lang/ast/query-properties/filters.js +6 -3
- package/dist/lang/ast/query-properties/group-by.js +0 -6
- package/dist/lang/ast/query-properties/measures.js +0 -3
- package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -0
- package/dist/lang/ast/query-properties/nest-reference.js +23 -0
- package/dist/lang/ast/query-properties/ordering.d.ts +1 -1
- package/dist/lang/ast/query-properties/ordering.js +18 -8
- package/dist/lang/ast/query-properties/qop-desc.js +8 -4
- package/dist/lang/ast/query-properties/top.js +20 -6
- package/dist/lang/ast/sources/named-source.js +4 -0
- package/dist/lang/ast/sources/sql-source.js +5 -1
- package/dist/lang/ast/time-utils.d.ts +1 -2
- package/dist/lang/ast/types/expr-result.d.ts +1 -2
- package/dist/lang/ast/types/expression-def.d.ts +3 -4
- package/dist/lang/ast/types/expression-def.js +10 -2
- package/dist/lang/ast/types/field-space.d.ts +7 -0
- package/dist/lang/ast/types/global-name-space.d.ts +12 -0
- package/dist/lang/ast/types/global-name-space.js +51 -0
- package/dist/lang/ast/types/malloy-element.d.ts +1 -0
- package/dist/lang/ast/types/malloy-element.js +15 -2
- package/dist/lang/ast/types/query-property.d.ts +1 -2
- package/dist/lang/ast/types/query-property.js +2 -0
- package/dist/lang/ast/types/space-entry.d.ts +1 -1
- package/dist/lang/ast/types/space-field.d.ts +1 -2
- package/dist/lang/ast/types/space-field.js +5 -1
- package/dist/lang/ast/types/space-param.d.ts +1 -2
- package/dist/lang/ast/types/space-param.js +10 -2
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +138 -135
- package/dist/lang/lib/Malloy/MalloyLexer.js +1135 -1103
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +252 -275
- package/dist/lang/lib/Malloy/MalloyParser.js +1753 -1905
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +40 -103
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +25 -64
- package/dist/lang/malloy-to-ast.d.ts +11 -7
- package/dist/lang/malloy-to-ast.js +90 -51
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +5 -2
- package/dist/lang/test/parse.spec.js +399 -18
- package/dist/lang/test/test-translator.d.ts +1 -0
- package/dist/lang/test/test-translator.js +5 -0
- package/dist/model/malloy_query.d.ts +13 -4
- package/dist/model/malloy_query.js +240 -76
- package/dist/model/malloy_types.d.ts +89 -18
- package/dist/model/malloy_types.js +88 -61
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.js +118 -1
- package/package.json +1 -1
- package/dist/lang/ast/types/type-desc.d.ts +0 -8
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = void 0;
|
|
25
|
+
exports.isSQLBlockStruct = exports.mergeEvalSpaces = exports.isSQLFragment = exports.isJoinOn = exports.isIndexSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isFieldFragment = exports.isSpreadFragment = exports.isSQLExpressionFragment = exports.isFunctionCallFragment = exports.isFunctionParameterFragment = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isOutputFieldFragment = exports.isFilteredAliasedName = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
|
|
26
|
+
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = void 0;
|
|
27
27
|
function isValueParameter(p) {
|
|
28
28
|
return p.value !== undefined;
|
|
29
29
|
}
|
|
@@ -45,6 +45,10 @@ function isFilteredAliasedName(f) {
|
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
exports.isFilteredAliasedName = isFilteredAliasedName;
|
|
48
|
+
function isOutputFieldFragment(f) {
|
|
49
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'outputField';
|
|
50
|
+
}
|
|
51
|
+
exports.isOutputFieldFragment = isOutputFieldFragment;
|
|
48
52
|
function isFilterFragment(f) {
|
|
49
53
|
return (f === null || f === void 0 ? void 0 : f.type) === 'filterExpression';
|
|
50
54
|
}
|
|
@@ -66,61 +70,22 @@ function isUngroupFragment(f) {
|
|
|
66
70
|
return ftype === 'all' || ftype === 'exclude';
|
|
67
71
|
}
|
|
68
72
|
exports.isUngroupFragment = isUngroupFragment;
|
|
69
|
-
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'first_value_in_column': {
|
|
86
|
-
returnType: 'number',
|
|
87
|
-
parameters: 'any',
|
|
88
|
-
expressionType: 'analytic',
|
|
89
|
-
sqlName: 'first_value',
|
|
90
|
-
},
|
|
91
|
-
'last_value_in_column': {
|
|
92
|
-
returnType: 'number',
|
|
93
|
-
parameters: 'any',
|
|
94
|
-
expressionType: 'analytic',
|
|
95
|
-
sqlName: 'last_value',
|
|
96
|
-
},
|
|
97
|
-
'min_in_column': {
|
|
98
|
-
returnType: 'number',
|
|
99
|
-
parameters: 'any',
|
|
100
|
-
expressionType: 'analytic',
|
|
101
|
-
sqlName: 'min',
|
|
102
|
-
},
|
|
103
|
-
'max_in_column': {
|
|
104
|
-
returnType: 'number',
|
|
105
|
-
parameters: 'any',
|
|
106
|
-
expressionType: 'analytic',
|
|
107
|
-
sqlName: 'max',
|
|
108
|
-
},
|
|
109
|
-
'ntile': {
|
|
110
|
-
returnType: 'number',
|
|
111
|
-
parameters: ['nconst'],
|
|
112
|
-
expressionType: 'analytic',
|
|
113
|
-
},
|
|
114
|
-
'lag': {
|
|
115
|
-
returnType: 'number',
|
|
116
|
-
parameters: ['number', 'nconst'],
|
|
117
|
-
expressionType: 'analytic',
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
function isAnalyticFragment(f) {
|
|
121
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'analytic';
|
|
122
|
-
}
|
|
123
|
-
exports.isAnalyticFragment = isAnalyticFragment;
|
|
73
|
+
function isFunctionParameterFragment(f) {
|
|
74
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'function_parameter';
|
|
75
|
+
}
|
|
76
|
+
exports.isFunctionParameterFragment = isFunctionParameterFragment;
|
|
77
|
+
function isFunctionCallFragment(f) {
|
|
78
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'function_call';
|
|
79
|
+
}
|
|
80
|
+
exports.isFunctionCallFragment = isFunctionCallFragment;
|
|
81
|
+
function isSQLExpressionFragment(f) {
|
|
82
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'sql_expression';
|
|
83
|
+
}
|
|
84
|
+
exports.isSQLExpressionFragment = isSQLExpressionFragment;
|
|
85
|
+
function isSpreadFragment(f) {
|
|
86
|
+
return (f === null || f === void 0 ? void 0 : f.type) === 'spread';
|
|
87
|
+
}
|
|
88
|
+
exports.isSpreadFragment = isSpreadFragment;
|
|
124
89
|
function isFieldFragment(f) {
|
|
125
90
|
return (f === null || f === void 0 ? void 0 : f.type) === 'field';
|
|
126
91
|
}
|
|
@@ -168,25 +133,77 @@ function mkExpr(src, ...exprs) {
|
|
|
168
133
|
return ret;
|
|
169
134
|
}
|
|
170
135
|
exports.mkExpr = mkExpr;
|
|
136
|
+
function expressionIsScalar(e) {
|
|
137
|
+
return e === undefined || e === 'scalar';
|
|
138
|
+
}
|
|
139
|
+
exports.expressionIsScalar = expressionIsScalar;
|
|
171
140
|
function expressionIsAggregate(e) {
|
|
172
|
-
return e === 'aggregate';
|
|
141
|
+
return e === 'aggregate' || e === 'ungrouped_aggregate';
|
|
173
142
|
}
|
|
174
143
|
exports.expressionIsAggregate = expressionIsAggregate;
|
|
144
|
+
function expressionIsUngroupedAggregate(e) {
|
|
145
|
+
return e === 'ungrouped_aggregate';
|
|
146
|
+
}
|
|
147
|
+
exports.expressionIsUngroupedAggregate = expressionIsUngroupedAggregate;
|
|
148
|
+
function expressionInvolvesAggregate(e) {
|
|
149
|
+
return (e === 'aggregate' ||
|
|
150
|
+
e === 'ungrouped_aggregate' ||
|
|
151
|
+
e === 'aggregate_analytic');
|
|
152
|
+
}
|
|
153
|
+
exports.expressionInvolvesAggregate = expressionInvolvesAggregate;
|
|
175
154
|
function expressionIsCalculation(e) {
|
|
176
|
-
return e === 'aggregate' ||
|
|
155
|
+
return (e === 'aggregate' ||
|
|
156
|
+
e === 'scalar_analytic' ||
|
|
157
|
+
e === 'aggregate_analytic' ||
|
|
158
|
+
e === 'ungrouped_aggregate');
|
|
177
159
|
}
|
|
178
160
|
exports.expressionIsCalculation = expressionIsCalculation;
|
|
161
|
+
function expressionIsAnalytic(e) {
|
|
162
|
+
return e === 'aggregate_analytic' || e === 'scalar_analytic';
|
|
163
|
+
}
|
|
164
|
+
exports.expressionIsAnalytic = expressionIsAnalytic;
|
|
165
|
+
function expressionTypeLevel(e) {
|
|
166
|
+
return {
|
|
167
|
+
scalar: 0,
|
|
168
|
+
aggregate: 1,
|
|
169
|
+
ungrouped_aggregate: 2,
|
|
170
|
+
scalar_analytic: 2,
|
|
171
|
+
aggregate_analytic: 3,
|
|
172
|
+
}[e];
|
|
173
|
+
}
|
|
174
|
+
function isExpressionTypeLEQ(e1, e2) {
|
|
175
|
+
return e1 === e2 || expressionTypeLevel(e1) < expressionTypeLevel(e2);
|
|
176
|
+
}
|
|
177
|
+
exports.isExpressionTypeLEQ = isExpressionTypeLEQ;
|
|
178
|
+
// TODO rename this to be like `combineExpressionTypes`
|
|
179
179
|
function maxExpressionType(e1, e2) {
|
|
180
|
+
// TODO handle the case where e1 is analytic and e2 is ungrouped_aggregate
|
|
180
181
|
let ret = 'scalar';
|
|
181
182
|
if (e1 === 'aggregate' || e2 === 'aggregate') {
|
|
182
183
|
ret = 'aggregate';
|
|
183
184
|
}
|
|
184
|
-
if (e1 === '
|
|
185
|
-
ret = '
|
|
185
|
+
if (e1 === 'ungrouped_aggregate' || e2 === 'ungrouped_aggregate') {
|
|
186
|
+
ret = 'ungrouped_aggregate';
|
|
187
|
+
}
|
|
188
|
+
if (e1 === 'scalar_analytic' || e2 === 'scalar_analytic') {
|
|
189
|
+
ret = 'scalar_analytic';
|
|
190
|
+
}
|
|
191
|
+
if (e1 === 'aggregate_analytic' || e2 === 'aggregate_analytic') {
|
|
192
|
+
ret = 'aggregate_analytic';
|
|
193
|
+
}
|
|
194
|
+
if (e1 === 'scalar_analytic' && e2 === 'aggregate') {
|
|
195
|
+
ret = 'aggregate_analytic';
|
|
196
|
+
}
|
|
197
|
+
else if (e1 === 'aggregate' && e2 === 'scalar_analytic') {
|
|
198
|
+
ret = 'aggregate_analytic';
|
|
186
199
|
}
|
|
187
200
|
return ret;
|
|
188
201
|
}
|
|
189
202
|
exports.maxExpressionType = maxExpressionType;
|
|
203
|
+
function maxOfExpressionTypes(types) {
|
|
204
|
+
return types.reduce(maxExpressionType, 'scalar');
|
|
205
|
+
}
|
|
206
|
+
exports.maxOfExpressionTypes = maxOfExpressionTypes;
|
|
190
207
|
/** Grants access to the expression property of a FielfDef */
|
|
191
208
|
function hasExpression(f) {
|
|
192
209
|
return f.e !== undefined;
|
|
@@ -296,6 +313,16 @@ function isSQLFragment(f) {
|
|
|
296
313
|
return f.sql !== undefined;
|
|
297
314
|
}
|
|
298
315
|
exports.isSQLFragment = isSQLFragment;
|
|
316
|
+
function mergeEvalSpaces(...evalSpaces) {
|
|
317
|
+
if (evalSpaces.every(e => e === 'constant' || e === 'literal')) {
|
|
318
|
+
return 'constant';
|
|
319
|
+
}
|
|
320
|
+
else if (evalSpaces.every(e => e === 'output' || e === 'constant' || e === 'literal')) {
|
|
321
|
+
return 'output';
|
|
322
|
+
}
|
|
323
|
+
return 'input';
|
|
324
|
+
}
|
|
325
|
+
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
299
326
|
function isSQLBlockStruct(sd) {
|
|
300
327
|
const src = sd.structSource;
|
|
301
328
|
return src.type === 'sql' && src.method === 'subquery';
|
package/dist/model/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Expr, Fragment } from './malloy_types';
|
|
1
2
|
/** simple indent function */
|
|
2
3
|
export declare function indent(s: string): string;
|
|
3
4
|
/**
|
|
@@ -20,3 +21,6 @@ export declare class AndChain {
|
|
|
20
21
|
sql(whereOrHaving?: 'where' | 'having'): string;
|
|
21
22
|
}
|
|
22
23
|
export declare function generateHash(input: string): string;
|
|
24
|
+
export declare function exprMap(expr: Expr, func: (fragment: Fragment) => Expr): Expr;
|
|
25
|
+
export declare function joinWith<T>(els: T[][], sep: T): T[];
|
|
26
|
+
export declare function range(start: number, end: number): number[];
|
package/dist/model/utils.js
CHANGED
|
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.generateHash = exports.AndChain = exports.generateSQLStringLiteral = exports.indent = void 0;
|
|
28
|
+
exports.range = exports.joinWith = exports.exprMap = exports.generateHash = exports.AndChain = exports.generateSQLStringLiteral = exports.indent = void 0;
|
|
29
29
|
const md5_1 = __importDefault(require("md5"));
|
|
30
30
|
/** simple indent function */
|
|
31
31
|
function indent(s) {
|
|
@@ -99,4 +99,121 @@ function generateHash(input) {
|
|
|
99
99
|
return (0, md5_1.default)(input);
|
|
100
100
|
}
|
|
101
101
|
exports.generateHash = generateHash;
|
|
102
|
+
function exprMap(expr, func) {
|
|
103
|
+
return expr.flatMap(fragment => {
|
|
104
|
+
const mapped = func(fragment);
|
|
105
|
+
return mapped.map(fragment => {
|
|
106
|
+
if (typeof fragment === 'string') {
|
|
107
|
+
return fragment;
|
|
108
|
+
}
|
|
109
|
+
switch (fragment.type) {
|
|
110
|
+
case 'aggregate':
|
|
111
|
+
case 'all':
|
|
112
|
+
case 'spread':
|
|
113
|
+
case 'sql_expression':
|
|
114
|
+
case 'exclude':
|
|
115
|
+
return {
|
|
116
|
+
...fragment,
|
|
117
|
+
e: exprMap(fragment.e, func),
|
|
118
|
+
};
|
|
119
|
+
case 'apply':
|
|
120
|
+
return {
|
|
121
|
+
...fragment,
|
|
122
|
+
to: exprMap(fragment.to, func),
|
|
123
|
+
value: exprMap(fragment.value, func),
|
|
124
|
+
};
|
|
125
|
+
case 'applyVal':
|
|
126
|
+
case 'field':
|
|
127
|
+
case 'function_parameter':
|
|
128
|
+
case 'parameter':
|
|
129
|
+
case 'outputField':
|
|
130
|
+
return fragment;
|
|
131
|
+
case 'function_call':
|
|
132
|
+
return {
|
|
133
|
+
...fragment,
|
|
134
|
+
args: fragment.args.map(arg => exprMap(arg, func)),
|
|
135
|
+
};
|
|
136
|
+
case 'filterExpression':
|
|
137
|
+
return {
|
|
138
|
+
...fragment,
|
|
139
|
+
e: exprMap(fragment.e, func),
|
|
140
|
+
filterList: fragment.filterList.map(filter => {
|
|
141
|
+
return {
|
|
142
|
+
...filter,
|
|
143
|
+
expression: exprMap(filter.expression, func),
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
146
|
+
};
|
|
147
|
+
case 'dialect': {
|
|
148
|
+
switch (fragment.function) {
|
|
149
|
+
case 'cast':
|
|
150
|
+
case 'regexpMatch':
|
|
151
|
+
return {
|
|
152
|
+
...fragment,
|
|
153
|
+
expr: exprMap(fragment.expr, func),
|
|
154
|
+
};
|
|
155
|
+
case 'delta':
|
|
156
|
+
return {
|
|
157
|
+
...fragment,
|
|
158
|
+
delta: exprMap(fragment.delta, func),
|
|
159
|
+
};
|
|
160
|
+
case 'div':
|
|
161
|
+
return {
|
|
162
|
+
...fragment,
|
|
163
|
+
denominator: exprMap(fragment.denominator, func),
|
|
164
|
+
numerator: exprMap(fragment.numerator, func),
|
|
165
|
+
};
|
|
166
|
+
case 'now':
|
|
167
|
+
case 'numberLiteral':
|
|
168
|
+
case 'stringLiteral':
|
|
169
|
+
case 'timeLiteral':
|
|
170
|
+
case 'regexpLiteral':
|
|
171
|
+
return fragment;
|
|
172
|
+
case 'extract':
|
|
173
|
+
case 'trunc':
|
|
174
|
+
return {
|
|
175
|
+
...fragment,
|
|
176
|
+
expr: {
|
|
177
|
+
...fragment.expr,
|
|
178
|
+
value: exprMap(fragment.expr.value, func),
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
case 'timeDiff':
|
|
182
|
+
return {
|
|
183
|
+
...fragment,
|
|
184
|
+
left: {
|
|
185
|
+
...fragment.left,
|
|
186
|
+
value: exprMap(fragment.left.value, func),
|
|
187
|
+
},
|
|
188
|
+
right: {
|
|
189
|
+
...fragment.left,
|
|
190
|
+
value: exprMap(fragment.left.value, func),
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
default:
|
|
194
|
+
throw new Error('unexpected dialect function');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
default:
|
|
198
|
+
throw new Error('unexpected');
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
exports.exprMap = exprMap;
|
|
204
|
+
function joinWith(els, sep) {
|
|
205
|
+
const result = [];
|
|
206
|
+
for (let i = 0; i < els.length; i++) {
|
|
207
|
+
result.push(...els[i]);
|
|
208
|
+
if (i < els.length - 1) {
|
|
209
|
+
result.push(sep);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
exports.joinWith = joinWith;
|
|
215
|
+
function range(start, end) {
|
|
216
|
+
return Array.from({ length: end - start }, (_, index) => index + start);
|
|
217
|
+
}
|
|
218
|
+
exports.range = range;
|
|
102
219
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AtomicFieldType, ExpressionType } from '../../../model/malloy_types';
|
|
2
|
-
export declare type ExpressionValueType = AtomicFieldType | 'null' | 'unknown' | 'duration' | 'regular expression';
|
|
3
|
-
export declare type FieldValueType = ExpressionValueType | 'turtle' | 'struct';
|
|
4
|
-
export interface TypeDesc {
|
|
5
|
-
dataType: FieldValueType;
|
|
6
|
-
expressionType: ExpressionType;
|
|
7
|
-
rawType?: string;
|
|
8
|
-
}
|