microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`KS208: The name '' does not refer to any known database`. referencing another database when analyze `.create-or-alter function`

theta3 opened this issue · comments

commented

I use ServerSymbolLoader and call LoadDatabaseAsync() to create DatabaseSymbol for all the databases. Then create

 var knownGlobalState = GlobalState.Default.WithCluster(new ClusterSymbol(clusterUri, databaseSymbols));

However, when I call var result = KustoCode.ParseAndAnalyze(func, knownGlobalState).GetDiagnostics();, there is error KS208: The name 'otherdatabase' does not refer to any known database

Does GlobalState support multiple databases? Did I miss some steps?

You should post questions about ServerSymbolLoader on the repo that is from: https://github.com/mattwar/Kusto.Toolkit

There are steps published in the Kusto.Toolkit readme about using the ServerSymbolLoader and dealing with queries that also reference other databases using the SymbolResolver class.

To answer your question, GlobalState does support declaring multiple clusters and multiple databases per cluster. However, it looks like you used the ServerSymbolLoader to load the database symbols independently of the global state and then added them as the default cluster to the global state. This is okay, but you also need to tell the GlobalState which database is the default database using the GlobalState.WithDatabase() method. This step is skipped when you use the loader's AddOrUpdateDefaultDatabase() method. It both loads the database and sets it as the default for you.

commented

Thank you so much! After following the examples here https://github.com/mattwar/Kusto.Toolkit/blob/master/src/Toolkit/docs/SymbolResolver.md. I was able to get it to work.

The reason I posted the issue here and not in the Toolkit repo was because I thought I have constructed the Symbols correctly and the issue was with either GlobalState or ParseAndAnalyze which is in this repo