Skip to content

Commit

Permalink
Small tweaks and comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherswenson committed Nov 15, 2024
1 parent 2234699 commit 8e2b010
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
10 changes: 2 additions & 8 deletions packages/malloy/src/lang/ast/source-elements/cube-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ export class CubeSource extends Source {
parameterSpace: ParameterSpace | undefined,
pList: HasParameter[] | undefined
): SourceDef {
// TODO think about params for cube sources and test that this works...
/**
* source: foo(a is 1) is cube(
* duckdb.table('foo') extend { dimension: x is a },
* duckdb.table('bar') extend { dimension: x is a }
* )
*/
const sourceDefs = this.sources.map(source =>
source.withParameters(parameterSpace, pList)
);
Expand Down Expand Up @@ -79,7 +72,8 @@ export class CubeSource extends Source {
as: undefined,
e: {node: 'cubeField'},
cubeUsage: {fields: [fieldName], joinedUsage: {}},
// TODO code and location are wrong...
code: this.code,
location: this.codeLocation,
};
fields.push(cubeField);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/malloy/src/lang/ast/struct-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export function opOutputStruct(
logTo.logError(
'failed-to-compute-output-schema',
`INTERNAL ERROR model/Segment.nextStructDef: ${e.message}\n` +
`QUERY: ${inspect(opDesc, {breakLength: 72, depth: Infinity})}\n` +
`STACK: ${e.stack}`
`QUERY: ${inspect(opDesc, {breakLength: 72, depth: Infinity})}`
);
}
}
Expand Down
12 changes: 5 additions & 7 deletions packages/malloy/src/model/cube_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
SourceDef,
} from './malloy_types';

// TODO handle joins...

type CubeError =
| {code: 'not_a_cube'; data: {path: string[]}}
| {code: 'cube_not_defined'; data: {path: string[]}}
Expand All @@ -34,11 +32,12 @@ function _resolveCubeSources(
if (source.type === 'cube') {
let found = false;
overSources: for (const inputSource of source.sources) {
const fieldNames = new Set<string>();
for (const field of inputSource.fields) {
fieldNames.add(field.as ?? field.name);
}
for (const usage of cubeUsage.fields) {
// TODO handle joins
if (
inputSource.fields.find(f => f.as ?? f.name === usage) === undefined
) {
if (!fieldNames.has(usage)) {
continue overSources;
}
}
Expand Down Expand Up @@ -266,7 +265,6 @@ function cubeUsageWithoutNonCubeFields(
}
return {
fields: cubeUsage.fields.filter(f => isCubeField(sourceFieldsByName[f])),
// TODO not sure about this?
joinedUsage: cubeUsage.joinedUsage,
};
}
3 changes: 2 additions & 1 deletion packages/malloy/src/model/malloy_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,8 @@ export interface TableSourceDef extends SourceDefBase {

export interface CubeSourceDef extends SourceDefBase {
type: 'cube';
sources: SourceDef[]; // TODO maybe this should be StructRef[], but that makes a lot of stuff harder.
// TODO make cube sources support StructRefs
sources: SourceDef[];
}

/*
Expand Down

0 comments on commit 8e2b010

Please sign in to comment.