@malloydata/malloy 0.0.203-dev241021134413 → 0.0.203-dev241022191525
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 +11 -0
- package/dist/dialect/dialect.js +27 -0
- package/dist/dialect/duckdb/duckdb.js +2 -2
- package/dist/dialect/mysql/mysql.js +12 -15
- package/dist/dialect/pg_impl.js +7 -9
- package/dist/dialect/snowflake/snowflake.js +12 -17
- package/dist/dialect/standardsql/standardsql.js +13 -16
- package/dist/dialect/trino/trino.js +9 -12
- package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
- package/dist/lang/ast/expressions/expr-record-literal.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-record-literal.js +28 -25
- package/dist/lang/ast/expressions/expr-time-extract.js +3 -3
- package/dist/lang/ast/expressions/expr-time.js +2 -2
- package/dist/lang/ast/expressions/for-range.js +1 -1
- package/dist/lang/ast/expressions/time-literal.js +1 -1
- package/dist/lang/ast/query-builders/index-builder.d.ts +1 -0
- package/dist/lang/ast/query-builders/index-builder.js +4 -0
- package/dist/lang/ast/query-builders/reduce-builder.d.ts +1 -0
- package/dist/lang/ast/query-builders/reduce-builder.js +4 -0
- package/dist/lang/ast/source-properties/join.js +1 -0
- package/dist/lang/ast/time-utils.d.ts +1 -3
- package/dist/lang/ast/time-utils.js +24 -34
- package/dist/lang/ast/types/expression-def.js +2 -2
- package/dist/lang/ast/types/query-builder.d.ts +1 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +49 -14
- package/dist/lang/lib/Malloy/MalloyParser.js +1784 -1538
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +48 -11
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +30 -7
- package/dist/lang/malloy-to-ast.d.ts +4 -1
- package/dist/lang/malloy-to-ast.js +21 -32
- package/dist/lang/test/query.spec.js +7 -2
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/model/malloy_query.d.ts +1 -0
- package/dist/model/malloy_query.js +15 -1
- package/dist/model/malloy_types.d.ts +43 -14
- package/dist/model/malloy_types.js +83 -2
- package/package.json +1 -1
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.mkTimeResult = exports.resolution = exports.castTo = exports.timeOffset = void 0;
|
|
26
26
|
const malloy_types_1 = require("../../model/malloy_types");
|
|
27
27
|
function timeOffset(timeType, from, op, n, timeframe) {
|
|
28
28
|
return {
|
|
29
29
|
node: 'delta',
|
|
30
30
|
kids: {
|
|
31
|
-
base:
|
|
31
|
+
base: (0, malloy_types_1.mkTemporal)(from, timeType),
|
|
32
32
|
delta: n,
|
|
33
33
|
},
|
|
34
34
|
op,
|
|
@@ -37,40 +37,30 @@ function timeOffset(timeType, from, op, n, timeframe) {
|
|
|
37
37
|
}
|
|
38
38
|
exports.timeOffset = timeOffset;
|
|
39
39
|
function castTo(castType, from, fromType, safe = false) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
let cast;
|
|
41
|
+
if (typeof castType !== 'string') {
|
|
42
|
+
cast = {
|
|
43
|
+
node: 'cast',
|
|
44
|
+
dstSQLType: castType.raw,
|
|
45
|
+
e: from,
|
|
46
|
+
safe,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const dstType = { type: castType };
|
|
51
|
+
cast = {
|
|
52
|
+
node: 'cast',
|
|
53
|
+
dstType,
|
|
54
|
+
e: from,
|
|
55
|
+
safe,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if ((0, malloy_types_1.isCastType)(fromType)) {
|
|
59
|
+
cast.srcType = { type: fromType };
|
|
48
60
|
}
|
|
49
61
|
return cast;
|
|
50
62
|
}
|
|
51
63
|
exports.castTo = castTo;
|
|
52
|
-
function castTimestampToDate(from, safe = false) {
|
|
53
|
-
const cast = {
|
|
54
|
-
node: 'cast',
|
|
55
|
-
dstType: 'date',
|
|
56
|
-
srcType: 'timestamp',
|
|
57
|
-
e: from,
|
|
58
|
-
safe,
|
|
59
|
-
};
|
|
60
|
-
return cast;
|
|
61
|
-
}
|
|
62
|
-
exports.castTimestampToDate = castTimestampToDate;
|
|
63
|
-
function castDateToTimestamp(from, safe = false) {
|
|
64
|
-
const cast = {
|
|
65
|
-
node: 'cast',
|
|
66
|
-
dstType: 'timestamp',
|
|
67
|
-
srcType: 'date',
|
|
68
|
-
e: from,
|
|
69
|
-
safe,
|
|
70
|
-
};
|
|
71
|
-
return cast;
|
|
72
|
-
}
|
|
73
|
-
exports.castDateToTimestamp = castDateToTimestamp;
|
|
74
64
|
function resolution(timeframe) {
|
|
75
65
|
switch (timeframe) {
|
|
76
66
|
case 'hour':
|
|
@@ -83,11 +73,11 @@ function resolution(timeframe) {
|
|
|
83
73
|
return 'date';
|
|
84
74
|
}
|
|
85
75
|
exports.resolution = resolution;
|
|
86
|
-
function
|
|
76
|
+
function mkTimeResult(t, tt) {
|
|
87
77
|
if (tt) {
|
|
88
78
|
return { ...t, timeframe: tt };
|
|
89
79
|
}
|
|
90
80
|
return t;
|
|
91
81
|
}
|
|
92
|
-
exports.
|
|
82
|
+
exports.mkTimeResult = mkTimeResult;
|
|
93
83
|
//# sourceMappingURL=time-utils.js.map
|
|
@@ -145,7 +145,7 @@ class ExprDuration extends ExpressionDef {
|
|
|
145
145
|
}
|
|
146
146
|
if (lhs.dataType === 'timestamp') {
|
|
147
147
|
const result = (0, time_utils_1.timeOffset)('timestamp', lhs.value, op, num.value, this.timeframe);
|
|
148
|
-
return (0, time_utils_1.
|
|
148
|
+
return (0, time_utils_1.mkTimeResult)({
|
|
149
149
|
dataType: 'timestamp',
|
|
150
150
|
expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
|
|
151
151
|
evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, num.evalSpace),
|
|
@@ -153,7 +153,7 @@ class ExprDuration extends ExpressionDef {
|
|
|
153
153
|
}, resultGranularity);
|
|
154
154
|
}
|
|
155
155
|
if ((0, malloy_types_1.isDateUnit)(this.timeframe)) {
|
|
156
|
-
return (0, time_utils_1.
|
|
156
|
+
return (0, time_utils_1.mkTimeResult)({
|
|
157
157
|
dataType: 'date',
|
|
158
158
|
expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
|
|
159
159
|
evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, num.evalSpace),
|
|
@@ -298,11 +298,12 @@ export declare class MalloyParser extends Parser {
|
|
|
298
298
|
static readonly RULE_fieldPath = 131;
|
|
299
299
|
static readonly RULE_joinName = 132;
|
|
300
300
|
static readonly RULE_fieldName = 133;
|
|
301
|
-
static readonly
|
|
302
|
-
static readonly
|
|
303
|
-
static readonly
|
|
304
|
-
static readonly
|
|
305
|
-
static readonly
|
|
301
|
+
static readonly RULE_sqlExploreNameRef = 134;
|
|
302
|
+
static readonly RULE_nameSQLBlock = 135;
|
|
303
|
+
static readonly RULE_connectionName = 136;
|
|
304
|
+
static readonly RULE_debugExpr = 137;
|
|
305
|
+
static readonly RULE_debugPartial = 138;
|
|
306
|
+
static readonly RULE_experimentalStatementForTesting = 139;
|
|
306
307
|
static readonly ruleNames: string[];
|
|
307
308
|
private static readonly _LITERAL_NAMES;
|
|
308
309
|
private static readonly _SYMBOLIC_NAMES;
|
|
@@ -450,10 +451,11 @@ export declare class MalloyParser extends Parser {
|
|
|
450
451
|
fieldPath(): FieldPathContext;
|
|
451
452
|
joinName(): JoinNameContext;
|
|
452
453
|
fieldName(): FieldNameContext;
|
|
453
|
-
justExpr(): JustExprContext;
|
|
454
454
|
sqlExploreNameRef(): SqlExploreNameRefContext;
|
|
455
455
|
nameSQLBlock(): NameSQLBlockContext;
|
|
456
456
|
connectionName(): ConnectionNameContext;
|
|
457
|
+
debugExpr(): DebugExprContext;
|
|
458
|
+
debugPartial(): DebugPartialContext;
|
|
457
459
|
experimentalStatementForTesting(): ExperimentalStatementForTestingContext;
|
|
458
460
|
sempred(_localctx: RuleContext, ruleIndex: number, predIndex: number): boolean;
|
|
459
461
|
private sqExpr_sempred;
|
|
@@ -2014,6 +2016,30 @@ export declare class ExprLiteralContext extends FieldExprContext {
|
|
|
2014
2016
|
exitRule(listener: MalloyParserListener): void;
|
|
2015
2017
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2016
2018
|
}
|
|
2019
|
+
export declare class ExprArrayLiteralContext extends FieldExprContext {
|
|
2020
|
+
OBRACK(): TerminalNode;
|
|
2021
|
+
fieldExpr(): FieldExprContext[];
|
|
2022
|
+
fieldExpr(i: number): FieldExprContext;
|
|
2023
|
+
CBRACK(): TerminalNode;
|
|
2024
|
+
COMMA(): TerminalNode[];
|
|
2025
|
+
COMMA(i: number): TerminalNode;
|
|
2026
|
+
constructor(ctx: FieldExprContext);
|
|
2027
|
+
enterRule(listener: MalloyParserListener): void;
|
|
2028
|
+
exitRule(listener: MalloyParserListener): void;
|
|
2029
|
+
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2030
|
+
}
|
|
2031
|
+
export declare class ExprLiteralRecordContext extends FieldExprContext {
|
|
2032
|
+
OCURLY(): TerminalNode;
|
|
2033
|
+
recordElement(): RecordElementContext[];
|
|
2034
|
+
recordElement(i: number): RecordElementContext;
|
|
2035
|
+
CCURLY(): TerminalNode;
|
|
2036
|
+
COMMA(): TerminalNode[];
|
|
2037
|
+
COMMA(i: number): TerminalNode;
|
|
2038
|
+
constructor(ctx: FieldExprContext);
|
|
2039
|
+
enterRule(listener: MalloyParserListener): void;
|
|
2040
|
+
exitRule(listener: MalloyParserListener): void;
|
|
2041
|
+
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2042
|
+
}
|
|
2017
2043
|
export declare class ExprFieldPropsContext extends FieldExprContext {
|
|
2018
2044
|
fieldExpr(): FieldExprContext;
|
|
2019
2045
|
fieldProperties(): FieldPropertiesContext;
|
|
@@ -2524,16 +2550,15 @@ export declare class FieldNameContext extends ParserRuleContext {
|
|
|
2524
2550
|
exitRule(listener: MalloyParserListener): void;
|
|
2525
2551
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2526
2552
|
}
|
|
2527
|
-
export declare class
|
|
2528
|
-
|
|
2529
|
-
EOF(): TerminalNode;
|
|
2553
|
+
export declare class SqlExploreNameRefContext extends ParserRuleContext {
|
|
2554
|
+
id(): IdContext;
|
|
2530
2555
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
2531
2556
|
get ruleIndex(): number;
|
|
2532
2557
|
enterRule(listener: MalloyParserListener): void;
|
|
2533
2558
|
exitRule(listener: MalloyParserListener): void;
|
|
2534
2559
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2535
2560
|
}
|
|
2536
|
-
export declare class
|
|
2561
|
+
export declare class NameSQLBlockContext extends ParserRuleContext {
|
|
2537
2562
|
id(): IdContext;
|
|
2538
2563
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
2539
2564
|
get ruleIndex(): number;
|
|
@@ -2541,16 +2566,26 @@ export declare class SqlExploreNameRefContext extends ParserRuleContext {
|
|
|
2541
2566
|
exitRule(listener: MalloyParserListener): void;
|
|
2542
2567
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2543
2568
|
}
|
|
2544
|
-
export declare class
|
|
2545
|
-
|
|
2569
|
+
export declare class ConnectionNameContext extends ParserRuleContext {
|
|
2570
|
+
string(): StringContext;
|
|
2546
2571
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
2547
2572
|
get ruleIndex(): number;
|
|
2548
2573
|
enterRule(listener: MalloyParserListener): void;
|
|
2549
2574
|
exitRule(listener: MalloyParserListener): void;
|
|
2550
2575
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2551
2576
|
}
|
|
2552
|
-
export declare class
|
|
2553
|
-
|
|
2577
|
+
export declare class DebugExprContext extends ParserRuleContext {
|
|
2578
|
+
fieldExpr(): FieldExprContext;
|
|
2579
|
+
EOF(): TerminalNode;
|
|
2580
|
+
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
2581
|
+
get ruleIndex(): number;
|
|
2582
|
+
enterRule(listener: MalloyParserListener): void;
|
|
2583
|
+
exitRule(listener: MalloyParserListener): void;
|
|
2584
|
+
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2585
|
+
}
|
|
2586
|
+
export declare class DebugPartialContext extends ParserRuleContext {
|
|
2587
|
+
partialAllowedFieldExpr(): PartialAllowedFieldExprContext;
|
|
2588
|
+
EOF(): TerminalNode;
|
|
2554
2589
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
2555
2590
|
get ruleIndex(): number;
|
|
2556
2591
|
enterRule(listener: MalloyParserListener): void;
|