Closed mtoy-googly-moogly closed 2 years ago
@lloydtabb I suspect this is also the source of your "unknown dialect" error.
I don't think this has anything to do with the IDE. Consider these two tests:
This test passes:
test("unknown dialect issue (okay)", () => {
const code = `
explore: flights is table('aTable') {
join_one: my_join is not_yet_defined with astr
}
explore: not_yet_defined is table('aTable') {
primary_key: astr
}
`;
const m = new BetaModel(code);
m.translate();
const errList = m.errors().errors;
expect(errList[0].message).toBe("Undefined data source 'not_yet_defined'")
});
This test fails:
test("unknown dialect issue (bad)", () => {
const code = `
explore: exp is table('aTable') {
join_one: my_join is not_yet_defined with astr
}
explore: not_yet_defined is table('aTable') {
primary_key: astr
}
query: exp -> { project: * }
`;
const m = new BetaModel(code);
m.translate();
const errList = m.errors().errors;
expect(errList[0].message).toBe("Undefined data source 'not_yet_defined'")
});
● unknown dialect issue (bad)
Unknown Dialect //undefined_errror_dialect
21 | const d = dialectMap.get(name);
22 | if (d === undefined) {
> 23 | throw new Error(`Unknown Dialect ${name}`);
| ^
24 | }
25 | return d;
26 | }
at getDialect (packages/malloy/src/dialect/dialect_map.ts:23:11)
at new QueryStruct (packages/malloy/src/model/malloy_query.ts:2651:30)
at QueryStruct.addFieldsFromFieldList (packages/malloy/src/model/malloy_query.ts:2668:13)
at new QueryStruct (packages/malloy/src/model/malloy_query.ts:2653:10)
at Function.nextStructDef (packages/malloy/src/model/malloy_query.ts:1145:16)
at opOutputStruct (packages/malloy/src/lang/ast/ast-main.ts:86:28)
at Object.outputSpace (packages/malloy/src/lang/ast/ast-main.ts:1520:25)
at FullQuery.appendOps (packages/malloy/src/lang/ast/ast-main.ts:1743:21)
at FullQuery.queryComp (packages/malloy/src/lang/ast/ast-main.ts:1906:31)
Following the error up, we see first we log "Undefined data source 'not_yet_defined'"
, and return undefined
from NamedSource.modelStruct()
, then in the caller, NamedSource.structDef()
, we get a ModelFactory.structDef
which we pass up the chain.
That structDef has dialect = //undefined_errror_dialect
Trying to figure out why the query needs or cares about the dialect of the join, since it's not used.
You are right. Taking this bug.
Right, the error is returned when it is not possible to compute a non error version. what is supposed to happen is that because an error is generated, no one will try to use any compiled items. i'll track it down.
This file
Parses and highlights the incorrect forward reference.
However if I add ...
Then the entirety of the error text available to the user is "unknown dialect" ... somehow the IDE is reaching in and getting a fake error query which should never be used because the model didn't compile.