malloy
malloy copied to clipboard
Remove group by join
Found this test for an experimental feature we need to kill.
it('group by join - simple group by', async () => {
await expect(`
run: aircraft->{
group_by: aircraft_models
aggregate: aircraft_count
}
`).malloyResultMatches(expressionModel, {
aircraft_models_id: 7102802,
aircraft_count: 58,
});
});
// when structs are referenced in queries, incorporate the
// primary key of struct and add the struct as a join to the result.
getAsQueryField(): QueryFieldStruct {
if (this.fieldDef.primaryKey === undefined) {
throw new Error(
`Joined explores can only be included in queries if a primary key is defined: '${this.getFullOutputName()}' has no primary key`
);
}
const pkField = this.getPrimaryKeyField(this.fieldDef);
const pkType = pkField.fieldDef.type;
if (pkType !== 'string' && pkType !== 'number') {
throw new Error(
`Unknown Primary key data type for ${pkField.fieldDef.name}`
);
}
const aliasName = getIdentifier(this.fieldDef);
const pkName = this.fieldDef.primaryKey;
const fieldDef: FieldDef = {
type: pkType,
name: `${aliasName}_id`,
e: [
{
type: 'field',
// path: pkField.getFullOutputName(),
path: pkField.getIdentifier(),
},
],
};
return new QueryFieldStruct(fieldDef, this, `${aliasName}.${pkName}`);
}