Query to know if table exists in LA workspace


I need to query  LA workspace(s) and the query will include couple of tables.
The LA workspace need not have all tables and hence I need to something like tableifExists and if true, query the table. (Something like columnifexists).
After using tableIfExists for all table, I need to do union of all table and fetch the results.

Could you please help me with the query?

3 Replies

Hi @Vino55,

I do not think this is possible. It is like you are trying to avoid exposing errors due to not only specific data being there but any data. What is the scenario here?

You can use isfuzzy parameter in union clause. See the example


// Using union isfuzzy=true to access non-existing view:
let View_1 = view () { print x=1 };
let View_2 = view () { print x=1 };
let OtherView_1 = view () { print x=1 };
union isfuzzy=true
(View_1 | where x > 0),
(View_2 | where x > 0),
(View_3 | where x > 0)
| count

Hi @Stanislav Zhelyazkov ,


Currently most of the  RP data (who are not onboarded to resource specific) move to AzureDiagnostics.


We are moving to Resource specific feature and due to which we are creating workflow in LA.
By this, LA workspace will always have our table with defined schema.

Hence this table will always exist in LA workspace when we query. if there is no data, LA is going to return 0 records but not error.


However, the workspace may or may not have table AzureDiagnostics. You can quickly check by creating a new workspace and you will not find table AzureDiagnostics. If there is no data, since table will not exist, LA will return error.


As our intent to combine data from both table (AzureDiagnostics and our new table) from our workbook, our customer workspace may or may not have AzureDiagnostic table. Hence we need to handle this in our query used in our workbook template.
I will try to follow @Ketan Ghelani 's suggestion.