@malloydata/malloy 0.0.3 → 0.0.4
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/lang/ast/ast-expr.d.ts +0 -1
- package/dist/lang/ast/ast-main.d.ts +2 -2
- package/package.json +1 -1
- package/dist/connection_utils.js +0 -56
- package/dist/dialect/dialect.js +0 -77
- package/dist/dialect/dialect_map.js +0 -35
- package/dist/dialect/duckdb.js +0 -347
- package/dist/dialect/index.js +0 -27
- package/dist/dialect/postgres.js +0 -315
- package/dist/dialect/standardsql.js +0 -362
- package/dist/index.js +0 -47
- package/dist/lang/ast/apply-expr.js +0 -231
- package/dist/lang/ast/ast-expr.js +0 -1041
- package/dist/lang/ast/ast-main.js +0 -2087
- package/dist/lang/ast/ast-time-expr.js +0 -549
- package/dist/lang/ast/ast-types.js +0 -215
- package/dist/lang/ast/index.js +0 -34
- package/dist/lang/ast/time-utils.js +0 -94
- package/dist/lang/field-space.js +0 -631
- package/dist/lang/field-utils.js +0 -33
- package/dist/lang/index.js +0 -22
- package/dist/lang/parse-log.js +0 -41
- package/dist/lang/reference-list.js +0 -80
- package/dist/lang/space-field.js +0 -346
- package/dist/lang/test/document-help-context-walker.spec.js +0 -45
- package/dist/lang/test/document-symbol-walker.spec.js +0 -100
- package/dist/lang/test/field-symbols.spec.js +0 -172
- package/dist/lang/test/parse.spec.js +0 -1951
- package/dist/lang/test/test-translator.js +0 -334
- package/dist/lang/zone.js +0 -97
- package/dist/malloy.js +0 -2360
- package/dist/model/index.js +0 -34
- package/dist/model/malloy_query.js +0 -2994
- package/dist/model/malloy_types.js +0 -283
- package/dist/model/sql_block.js +0 -41
- package/dist/model/utils.js +0 -84
- package/dist/runtime_types.js +0 -15
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const space_field_1 = require("../space-field");
|
|
16
|
-
const field_space_1 = require("../field-space");
|
|
17
|
-
const ast_1 = require("../ast");
|
|
18
|
-
/*
|
|
19
|
-
** A set of tests to make sure structdefs can become fieldspaces
|
|
20
|
-
** and the fieldspace produces the same strcutdef
|
|
21
|
-
*/
|
|
22
|
-
describe("structdef comprehension", () => {
|
|
23
|
-
function mkStructDef(field) {
|
|
24
|
-
return {
|
|
25
|
-
type: "struct",
|
|
26
|
-
name: "test",
|
|
27
|
-
dialect: "standardsql",
|
|
28
|
-
structSource: { type: "table", tablePath: "test" },
|
|
29
|
-
structRelationship: { type: "basetable", connectionName: "test" },
|
|
30
|
-
fields: [field],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function fieldRef(fieldPath) {
|
|
34
|
-
return fieldPath.split(".").map((name) => new ast_1.FieldName(name));
|
|
35
|
-
}
|
|
36
|
-
test(`import string field`, () => {
|
|
37
|
-
const field = {
|
|
38
|
-
name: "t",
|
|
39
|
-
type: "string",
|
|
40
|
-
};
|
|
41
|
-
const struct = mkStructDef(field);
|
|
42
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
43
|
-
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
44
|
-
const oField = space.structDef().fields[0];
|
|
45
|
-
expect(oField).toEqual(field);
|
|
46
|
-
});
|
|
47
|
-
test(`import float field`, () => {
|
|
48
|
-
const field = {
|
|
49
|
-
name: "t",
|
|
50
|
-
type: "number",
|
|
51
|
-
numberType: "float",
|
|
52
|
-
};
|
|
53
|
-
const struct = mkStructDef(field);
|
|
54
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
55
|
-
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
56
|
-
const oField = space.structDef().fields[0];
|
|
57
|
-
expect(oField).toEqual(field);
|
|
58
|
-
});
|
|
59
|
-
test(`import integer field`, () => {
|
|
60
|
-
const field = {
|
|
61
|
-
name: "t",
|
|
62
|
-
type: "number",
|
|
63
|
-
numberType: "integer",
|
|
64
|
-
};
|
|
65
|
-
const struct = mkStructDef(field);
|
|
66
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
67
|
-
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
68
|
-
const oField = space.structDef().fields[0];
|
|
69
|
-
expect(oField).toEqual(field);
|
|
70
|
-
});
|
|
71
|
-
test(`import boolean field`, () => {
|
|
72
|
-
const field = {
|
|
73
|
-
name: "t",
|
|
74
|
-
type: "boolean",
|
|
75
|
-
};
|
|
76
|
-
const struct = mkStructDef(field);
|
|
77
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
78
|
-
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
79
|
-
const oField = space.structDef().fields[0];
|
|
80
|
-
expect(oField).toEqual(field);
|
|
81
|
-
});
|
|
82
|
-
test(`import nested field`, () => {
|
|
83
|
-
const field = {
|
|
84
|
-
name: "t",
|
|
85
|
-
type: "struct",
|
|
86
|
-
dialect: "standardsql",
|
|
87
|
-
structRelationship: { type: "nested", field: "a", isArray: false },
|
|
88
|
-
structSource: { type: "nested" },
|
|
89
|
-
fields: [{ type: "string", name: "b" }],
|
|
90
|
-
};
|
|
91
|
-
const struct = mkStructDef(field);
|
|
92
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
93
|
-
expect(space.lookup(fieldRef("t.b")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
94
|
-
const oField = space.structDef().fields[0];
|
|
95
|
-
expect(oField).toEqual(field);
|
|
96
|
-
});
|
|
97
|
-
test(`import inline field`, () => {
|
|
98
|
-
const field = {
|
|
99
|
-
name: "t",
|
|
100
|
-
type: "struct",
|
|
101
|
-
dialect: "standardsql",
|
|
102
|
-
structRelationship: { type: "inline" },
|
|
103
|
-
structSource: { type: "inline" },
|
|
104
|
-
fields: [{ type: "string", name: "a" }],
|
|
105
|
-
};
|
|
106
|
-
const struct = mkStructDef(field);
|
|
107
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
108
|
-
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
109
|
-
const oField = space.structDef().fields[0];
|
|
110
|
-
expect(oField).toEqual(field);
|
|
111
|
-
});
|
|
112
|
-
test(`import join field`, () => {
|
|
113
|
-
const field = {
|
|
114
|
-
name: "t",
|
|
115
|
-
type: "struct",
|
|
116
|
-
dialect: "standardsql",
|
|
117
|
-
structRelationship: {
|
|
118
|
-
type: "one",
|
|
119
|
-
onExpression: [
|
|
120
|
-
{ type: "field", path: "aKey" },
|
|
121
|
-
"=",
|
|
122
|
-
{ type: "field", path: "t.a" },
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
structSource: { type: "table", tablePath: "t" },
|
|
126
|
-
fields: [{ type: "string", name: "a" }],
|
|
127
|
-
};
|
|
128
|
-
const struct = mkStructDef(field);
|
|
129
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
130
|
-
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
|
|
131
|
-
const oField = space.structDef().fields[0];
|
|
132
|
-
expect(oField).toEqual(field);
|
|
133
|
-
});
|
|
134
|
-
test(`import query stage field`, () => {
|
|
135
|
-
const field = {
|
|
136
|
-
name: "t",
|
|
137
|
-
type: "turtle",
|
|
138
|
-
pipeline: [
|
|
139
|
-
{
|
|
140
|
-
type: "reduce",
|
|
141
|
-
fields: ["a"],
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
};
|
|
145
|
-
const struct = mkStructDef(field);
|
|
146
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
147
|
-
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.QueryFieldStruct);
|
|
148
|
-
const oField = space.structDef().fields[0];
|
|
149
|
-
expect(oField).toEqual(field);
|
|
150
|
-
});
|
|
151
|
-
test("import struct with parameters", () => {
|
|
152
|
-
const struct = mkStructDef({ name: "f", type: "string" });
|
|
153
|
-
struct.parameters = {
|
|
154
|
-
cReqStr: {
|
|
155
|
-
name: "cReqStr",
|
|
156
|
-
type: "string",
|
|
157
|
-
value: null,
|
|
158
|
-
constant: false,
|
|
159
|
-
},
|
|
160
|
-
cOptStr: {
|
|
161
|
-
name: "cOptStr",
|
|
162
|
-
type: "string",
|
|
163
|
-
value: ["value"],
|
|
164
|
-
constant: false,
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
const space = new field_space_1.StaticSpace(struct);
|
|
168
|
-
expect(space.lookup(fieldRef("cReqStr")).found).toBeInstanceOf(space_field_1.DefinedParameter);
|
|
169
|
-
expect(space.lookup(fieldRef("cOptStr")).found).toBeInstanceOf(space_field_1.DefinedParameter);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
//# sourceMappingURL=field-symbols.spec.js.map
|