From 3f725b5aec2f5c7ad012e60838e8de962b234145 Mon Sep 17 00:00:00 2001
From: Justin M <63619224+JustinMDotNet@users.noreply.github.com>
Date: Tue, 25 Aug 2020 11:55:07 -0700
Subject: [PATCH] 3487 Created new function GetTablesForDashboard in
KustoDataSource to load tables for ADS Dashboard (#1056)
---
.../DataSource/KustoDataSource.cs | 24 ++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs
index 7cba553c..68b41293 100644
--- a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs
+++ b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs
@@ -572,7 +572,9 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
return GetDatabaseMetadata(includeSizeDetails);
case DataSourceMetadataType.Database: // show folders, tables, and functions
- return GetDatabaseSchema(objectMetadata, includeSizeDetails);
+ return includeSizeDetails
+ ? GetTablesForDashboard(objectMetadata)
+ : GetDatabaseSchema(objectMetadata);
case DataSourceMetadataType.Table: // show columns
var table = objectMetadata as TableMetadata;
@@ -621,13 +623,13 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
}
///
- private IEnumerable GetDatabaseSchema(DataSourceObjectMetadata objectMetadata, bool includeSizeDetails)
+ private IEnumerable GetDatabaseSchema(DataSourceObjectMetadata objectMetadata)
{
// Check if the database exists
ValidationUtils.IsTrue(DatabaseExists(objectMetadata.Name).Result, $"Database '{objectMetadata}' does not exist.");
var allMetadata = GetAllMetadata(objectMetadata.Urn);
-
+
// if the records have already been loaded them return them
if (allMetadata.Any())
{
@@ -636,13 +638,19 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
LoadTableSchema(objectMetadata);
LoadFunctionSchema(objectMetadata);
+
+ return GetAllMetadata(objectMetadata.Urn);
+ }
- if (!includeSizeDetails)
- {
- return GetAllMetadata(objectMetadata.Urn);
- }
-
+ private IEnumerable GetTablesForDashboard(DataSourceObjectMetadata objectMetadata)
+ {
string newKey = $"{DatabaseKeyPrefix}.{objectMetadata.Urn}";
+
+ if (!_tableMetadata.ContainsKey(newKey) || !_tableMetadata[newKey].Any())
+ {
+ LoadTableSchema(objectMetadata);
+ }
+
return _tableMetadata[newKey].OrderBy(x => x.PrettyName, StringComparer.OrdinalIgnoreCase);
}