@malloydata/malloy 0.0.80-dev230903192621 → 0.0.80-dev230905212201
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/field-space/query-spaces.d.ts +1 -0
- package/dist/lang/ast/field-space/query-spaces.js +34 -72
- package/dist/lang/ast/query-items/field-references.d.ts +1 -2
- package/dist/lang/ast/query-items/field-references.js +2 -5
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1 -3
- package/dist/lang/lib/Malloy/MalloyParser.js +757 -777
- package/dist/lang/malloy-to-ast.js +4 -6
- package/dist/lang/test/parse-expects.js +11 -4
- package/dist/lang/test/query.spec.js +61 -2
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ export declare abstract class QuerySpace extends RefinedSpace implements QueryFi
|
|
|
17
17
|
private exprSpace;
|
|
18
18
|
astEl?: MalloyElement | undefined;
|
|
19
19
|
abstract readonly segmentType: 'reduce' | 'project' | 'index';
|
|
20
|
+
expandedWild: Record<string, string[]>;
|
|
20
21
|
constructor(queryInputSpace: FieldSpace, refineThis: model.PipeSegment | undefined);
|
|
21
22
|
private addRefineFromFields;
|
|
22
23
|
log(s: string): void;
|
|
@@ -65,6 +65,7 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
65
65
|
constructor(queryInputSpace, refineThis) {
|
|
66
66
|
super(queryInputSpace.emptyStructDef());
|
|
67
67
|
this.queryInputSpace = queryInputSpace;
|
|
68
|
+
this.expandedWild = {};
|
|
68
69
|
this.exprSpace = new query_input_space_1.QueryInputSpace(queryInputSpace, this);
|
|
69
70
|
if (refineThis)
|
|
70
71
|
this.addRefineFromFields(refineThis);
|
|
@@ -111,93 +112,49 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
111
112
|
}
|
|
112
113
|
setEntry(name, value) {
|
|
113
114
|
super.setEntry(name, value);
|
|
114
|
-
// Everything in this namespace is
|
|
115
|
+
// Everything in this namespace is an output field
|
|
115
116
|
value.outputField = true;
|
|
116
117
|
}
|
|
117
118
|
addWild(wild) {
|
|
118
|
-
|
|
119
|
+
var _a;
|
|
119
120
|
let current = this.exprSpace;
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
for (let pi = 0; pi < parts.length; pi++) {
|
|
128
|
-
const part = parts[pi];
|
|
129
|
-
const prevParts = parts.slice(0, pi);
|
|
130
|
-
const parentRef = pi > 0 ? prevParts.join('.') : undefined;
|
|
131
|
-
const fullName = [...prevParts.join('.'), part].join('.');
|
|
132
|
-
if (part === '*') {
|
|
133
|
-
for (const [name, entry] of current.entries()) {
|
|
134
|
-
if (this.entry(name)) {
|
|
135
|
-
logConflict(name, parentRef);
|
|
136
|
-
success = false;
|
|
137
|
-
}
|
|
138
|
-
if (model.expressionIsScalar(entry.typeDesc().expressionType)) {
|
|
139
|
-
this.setEntry(name, entry);
|
|
140
|
-
conflictMap[name] = fullName;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
else if (part === '**') {
|
|
145
|
-
// TODO actually handle **
|
|
146
|
-
wild.log('** is currently broken');
|
|
147
|
-
success = false;
|
|
148
|
-
// const spaces: {space: FieldSpace; ref: string | undefined}[] = [
|
|
149
|
-
// {space: current, ref: undefined},
|
|
150
|
-
// ];
|
|
151
|
-
// let toExpand: {space: FieldSpace; ref: string | undefined} | undefined;
|
|
152
|
-
// while ((toExpand = spaces.pop())) {
|
|
153
|
-
// for (const [name, entry] of toExpand.space.entries()) {
|
|
154
|
-
// if (this.entry(name)) {
|
|
155
|
-
// logConflict(name, toExpand.ref);
|
|
156
|
-
// success = false;
|
|
157
|
-
// }
|
|
158
|
-
// if (model.expressionIsScalar(entry.typeDesc().expressionType)) {
|
|
159
|
-
// this.setEntry(name, entry);
|
|
160
|
-
// conflictMap[name] = toExpand.ref
|
|
161
|
-
// ? `${toExpand.ref}.${name}`
|
|
162
|
-
// : name;
|
|
163
|
-
// }
|
|
164
|
-
// if (entry instanceof StructSpaceField) {
|
|
165
|
-
// spaces.push({
|
|
166
|
-
// space: entry.fieldSpace,
|
|
167
|
-
// ref: [
|
|
168
|
-
// ...(parentRef ? [parentRef] : []),
|
|
169
|
-
// ...(toExpand.ref ? [toExpand.ref] : []),
|
|
170
|
-
// name,
|
|
171
|
-
// ].join('.'),
|
|
172
|
-
// });
|
|
173
|
-
// }
|
|
174
|
-
// }
|
|
175
|
-
// }
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
121
|
+
const joinPath = [];
|
|
122
|
+
if (wild.joinPath) {
|
|
123
|
+
// walk path to determine namespace for *
|
|
124
|
+
for (const pathPart of wild.joinPath.list) {
|
|
125
|
+
const part = pathPart.refString;
|
|
126
|
+
joinPath.push(part);
|
|
178
127
|
const ent = current.entry(part);
|
|
179
128
|
if (ent) {
|
|
180
129
|
if (ent instanceof static_space_1.StructSpaceField) {
|
|
181
130
|
current = ent.fieldSpace;
|
|
182
131
|
}
|
|
183
132
|
else {
|
|
184
|
-
|
|
185
|
-
|
|
133
|
+
pathPart.log(`Field '${part}' does not contain rows and cannot be expanded with '*'`);
|
|
134
|
+
return;
|
|
186
135
|
}
|
|
187
136
|
}
|
|
188
137
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
138
|
+
pathPart.log(`No such field as '${part}'`);
|
|
139
|
+
return;
|
|
191
140
|
}
|
|
192
141
|
}
|
|
193
142
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
143
|
+
const dialect = this.dialectObj();
|
|
144
|
+
for (const [name, entry] of current.entries()) {
|
|
145
|
+
if (this.entry(name)) {
|
|
146
|
+
const conflict = (_a = this.expandedWild[name]) === null || _a === void 0 ? void 0 : _a.join('.');
|
|
147
|
+
wild.log(`Cannot expand '${name}' in '${wild.refString}' because a field with that name already exists${conflict ? ` (conflicts with ${conflict})` : ''}`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const eType = entry.typeDesc();
|
|
151
|
+
if (model.isAtomicFieldType(eType.dataType) &&
|
|
152
|
+
model.expressionIsScalar(eType.expressionType) &&
|
|
153
|
+
(dialect === undefined || !dialect.ignoreInProject(name))) {
|
|
154
|
+
this.setEntry(name, entry);
|
|
155
|
+
this.expandedWild[name] = joinPath.concat(name);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
201
158
|
}
|
|
202
159
|
}
|
|
203
160
|
/**
|
|
@@ -232,8 +189,13 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
232
189
|
}
|
|
233
190
|
queryFieldDefs() {
|
|
234
191
|
const fields = [];
|
|
235
|
-
for (const [, field] of this.entries()) {
|
|
192
|
+
for (const [name, field] of this.entries()) {
|
|
236
193
|
if (field instanceof space_field_1.SpaceField) {
|
|
194
|
+
const wildPath = this.expandedWild[name];
|
|
195
|
+
if (wildPath) {
|
|
196
|
+
fields.push(wildPath.join('.'));
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
237
199
|
const fieldQueryDef = field.getQueryFieldDef(this.exprSpace);
|
|
238
200
|
if (fieldQueryDef) {
|
|
239
201
|
if (field instanceof wild_space_field_1.WildSpaceField) {
|
|
@@ -62,12 +62,11 @@ export declare class DimensionFieldReference extends FieldReference {
|
|
|
62
62
|
}
|
|
63
63
|
export declare class WildcardFieldReference extends MalloyElement implements Noteable {
|
|
64
64
|
readonly joinPath: FieldReference | undefined;
|
|
65
|
-
readonly star: '*' | '**';
|
|
66
65
|
elementType: string;
|
|
67
66
|
note?: Annotation;
|
|
68
67
|
readonly isNoteableObj = true;
|
|
69
68
|
extendNote: typeof extendNoteMethod;
|
|
70
|
-
constructor(joinPath: FieldReference | undefined
|
|
69
|
+
constructor(joinPath: FieldReference | undefined);
|
|
71
70
|
getFieldDef(): FieldDef;
|
|
72
71
|
get refString(): string;
|
|
73
72
|
}
|
|
@@ -177,10 +177,9 @@ class DimensionFieldReference extends FieldReference {
|
|
|
177
177
|
}
|
|
178
178
|
exports.DimensionFieldReference = DimensionFieldReference;
|
|
179
179
|
class WildcardFieldReference extends malloy_element_1.MalloyElement {
|
|
180
|
-
constructor(joinPath
|
|
180
|
+
constructor(joinPath) {
|
|
181
181
|
super();
|
|
182
182
|
this.joinPath = joinPath;
|
|
183
|
-
this.star = star;
|
|
184
183
|
this.elementType = 'wildcardFieldReference';
|
|
185
184
|
this.isNoteableObj = true;
|
|
186
185
|
this.extendNote = noteable_1.extendNoteMethod;
|
|
@@ -190,9 +189,7 @@ class WildcardFieldReference extends malloy_element_1.MalloyElement {
|
|
|
190
189
|
throw this.internalError('fielddef request from wildcard reference');
|
|
191
190
|
}
|
|
192
191
|
get refString() {
|
|
193
|
-
return this.joinPath
|
|
194
|
-
? `${this.joinPath.refString}.${this.star}`
|
|
195
|
-
: this.star;
|
|
192
|
+
return this.joinPath ? `${this.joinPath.refString}.*` : '*';
|
|
196
193
|
}
|
|
197
194
|
}
|
|
198
195
|
exports.WildcardFieldReference = WildcardFieldReference;
|
|
@@ -1595,7 +1595,6 @@ export declare class IndexElementContext extends ParserRuleContext {
|
|
|
1595
1595
|
fieldPath(): FieldPathContext | undefined;
|
|
1596
1596
|
DOT(): TerminalNode | undefined;
|
|
1597
1597
|
STAR(): TerminalNode | undefined;
|
|
1598
|
-
STARSTAR(): TerminalNode | undefined;
|
|
1599
1598
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
1600
1599
|
get ruleIndex(): number;
|
|
1601
1600
|
enterRule(listener: MalloyParserListener): void;
|
|
@@ -2232,8 +2231,7 @@ export declare class FieldCollectionContext extends ParserRuleContext {
|
|
|
2232
2231
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
2233
2232
|
}
|
|
2234
2233
|
export declare class CollectionWildCardContext extends ParserRuleContext {
|
|
2235
|
-
STAR(): TerminalNode
|
|
2236
|
-
STARSTAR(): TerminalNode | undefined;
|
|
2234
|
+
STAR(): TerminalNode;
|
|
2237
2235
|
fieldPath(): FieldPathContext | undefined;
|
|
2238
2236
|
DOT(): TerminalNode | undefined;
|
|
2239
2237
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|