@malloydata/malloy 0.0.220-dev241205013400 → 0.0.220-dev241205235613
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/snowflake/snowflake.js +2 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/lang/ast/expressions/expr-array-literal.js +10 -13
- package/dist/lang/ast/expressions/expr-record-literal.js +1 -4
- package/dist/lang/ast/expressions/expr-time-extract.js +3 -3
- package/dist/lang/ast/expressions/expr-time.js +1 -1
- package/dist/lang/ast/expressions/time-literal.js +1 -1
- package/dist/lang/ast/field-space/reference-field.js +1 -2
- package/dist/lang/ast/field-space/static-space.js +1 -1
- package/dist/lang/ast/field-space/view-field.d.ts +9 -23
- package/dist/lang/ast/query-builders/reduce-builder.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.js +7 -55
- package/dist/lang/ast/typedesc-utils.js +11 -15
- package/dist/lang/ast/types/expression-def.js +4 -4
- package/dist/lang/ast/view-elements/reference-view.js +1 -1
- package/dist/lang/test/test-translator.js +1 -8
- package/dist/model/malloy_query.js +10 -1
- package/dist/model/malloy_types.d.ts +31 -20
- package/dist/model/malloy_types.js +58 -27
- package/package.json +1 -1
|
@@ -392,9 +392,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
392
392
|
return 'DOUBLE';
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
else if (malloyType.type === 'record' ||
|
|
396
|
-
(malloyType.type === 'array' &&
|
|
397
|
-
malloyType.elementTypeDef.type === 'record_element')) {
|
|
395
|
+
else if (malloyType.type === 'record' || (0, malloy_types_1.isRepeatedRecord)(malloyType)) {
|
|
398
396
|
const sqlFields = malloyType.fields.reduce((ret, f) => {
|
|
399
397
|
var _a;
|
|
400
398
|
if ((0, malloy_types_1.isAtomic)(f)) {
|
|
@@ -409,8 +407,7 @@ ${(0, utils_1.indent)(sql)}
|
|
|
409
407
|
? recordScehma
|
|
410
408
|
: `ARRAY(${recordScehma})`;
|
|
411
409
|
}
|
|
412
|
-
else if (malloyType
|
|
413
|
-
malloyType.elementTypeDef.type !== 'record_element') {
|
|
410
|
+
else if ((0, malloy_types_1.isScalarArray)(malloyType)) {
|
|
414
411
|
return `ARRAY(${this.malloyTypeToSQLType(malloyType.elementTypeDef)})`;
|
|
415
412
|
}
|
|
416
413
|
return malloyType.type;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, SnowflakeDialect, MySQLDialect, registerDialect, arg, qtz, overload, minScalar, anyExprType, minAggregate, maxScalar, sql, makeParam, param, variadicParam, literal, spread, Dialect, TinyParser, } from './dialect';
|
|
2
2
|
export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, TinyToken, } from './dialect';
|
|
3
3
|
export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, SQLSentence, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryRunStats, NamedQuery, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, LeafAtomicTypeDef, LeafAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, ArrayLiteralNode, } from './model';
|
|
4
|
-
export {
|
|
4
|
+
export { isSourceDef, Segment, isLeafAtomic, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isScalarArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, } from './model';
|
|
5
5
|
export { MalloyTranslator, } from './lang';
|
|
6
6
|
export type { LogMessage, TranslateResponse } from './lang';
|
|
7
7
|
export { Model, Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, PreparedResult, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, } from './malloy';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.Tag = exports.toAsyncGenerator = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = void 0;
|
|
3
|
+
exports.InMemoryURLReader = exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.Model = exports.MalloyTranslator = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isScalarArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isLeafAtomic = exports.Segment = exports.isSourceDef = exports.TinyParser = exports.Dialect = exports.spread = exports.literal = exports.variadicParam = exports.param = exports.makeParam = exports.sql = exports.maxScalar = exports.minAggregate = exports.anyExprType = exports.minScalar = exports.overload = exports.qtz = exports.arg = exports.registerDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
|
|
4
|
+
exports.Tag = exports.toAsyncGenerator = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = void 0;
|
|
5
5
|
/*
|
|
6
6
|
* Copyright 2023 Google LLC
|
|
7
7
|
*
|
|
@@ -48,8 +48,6 @@ Object.defineProperty(exports, "spread", { enumerable: true, get: function () {
|
|
|
48
48
|
Object.defineProperty(exports, "Dialect", { enumerable: true, get: function () { return dialect_1.Dialect; } });
|
|
49
49
|
Object.defineProperty(exports, "TinyParser", { enumerable: true, get: function () { return dialect_1.TinyParser; } });
|
|
50
50
|
var model_1 = require("./model");
|
|
51
|
-
Object.defineProperty(exports, "arrayEachFields", { enumerable: true, get: function () { return model_1.arrayEachFields; } });
|
|
52
|
-
Object.defineProperty(exports, "isRepeatedRecord", { enumerable: true, get: function () { return model_1.isRepeatedRecord; } });
|
|
53
51
|
Object.defineProperty(exports, "isSourceDef", { enumerable: true, get: function () { return model_1.isSourceDef; } });
|
|
54
52
|
// Used in Composer Demo
|
|
55
53
|
Object.defineProperty(exports, "Segment", { enumerable: true, get: function () { return model_1.Segment; } });
|
|
@@ -59,6 +57,10 @@ Object.defineProperty(exports, "isJoinedSource", { enumerable: true, get: functi
|
|
|
59
57
|
Object.defineProperty(exports, "isSamplingEnable", { enumerable: true, get: function () { return model_1.isSamplingEnable; } });
|
|
60
58
|
Object.defineProperty(exports, "isSamplingPercent", { enumerable: true, get: function () { return model_1.isSamplingPercent; } });
|
|
61
59
|
Object.defineProperty(exports, "isSamplingRows", { enumerable: true, get: function () { return model_1.isSamplingRows; } });
|
|
60
|
+
Object.defineProperty(exports, "isRepeatedRecord", { enumerable: true, get: function () { return model_1.isRepeatedRecord; } });
|
|
61
|
+
Object.defineProperty(exports, "isScalarArray", { enumerable: true, get: function () { return model_1.isScalarArray; } });
|
|
62
|
+
Object.defineProperty(exports, "mkArrayDef", { enumerable: true, get: function () { return model_1.mkArrayDef; } });
|
|
63
|
+
Object.defineProperty(exports, "mkFieldDef", { enumerable: true, get: function () { return model_1.mkFieldDef; } });
|
|
62
64
|
Object.defineProperty(exports, "expressionIsAggregate", { enumerable: true, get: function () { return model_1.expressionIsAggregate; } });
|
|
63
65
|
Object.defineProperty(exports, "expressionIsAnalytic", { enumerable: true, get: function () { return model_1.expressionIsAnalytic; } });
|
|
64
66
|
Object.defineProperty(exports, "expressionIsCalculation", { enumerable: true, get: function () { return model_1.expressionIsCalculation; } });
|
|
@@ -30,7 +30,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.ArrayLiteral = void 0;
|
|
33
|
-
const model_1 = require("../../../model");
|
|
34
33
|
const expr_value_1 = require("../types/expr-value");
|
|
35
34
|
const expression_def_1 = require("../types/expression-def");
|
|
36
35
|
const TDU = __importStar(require("../typedesc-utils"));
|
|
@@ -65,18 +64,16 @@ class ArrayLiteral extends expression_def_1.ExpressionDef {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
const elementTypeDef = TDU.atomicDef(firstValue || { type: 'number' });
|
|
68
|
-
const typeDef =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
: (0, model_1.arrayEachFields)(elementTypeDef),
|
|
79
|
-
};
|
|
67
|
+
const typeDef = elementTypeDef.type === 'record'
|
|
68
|
+
? {
|
|
69
|
+
type: 'array',
|
|
70
|
+
elementTypeDef: { type: 'record_element' },
|
|
71
|
+
fields: elementTypeDef.fields,
|
|
72
|
+
}
|
|
73
|
+
: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
elementTypeDef,
|
|
76
|
+
};
|
|
80
77
|
const aLit = {
|
|
81
78
|
node: 'arrayLiteral',
|
|
82
79
|
kids: { values },
|
|
@@ -57,10 +57,7 @@ class RecordLiteral extends expression_def_1.ExpressionDef {
|
|
|
57
57
|
node: 'recordLiteral',
|
|
58
58
|
kids: {},
|
|
59
59
|
typeDef: {
|
|
60
|
-
name: '',
|
|
61
60
|
type: 'record',
|
|
62
|
-
join: 'one',
|
|
63
|
-
dialect: fs.dialectName(),
|
|
64
61
|
fields: [],
|
|
65
62
|
},
|
|
66
63
|
};
|
|
@@ -70,7 +67,7 @@ class RecordLiteral extends expression_def_1.ExpressionDef {
|
|
|
70
67
|
if (model_1.TD.isAtomic(xVal)) {
|
|
71
68
|
dependents.push(xVal);
|
|
72
69
|
recLit.kids[el.key] = xVal.value;
|
|
73
|
-
recLit.typeDef.fields.push(
|
|
70
|
+
recLit.typeDef.fields.push((0, model_1.mkFieldDef)(TDU.atomicDef(xVal), el.key, fs.dialectName()));
|
|
74
71
|
}
|
|
75
72
|
else {
|
|
76
73
|
this.logError('illegal-record-property-type', `Record property '${el.key} is type '${xVal.type}', which is not a legal property value type`);
|
|
@@ -60,10 +60,10 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
|
|
|
60
60
|
from: [first, last],
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
if (!(0, malloy_types_1.
|
|
63
|
+
if (!(0, malloy_types_1.isTemporalType)(first.type)) {
|
|
64
64
|
return from.first.loggedErrorExpr('invalid-type-for-time-extraction', `Can't extract ${extractTo} from '${first.type}'`);
|
|
65
65
|
}
|
|
66
|
-
if (!(0, malloy_types_1.
|
|
66
|
+
if (!(0, malloy_types_1.isTemporalType)(last.type)) {
|
|
67
67
|
return from.last.loggedErrorExpr('invalid-type-for-time-extraction', `Cannot extract ${extractTo} from '${last.type}'`);
|
|
68
68
|
}
|
|
69
69
|
let valueType = first.type;
|
|
@@ -109,7 +109,7 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
|
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
const argV = from.getExpression(fs);
|
|
112
|
-
if ((0, malloy_types_1.
|
|
112
|
+
if ((0, malloy_types_1.isTemporalType)(argV.type)) {
|
|
113
113
|
return (0, expr_value_1.computedExprValue)({
|
|
114
114
|
dataType: { type: 'number', numberType: 'integer' },
|
|
115
115
|
value: {
|
|
@@ -49,7 +49,7 @@ class ExprTime extends expression_def_1.ExpressionDef {
|
|
|
49
49
|
dstType: { type: timeType },
|
|
50
50
|
e: expr.value,
|
|
51
51
|
};
|
|
52
|
-
if ((0, malloy_types_1.
|
|
52
|
+
if ((0, malloy_types_1.isTemporalType)(expr.type)) {
|
|
53
53
|
toTs.srcType = { type: expr.type };
|
|
54
54
|
}
|
|
55
55
|
value = toTs;
|
|
@@ -166,7 +166,7 @@ class GranularLiteral extends TimeLiteral {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
// Compiler is unsure about rangeEnd = newEnd for some reason
|
|
169
|
-
if (rangeEnd && (0, malloy_types_1.
|
|
169
|
+
if (rangeEnd && (0, malloy_types_1.isTemporalType)(testValue.type)) {
|
|
170
170
|
const rangeType = testValue.type;
|
|
171
171
|
const range = new range_1.Range(new expr_time_1.ExprTime(rangeType, rangeStart.value), new expr_time_1.ExprTime(rangeType, rangeEnd.value));
|
|
172
172
|
return range.apply(fs, op, left);
|
|
@@ -78,8 +78,7 @@ class ReferenceField extends space_field_1.SpaceField {
|
|
|
78
78
|
const foundType = check.found.typeDesc();
|
|
79
79
|
if (malloy_types_1.TD.isAtomic(foundType)) {
|
|
80
80
|
this.queryFieldDef = {
|
|
81
|
-
...TDU.atomicDef(foundType),
|
|
82
|
-
name: path[0],
|
|
81
|
+
...(0, malloy_types_1.mkFieldDef)(TDU.atomicDef(foundType), path[0], fs.dialectName()),
|
|
83
82
|
e: { node: 'parameter', path },
|
|
84
83
|
};
|
|
85
84
|
}
|
|
@@ -53,7 +53,7 @@ class StaticSpace {
|
|
|
53
53
|
if ((0, malloy_types_1.isJoined)(from)) {
|
|
54
54
|
return new StructSpaceField(from);
|
|
55
55
|
}
|
|
56
|
-
else if ((0, malloy_types_1.
|
|
56
|
+
else if ((0, malloy_types_1.isTurtle)(from)) {
|
|
57
57
|
return new ir_view_field_1.IRViewField(this, from);
|
|
58
58
|
}
|
|
59
59
|
return new column_space_field_1.ColumnSpaceField(from);
|
|
@@ -55,34 +55,20 @@ export declare abstract class ViewField extends SpaceField {
|
|
|
55
55
|
} | {
|
|
56
56
|
compositeFieldUsage: import("../../../model/malloy_types").CompositeFieldUsage;
|
|
57
57
|
type: "array";
|
|
58
|
-
elementTypeDef: import("../../../model/malloy_types").LeafAtomicTypeDef | import("../../../model/malloy_types").
|
|
59
|
-
join: "many";
|
|
60
|
-
matrixOperation?: import("../../../model/malloy_types").MatrixOperation | undefined;
|
|
61
|
-
onExpression?: import("../../../model/malloy_types").Expr | undefined;
|
|
62
|
-
onCompositeFieldUsage?: import("../../../model/malloy_types").CompositeFieldUsage | undefined;
|
|
63
|
-
annotation?: import("../../../model/malloy_types").Annotation | undefined;
|
|
64
|
-
modelAnnotation?: import("../../../model/malloy_types").ModelAnnotation | undefined;
|
|
65
|
-
fields: ((import("../../../model/malloy_types").StringTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").DateTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").TimestampTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").NumberTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").BooleanTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").JSONTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").NativeUnsupportedTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").ErrorTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").ArrayTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").RecordTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").TableSourceDef) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").SQLSourceDef) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").QuerySourceDef) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").CompositeSourceDef) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").ArrayTypeDef & import("../../../model/malloy_types").FieldBase) | (import("../../../model/malloy_types").JoinBase & import("../../../model/malloy_types").RecordTypeDef & import("../../../model/malloy_types").FieldBase) | TurtleDef)[];
|
|
66
|
-
dialect: string;
|
|
67
|
-
location?: import("../../../model/malloy_types").DocumentLocation | undefined;
|
|
68
|
-
name: string;
|
|
69
|
-
as?: string | undefined;
|
|
58
|
+
elementTypeDef: import("../../../model/malloy_types").LeafAtomicTypeDef | import("../../../model/malloy_types").ScalarArrayTypeDef | import("../../../model/malloy_types").RepeatedRecordTypeDef;
|
|
70
59
|
expressionType: import("../../../model/malloy_types").ExpressionType;
|
|
71
60
|
evalSpace: import("../../../model/malloy_types").EvalSpace;
|
|
72
61
|
} | {
|
|
73
62
|
compositeFieldUsage: import("../../../model/malloy_types").CompositeFieldUsage;
|
|
74
63
|
type: "record";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
matrixOperation?: import("../../../model/malloy_types").MatrixOperation | undefined;
|
|
84
|
-
onExpression?: import("../../../model/malloy_types").Expr | undefined;
|
|
85
|
-
onCompositeFieldUsage?: import("../../../model/malloy_types").CompositeFieldUsage | undefined;
|
|
64
|
+
fields: import("../../../model/malloy_types").FieldDef[];
|
|
65
|
+
expressionType: import("../../../model/malloy_types").ExpressionType;
|
|
66
|
+
evalSpace: import("../../../model/malloy_types").EvalSpace;
|
|
67
|
+
} | {
|
|
68
|
+
compositeFieldUsage: import("../../../model/malloy_types").CompositeFieldUsage;
|
|
69
|
+
type: "array";
|
|
70
|
+
elementTypeDef: import("../../../model/malloy_types").RecordElementTypeDef;
|
|
71
|
+
fields: import("../../../model/malloy_types").FieldDef[];
|
|
86
72
|
expressionType: import("../../../model/malloy_types").ExpressionType;
|
|
87
73
|
evalSpace: import("../../../model/malloy_types").EvalSpace;
|
|
88
74
|
} | {
|
|
@@ -161,7 +161,7 @@ class ReduceBuilder extends QuerySegmentBuilder {
|
|
|
161
161
|
fieldAnalytic =
|
|
162
162
|
(0, malloy_types_1.hasExpression)(field) && (0, malloy_types_1.expressionIsAnalytic)(field.expressionType);
|
|
163
163
|
}
|
|
164
|
-
if ((0, malloy_types_1.
|
|
164
|
+
if ((0, malloy_types_1.isTemporalType)(fieldType) || fieldAggregate) {
|
|
165
165
|
reduceSegment.defaultOrderBy = true;
|
|
166
166
|
reduceSegment.orderBy = [{ field: fieldName, dir: 'desc' }];
|
|
167
167
|
usableDefaultOrderField = undefined;
|
|
@@ -109,62 +109,14 @@ class AtomicFieldDeclaration extends malloy_element_1.MalloyElement {
|
|
|
109
109
|
}
|
|
110
110
|
if ((0, malloy_types_1.isAtomicFieldType)(exprValue.type) && exprValue.type !== 'error') {
|
|
111
111
|
this.typecheckExprValue(exprValue);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const timeRet = {
|
|
117
|
-
name: exprName,
|
|
118
|
-
type: exprValue.type,
|
|
119
|
-
location: this.location,
|
|
120
|
-
e: exprValue.value,
|
|
121
|
-
compositeFieldUsage: exprValue.compositeFieldUsage,
|
|
122
|
-
};
|
|
123
|
-
if ((0, granular_result_1.isGranularResult)(exprValue)) {
|
|
124
|
-
timeRet.timeframe = exprValue.timeframe;
|
|
125
|
-
}
|
|
126
|
-
ret = timeRet;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case 'json':
|
|
130
|
-
case 'boolean':
|
|
131
|
-
case 'string':
|
|
132
|
-
case 'number':
|
|
133
|
-
case 'sql native': {
|
|
134
|
-
ret = {
|
|
135
|
-
type: exprValue.type,
|
|
136
|
-
name: exprName,
|
|
137
|
-
location: this.location,
|
|
138
|
-
e: exprValue.value,
|
|
139
|
-
compositeFieldUsage: exprValue.compositeFieldUsage,
|
|
140
|
-
};
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case 'record': {
|
|
144
|
-
ret = {
|
|
145
|
-
type: 'record',
|
|
146
|
-
name: exprName,
|
|
147
|
-
location: this.location,
|
|
148
|
-
join: 'one',
|
|
149
|
-
fields: exprValue.fields,
|
|
150
|
-
e: exprValue.value,
|
|
151
|
-
compositeFieldUsage: exprValue.compositeFieldUsage,
|
|
152
|
-
dialect: exprFS.dialectName(),
|
|
153
|
-
};
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case 'array': {
|
|
157
|
-
ret = {
|
|
158
|
-
type: 'array',
|
|
159
|
-
elementTypeDef: exprValue.elementTypeDef,
|
|
160
|
-
name: exprName,
|
|
161
|
-
join: 'many',
|
|
162
|
-
fields: exprValue.fields,
|
|
163
|
-
e: exprValue.value,
|
|
164
|
-
dialect: exprValue.dialect,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
112
|
+
const ret = (0, malloy_types_1.mkFieldDef)(TDU.atomicDef(exprValue), exprName, exprFS.dialectName());
|
|
113
|
+
if ((ret.type === 'date' || ret.type === 'timestamp') &&
|
|
114
|
+
(0, granular_result_1.isGranularResult)(exprValue)) {
|
|
115
|
+
ret.timeframe = exprValue.timeframe;
|
|
167
116
|
}
|
|
117
|
+
ret.location = this.location;
|
|
118
|
+
ret.e = exprValue.value;
|
|
119
|
+
ret.compositeFieldUsage = exprValue.compositeFieldUsage;
|
|
168
120
|
if (exprValue.expressionType) {
|
|
169
121
|
ret.expressionType = exprValue.expressionType;
|
|
170
122
|
}
|
|
@@ -125,23 +125,19 @@ function atomicDef(td) {
|
|
|
125
125
|
if (model_1.TD.isAtomic(td)) {
|
|
126
126
|
switch (td.type) {
|
|
127
127
|
case 'array': {
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
return (0, model_1.isRepeatedRecord)(td)
|
|
129
|
+
? {
|
|
130
|
+
type: 'array',
|
|
131
|
+
elementTypeDef: td.elementTypeDef,
|
|
132
|
+
fields: td.fields,
|
|
133
|
+
}
|
|
134
|
+
: {
|
|
135
|
+
type: 'array',
|
|
136
|
+
elementTypeDef: td.elementTypeDef,
|
|
137
|
+
};
|
|
136
138
|
}
|
|
137
139
|
case 'record': {
|
|
138
|
-
return {
|
|
139
|
-
name: '',
|
|
140
|
-
type: 'record',
|
|
141
|
-
join: 'one',
|
|
142
|
-
dialect: td.dialect,
|
|
143
|
-
fields: td.fields,
|
|
144
|
-
};
|
|
140
|
+
return { type: 'record', fields: td.fields };
|
|
145
141
|
}
|
|
146
142
|
case 'number': {
|
|
147
143
|
return td.numberType
|
|
@@ -154,7 +154,7 @@ class ExprDuration extends ExpressionDef {
|
|
|
154
154
|
apply(fs, op, left) {
|
|
155
155
|
const lhs = left.getExpression(fs);
|
|
156
156
|
this.typeCheck(this, lhs);
|
|
157
|
-
if ((0, malloy_types_1.
|
|
157
|
+
if ((0, malloy_types_1.isTemporalType)(lhs.type) && (op === '+' || op === '-')) {
|
|
158
158
|
const num = this.n.getExpression(fs);
|
|
159
159
|
if (!TDU.typeEq(num, TDU.numberT)) {
|
|
160
160
|
this.logError('invalid-duration-quantity', `Duration quantity needs number not '${num.type}`);
|
|
@@ -209,8 +209,8 @@ function getMorphicValue(mv, mt) {
|
|
|
209
209
|
}
|
|
210
210
|
exports.getMorphicValue = getMorphicValue;
|
|
211
211
|
function timeCompare(left, lhs, op, rhs) {
|
|
212
|
-
const leftIsTime = (0, malloy_types_1.
|
|
213
|
-
const rightIsTime = (0, malloy_types_1.
|
|
212
|
+
const leftIsTime = (0, malloy_types_1.isTemporalType)(lhs.type);
|
|
213
|
+
const rightIsTime = (0, malloy_types_1.isTemporalType)(rhs.type);
|
|
214
214
|
const node = (0, binary_operators_1.getExprNode)(op);
|
|
215
215
|
if (leftIsTime && rightIsTime) {
|
|
216
216
|
if (lhs.type !== rhs.type) {
|
|
@@ -371,7 +371,7 @@ function delta(fs, left, op, right) {
|
|
|
371
371
|
if (noGo) {
|
|
372
372
|
return noGo;
|
|
373
373
|
}
|
|
374
|
-
const timeLHS = (0, malloy_types_1.
|
|
374
|
+
const timeLHS = (0, malloy_types_1.isTemporalType)(lhs.type);
|
|
375
375
|
const err = errorCascade(timeLHS ? 'error' : 'number', lhs, rhs);
|
|
376
376
|
if (err)
|
|
377
377
|
return err;
|
|
@@ -89,7 +89,7 @@ class ReferenceView extends view_1.View {
|
|
|
89
89
|
outputStruct,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
else if ((0, malloy_types_1.
|
|
92
|
+
else if ((0, malloy_types_1.isTurtle)(fieldDef)) {
|
|
93
93
|
if (this.reference.list.length > 1) {
|
|
94
94
|
if (forRefinement) {
|
|
95
95
|
this.logError('refinement-with-joined-view', 'Cannot use view from join as refinement');
|
|
@@ -74,14 +74,7 @@ const mockSchema = {
|
|
|
74
74
|
matrixOperation: 'left',
|
|
75
75
|
dialect: 'standardsql',
|
|
76
76
|
},
|
|
77
|
-
|
|
78
|
-
type: 'array',
|
|
79
|
-
name: 'ais',
|
|
80
|
-
elementTypeDef: intType,
|
|
81
|
-
join: 'many',
|
|
82
|
-
fields: (0, malloy_types_1.arrayEachFields)(intType),
|
|
83
|
-
dialect: 'standardsql',
|
|
84
|
-
},
|
|
77
|
+
(0, malloy_types_1.mkArrayDef)(intType, 'ais', 'standardsql'),
|
|
85
78
|
],
|
|
86
79
|
},
|
|
87
80
|
'malloytest.carriers': {
|
|
@@ -3597,7 +3597,16 @@ class QueryModel {
|
|
|
3597
3597
|
// for (const f of ret.outputStruct.fields) {
|
|
3598
3598
|
// fieldNames.push(getIdentifier(f));
|
|
3599
3599
|
// }
|
|
3600
|
-
const fieldNames =
|
|
3600
|
+
const fieldNames = [];
|
|
3601
|
+
for (const f of ret.outputStruct.fields) {
|
|
3602
|
+
if ((0, malloy_types_1.isAtomic)(f)) {
|
|
3603
|
+
const quoted = q.parent.dialect.sqlMaybeQuoteIdentifier(f.name);
|
|
3604
|
+
fieldNames.push(quoted);
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
// const fieldNames = getAtomicFields(ret.outputStruct).map(fieldDef =>
|
|
3608
|
+
// q.parent.dialect.sqlMaybeQuoteIdentifier(fieldDef.name)
|
|
3609
|
+
// );
|
|
3601
3610
|
ret.lastStageName = stageWriter.addStage(q.parent.dialect.sqlFinalStage(ret.lastStageName, fieldNames));
|
|
3602
3611
|
}
|
|
3603
3612
|
return {
|
|
@@ -342,7 +342,7 @@ export interface HasExpression {
|
|
|
342
342
|
}
|
|
343
343
|
export declare function hasExpression<T extends FieldDef>(f: T): f is T & Expression & HasExpression;
|
|
344
344
|
export type TemporalFieldType = 'date' | 'timestamp';
|
|
345
|
-
export declare function
|
|
345
|
+
export declare function isTemporalType(s: string): s is TemporalFieldType;
|
|
346
346
|
export type CastType = 'string' | 'number' | TemporalFieldType | 'boolean' | 'json';
|
|
347
347
|
export type AtomicFieldType = CastType | 'sql native' | 'record' | 'array' | 'error';
|
|
348
348
|
export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
|
|
@@ -381,28 +381,40 @@ export interface NativeUnsupportedTypeDef {
|
|
|
381
381
|
rawType?: string;
|
|
382
382
|
}
|
|
383
383
|
export type NativeUnsupportedFieldDef = NativeUnsupportedTypeDef & AtomicFieldDef;
|
|
384
|
-
export interface
|
|
384
|
+
export interface ScalarArrayTypeDef {
|
|
385
|
+
type: 'array';
|
|
386
|
+
elementTypeDef: Exclude<AtomicTypeDef, RecordTypeDef>;
|
|
387
|
+
}
|
|
388
|
+
export interface ScalarArrayDef extends ScalarArrayTypeDef, StructDefBase, JoinBase, FieldBase {
|
|
385
389
|
type: 'array';
|
|
386
|
-
elementTypeDef: Exclude<AtomicTypeDef, RecordTypeDef> | RecordElementTypeDef;
|
|
387
390
|
join: 'many';
|
|
388
391
|
}
|
|
389
|
-
export
|
|
390
|
-
export declare function
|
|
391
|
-
export interface RecordTypeDef
|
|
392
|
+
export declare function mkFieldDef(atd: AtomicTypeDef, name: string, dialect: string): AtomicFieldDef;
|
|
393
|
+
export declare function mkArrayDef(ofType: AtomicTypeDef, name: string, dialect: string): ArrayDef;
|
|
394
|
+
export interface RecordTypeDef {
|
|
395
|
+
type: 'record';
|
|
396
|
+
fields: FieldDef[];
|
|
397
|
+
}
|
|
398
|
+
export interface RecordDef extends RecordTypeDef, StructDefBase, JoinBase, FieldBase {
|
|
392
399
|
type: 'record';
|
|
393
400
|
join: 'one';
|
|
394
401
|
}
|
|
395
402
|
export interface RecordElementTypeDef {
|
|
396
403
|
type: 'record_element';
|
|
397
404
|
}
|
|
398
|
-
export interface RepeatedRecordTypeDef
|
|
405
|
+
export interface RepeatedRecordTypeDef {
|
|
399
406
|
type: 'array';
|
|
400
407
|
elementTypeDef: RecordElementTypeDef;
|
|
408
|
+
fields: FieldDef[];
|
|
409
|
+
}
|
|
410
|
+
export interface RepeatedRecordDef extends RepeatedRecordTypeDef, StructDefBase, JoinBase, FieldBase {
|
|
411
|
+
type: 'array';
|
|
401
412
|
join: 'many';
|
|
402
413
|
}
|
|
403
|
-
export type
|
|
404
|
-
export type
|
|
405
|
-
export declare function isRepeatedRecord(fd: FieldDef): fd is
|
|
414
|
+
export type ArrayTypeDef = ScalarArrayTypeDef | RepeatedRecordTypeDef;
|
|
415
|
+
export type ArrayDef = ScalarArrayDef | RepeatedRecordDef;
|
|
416
|
+
export declare function isRepeatedRecord(fd: FieldDef | QueryFieldDef | StructDef | AtomicTypeDef): fd is RepeatedRecordTypeDef;
|
|
417
|
+
export declare function isScalarArray(td: AtomicTypeDef | FieldDef | QueryFieldDef | StructDef): td is ScalarArrayTypeDef;
|
|
406
418
|
export interface ErrorTypeDef {
|
|
407
419
|
type: 'error';
|
|
408
420
|
}
|
|
@@ -419,10 +431,10 @@ export interface JoinBase {
|
|
|
419
431
|
onExpression?: Expr;
|
|
420
432
|
onCompositeFieldUsage?: CompositeFieldUsage;
|
|
421
433
|
}
|
|
422
|
-
export type Joinable = CompositeSourceDef | TableSourceDef | SQLSourceDef | QuerySourceDef | RecordDef | ArrayDef;
|
|
423
|
-
export type JoinFieldDef =
|
|
434
|
+
export type Joinable = CompositeSourceDef | TableSourceDef | SQLSourceDef | QuerySourceDef | RepeatedRecordDef | RecordDef | ArrayDef;
|
|
435
|
+
export type JoinFieldDef = Joinable & JoinBase;
|
|
424
436
|
export declare function isJoinable(sd: StructDef): sd is Joinable;
|
|
425
|
-
export declare function isJoined
|
|
437
|
+
export declare function isJoined(sd: TypedDef): sd is JoinFieldDef;
|
|
426
438
|
export declare function isJoinedSource(sd: StructDef): sd is SourceDef & JoinBase;
|
|
427
439
|
export type DateUnit = 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
428
440
|
export declare function isDateUnit(str: string): str is DateUnit;
|
|
@@ -622,7 +634,6 @@ export declare function isSourceDef(sd: NamedModelObject | FieldDef): sd is Sour
|
|
|
622
634
|
export type SourceDef = TableSourceDef | SQLSourceDef | QuerySourceDef | QueryResultDef | FinalizeSourceDef | NestSourceDef | CompositeSourceDef;
|
|
623
635
|
/** Is this the "FROM" table of a query tree */
|
|
624
636
|
export declare function isBaseTable(def: StructDef): def is SourceDef;
|
|
625
|
-
export declare function isScalarArray(def: FieldDef | StructDef): boolean;
|
|
626
637
|
export type StructDef = SourceDef | RecordDef | ArrayDef;
|
|
627
638
|
export type NonAtomicType = Exclude<JoinElementType, 'array' | 'record'> | 'turtle' | 'null' | 'duration' | 'any' | 'regular expression';
|
|
628
639
|
export interface NonAtomicTypeDef {
|
|
@@ -679,11 +690,11 @@ export interface ConnectionDef extends NamedObject {
|
|
|
679
690
|
}
|
|
680
691
|
export type TemporalTypeDef = DateTypeDef | TimestampTypeDef;
|
|
681
692
|
export type LeafAtomicTypeDef = StringTypeDef | TemporalTypeDef | NumberTypeDef | BooleanTypeDef | JSONTypeDef | NativeUnsupportedTypeDef | ErrorTypeDef;
|
|
682
|
-
export type AtomicTypeDef = LeafAtomicTypeDef | ArrayTypeDef | RecordTypeDef;
|
|
683
693
|
export type LeafAtomicDef = LeafAtomicTypeDef & FieldBase;
|
|
684
|
-
export type
|
|
694
|
+
export type AtomicTypeDef = LeafAtomicTypeDef | ScalarArrayTypeDef | RecordTypeDef | RepeatedRecordTypeDef;
|
|
695
|
+
export type AtomicFieldDef = LeafAtomicDef | ScalarArrayDef | RecordDef | RepeatedRecordDef;
|
|
685
696
|
export declare function isLeafAtomic(fd: FieldDef | QueryFieldDef | AtomicTypeDef): fd is LeafAtomicDef;
|
|
686
|
-
export type FieldDef =
|
|
697
|
+
export type FieldDef = LeafAtomicDef | JoinFieldDef | TurtleDef;
|
|
687
698
|
export type FieldDefType = AtomicFieldType | 'turtle' | JoinElementType;
|
|
688
699
|
export interface RefToField {
|
|
689
700
|
type: 'fieldref';
|
|
@@ -691,6 +702,7 @@ export interface RefToField {
|
|
|
691
702
|
annotation?: Annotation;
|
|
692
703
|
}
|
|
693
704
|
export type QueryFieldDef = AtomicFieldDef | TurtleDef | RefToField;
|
|
705
|
+
export type TypedDef = AtomicTypeDef | JoinFieldDef | TurtleDef | RefToField | StructDef;
|
|
694
706
|
/** Get the output name for a NamedObject */
|
|
695
707
|
export declare function getIdentifier(n: AliasedName): string;
|
|
696
708
|
export type NamedModelObject = StructDef | NamedQuery | FunctionDef | ConnectionDef;
|
|
@@ -768,15 +780,14 @@ export interface QueryResult extends CompiledQuery {
|
|
|
768
780
|
runStats?: QueryRunStats;
|
|
769
781
|
profilingUrl?: string;
|
|
770
782
|
}
|
|
771
|
-
export declare function
|
|
772
|
-
export declare function isAtomic(def:
|
|
783
|
+
export declare function isTurtle(def: TypedDef): def is TurtleDef;
|
|
784
|
+
export declare function isAtomic(def: TypedDef): def is AtomicTypeDef;
|
|
773
785
|
export interface SearchResultRow {
|
|
774
786
|
field_name: string;
|
|
775
787
|
field_value: string;
|
|
776
788
|
weight: number;
|
|
777
789
|
}
|
|
778
790
|
export type SearchResult = SearchResultRow[];
|
|
779
|
-
export declare function getAtomicFields(structDef: StructDef): AtomicFieldDef[];
|
|
780
791
|
export declare function isValueString(value: QueryValue, field: FieldDef): value is string | null;
|
|
781
792
|
export declare function isValueNumber(value: QueryValue, field: FieldDef): value is number | null;
|
|
782
793
|
export declare function isValueBoolean(value: QueryValue, field: FieldDef): value is boolean | null;
|
|
@@ -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.TD = exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.
|
|
25
|
+
exports.sourceBase = exports.isSegmentSQL = exports.isIndexSegment = exports.isRawSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.structHasErrors = exports.segmentHasErrors = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.isJoinedSource = exports.isJoined = exports.isJoinable = exports.isMatrixOperation = exports.isScalarArray = exports.isRepeatedRecord = exports.mkArrayDef = exports.mkFieldDef = exports.fieldIsIntrinsic = exports.isCastType = exports.canOrderBy = exports.isAtomicFieldType = exports.isTemporalType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.paramHasValue = exports.isRawCast = exports.mkTemporal = exports.isAsymmetricExpr = exports.exprIsLeaf = exports.exprHasE = exports.exprHasKids = void 0;
|
|
26
|
+
exports.TD = exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isAtomic = exports.isTurtle = exports.getIdentifier = exports.isLeafAtomic = exports.mergeEvalSpaces = exports.isLiteral = exports.isBaseTable = exports.isSourceDef = void 0;
|
|
27
27
|
function exprHasKids(e) {
|
|
28
28
|
return 'kids' in e;
|
|
29
29
|
}
|
|
@@ -147,10 +147,10 @@ function hasExpression(f) {
|
|
|
147
147
|
return 'e' in f;
|
|
148
148
|
}
|
|
149
149
|
exports.hasExpression = hasExpression;
|
|
150
|
-
function
|
|
150
|
+
function isTemporalType(s) {
|
|
151
151
|
return s === 'date' || s === 'timestamp';
|
|
152
152
|
}
|
|
153
|
-
exports.
|
|
153
|
+
exports.isTemporalType = isTemporalType;
|
|
154
154
|
function isAtomicFieldType(s) {
|
|
155
155
|
return [
|
|
156
156
|
'string',
|
|
@@ -179,34 +179,71 @@ function fieldIsIntrinsic(f) {
|
|
|
179
179
|
return isAtomicFieldType(f.type) && !hasExpression(f);
|
|
180
180
|
}
|
|
181
181
|
exports.fieldIsIntrinsic = fieldIsIntrinsic;
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
182
|
+
function mkFieldDef(atd, name, dialect) {
|
|
183
|
+
if (isScalarArray(atd)) {
|
|
184
|
+
return mkArrayDef(atd.elementTypeDef, name, dialect);
|
|
185
|
+
}
|
|
186
|
+
if (isRepeatedRecord(atd)) {
|
|
187
|
+
const { type, fields, elementTypeDef } = atd;
|
|
188
|
+
return { type, fields, elementTypeDef, join: 'many', name, dialect };
|
|
189
|
+
}
|
|
190
|
+
if (atd.type === 'record') {
|
|
191
|
+
const { type, fields } = atd;
|
|
192
|
+
return { type, fields, join: 'one', dialect, name };
|
|
193
|
+
}
|
|
194
|
+
return { ...atd, name };
|
|
195
|
+
}
|
|
196
|
+
exports.mkFieldDef = mkFieldDef;
|
|
197
|
+
function mkArrayDef(ofType, name, dialect) {
|
|
198
|
+
if (ofType.type === 'record') {
|
|
199
|
+
return {
|
|
200
|
+
type: 'array',
|
|
201
|
+
join: 'many',
|
|
202
|
+
name,
|
|
203
|
+
dialect,
|
|
204
|
+
elementTypeDef: { type: 'record_element' },
|
|
205
|
+
fields: ofType.fields,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const valueEnt = mkFieldDef(ofType, 'value', dialect);
|
|
209
|
+
return {
|
|
210
|
+
type: 'array',
|
|
211
|
+
join: 'many',
|
|
212
|
+
name,
|
|
213
|
+
dialect,
|
|
214
|
+
elementTypeDef: ofType,
|
|
215
|
+
fields: [
|
|
216
|
+
valueEnt,
|
|
217
|
+
{ ...valueEnt, name: 'each', e: { node: 'field', path: ['value'] } },
|
|
218
|
+
],
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
exports.mkArrayDef = mkArrayDef;
|
|
189
222
|
function isRepeatedRecord(fd) {
|
|
190
223
|
return fd.type === 'array' && fd.elementTypeDef.type === 'record_element';
|
|
191
224
|
}
|
|
192
225
|
exports.isRepeatedRecord = isRepeatedRecord;
|
|
226
|
+
function isScalarArray(td) {
|
|
227
|
+
return td.type === 'array' && td.elementTypeDef.type !== 'record_element';
|
|
228
|
+
}
|
|
229
|
+
exports.isScalarArray = isScalarArray;
|
|
193
230
|
function isMatrixOperation(x) {
|
|
194
231
|
return ['left', 'right', 'full', 'inner'].includes(x);
|
|
195
232
|
}
|
|
196
233
|
exports.isMatrixOperation = isMatrixOperation;
|
|
197
234
|
function isJoinable(sd) {
|
|
198
235
|
return [
|
|
236
|
+
'composite',
|
|
199
237
|
'table',
|
|
200
238
|
'sql_select',
|
|
201
239
|
'query_source',
|
|
202
240
|
'array',
|
|
203
241
|
'record',
|
|
204
|
-
'composite',
|
|
205
242
|
].includes(sd.type);
|
|
206
243
|
}
|
|
207
244
|
exports.isJoinable = isJoinable;
|
|
208
|
-
function isJoined(
|
|
209
|
-
return 'join' in
|
|
245
|
+
function isJoined(sd) {
|
|
246
|
+
return 'join' in sd;
|
|
210
247
|
}
|
|
211
248
|
exports.isJoined = isJoined;
|
|
212
249
|
function isJoinedSource(sd) {
|
|
@@ -330,7 +367,7 @@ function isSourceDef(sd) {
|
|
|
330
367
|
exports.isSourceDef = isSourceDef;
|
|
331
368
|
/** Is this the "FROM" table of a query tree */
|
|
332
369
|
function isBaseTable(def) {
|
|
333
|
-
if (
|
|
370
|
+
if (isJoinedSource(def)) {
|
|
334
371
|
return false;
|
|
335
372
|
}
|
|
336
373
|
if (isSourceDef(def)) {
|
|
@@ -339,10 +376,6 @@ function isBaseTable(def) {
|
|
|
339
376
|
return false;
|
|
340
377
|
}
|
|
341
378
|
exports.isBaseTable = isBaseTable;
|
|
342
|
-
function isScalarArray(def) {
|
|
343
|
-
return def.type === 'array' && def.elementTypeDef.type !== 'record_element';
|
|
344
|
-
}
|
|
345
|
-
exports.isScalarArray = isScalarArray;
|
|
346
379
|
function isLiteral(evalSpace) {
|
|
347
380
|
return evalSpace === 'literal';
|
|
348
381
|
}
|
|
@@ -362,7 +395,7 @@ function mergeEvalSpaces(...evalSpaces) {
|
|
|
362
395
|
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
363
396
|
function isLeafAtomic(fd) {
|
|
364
397
|
return (fd.type === 'string' ||
|
|
365
|
-
|
|
398
|
+
isTemporalType(fd.type) ||
|
|
366
399
|
fd.type === 'number' ||
|
|
367
400
|
fd.type === 'boolean' ||
|
|
368
401
|
fd.type === 'json' ||
|
|
@@ -378,18 +411,14 @@ function getIdentifier(n) {
|
|
|
378
411
|
return n.name;
|
|
379
412
|
}
|
|
380
413
|
exports.getIdentifier = getIdentifier;
|
|
381
|
-
function
|
|
414
|
+
function isTurtle(def) {
|
|
382
415
|
return def.type === 'turtle';
|
|
383
416
|
}
|
|
384
|
-
exports.
|
|
417
|
+
exports.isTurtle = isTurtle;
|
|
385
418
|
function isAtomic(def) {
|
|
386
419
|
return isAtomicFieldType(def.type);
|
|
387
420
|
}
|
|
388
421
|
exports.isAtomic = isAtomic;
|
|
389
|
-
function getAtomicFields(structDef) {
|
|
390
|
-
return structDef.fields.filter(isAtomic);
|
|
391
|
-
}
|
|
392
|
-
exports.getAtomicFields = getAtomicFields;
|
|
393
422
|
function isValueString(value, field) {
|
|
394
423
|
return field.type === 'string';
|
|
395
424
|
}
|
|
@@ -429,7 +458,9 @@ exports.TD = {
|
|
|
429
458
|
isDate: (td) => (td === null || td === void 0 ? void 0 : td.type) === 'date',
|
|
430
459
|
isTimestamp: (td) => (td === null || td === void 0 ? void 0 : td.type) === 'timestamp',
|
|
431
460
|
isTemporal(td) {
|
|
432
|
-
|
|
461
|
+
var _a;
|
|
462
|
+
const typ = (_a = td === null || td === void 0 ? void 0 : td.type) !== null && _a !== void 0 ? _a : '';
|
|
463
|
+
return isTemporalType(typ);
|
|
433
464
|
},
|
|
434
465
|
isError: (td) => (td === null || td === void 0 ? void 0 : td.type) === 'error',
|
|
435
466
|
eq(x, y) {
|