Skip to content

Commit

Permalink
Fix issue with referencing field in doubly-nested join inside a nest (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherswenson authored Jan 13, 2025
1 parent eb6f3c2 commit b88762b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/malloy/src/lang/ast/field-space/query-spaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
emptyCompositeFieldUsage,
emptyNarrowedCompositeFieldResolution,
isEmptyCompositeFieldUsage,
joinedCompositeFieldUsage,
mergeCompositeFieldUsage,
narrowCompositeFieldResolution,
NarrowedCompositeFieldResolution,
Expand Down Expand Up @@ -220,9 +221,10 @@ export abstract class QueryOperationSpace
const lookup = this.exprSpace.lookup(reference);
// Should always be found...
if (lookup.found && lookup.found instanceof StructSpaceFieldBase) {
return (
return joinedCompositeFieldUsage(
joinPath.slice(0, -1),
lookup.found.fieldDef().onCompositeFieldUsage ??
emptyCompositeFieldUsage()
emptyCompositeFieldUsage()
);
}
throw new Error('Unexpected join lookup was not found or not a struct');
Expand Down
13 changes: 13 additions & 0 deletions packages/malloy/src/lang/test/query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,19 @@ describe('query:', () => {
group_by: b.ai
}`).toTranslate();
});
test('reference field in double nested join inside nest', () => {
expect(`
source: a_2 is a extend { join_one: b is b extend {
join_one: c is b on 1 = c.ai
} with astr }
run: a_2 -> {
nest: x is {
group_by: ai is b.c.ai
}
}
`).toTranslate();
});
test.skip('reference join as field', () => {
expect(`run: a -> {
extend: { join_one: b with astr }
Expand Down

0 comments on commit b88762b

Please sign in to comment.