3487 Created new function GetTablesForDashboard in KustoDataSource to load tables for ADS Dashboard (#1056)

This commit is contained in:
Justin M
2020-08-25 11:55:07 -07:00
committed by GitHub
parent 14f5a3e0f1
commit 3f725b5aec

View File

@@ -572,7 +572,9 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
return GetDatabaseMetadata(includeSizeDetails); return GetDatabaseMetadata(includeSizeDetails);
case DataSourceMetadataType.Database: // show folders, tables, and functions case DataSourceMetadataType.Database: // show folders, tables, and functions
return GetDatabaseSchema(objectMetadata, includeSizeDetails); return includeSizeDetails
? GetTablesForDashboard(objectMetadata)
: GetDatabaseSchema(objectMetadata);
case DataSourceMetadataType.Table: // show columns case DataSourceMetadataType.Table: // show columns
var table = objectMetadata as TableMetadata; var table = objectMetadata as TableMetadata;
@@ -621,7 +623,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
} }
/// <inheritdoc/> /// <inheritdoc/>
private IEnumerable<DataSourceObjectMetadata> GetDatabaseSchema(DataSourceObjectMetadata objectMetadata, bool includeSizeDetails) private IEnumerable<DataSourceObjectMetadata> GetDatabaseSchema(DataSourceObjectMetadata objectMetadata)
{ {
// Check if the database exists // Check if the database exists
ValidationUtils.IsTrue<ArgumentException>(DatabaseExists(objectMetadata.Name).Result, $"Database '{objectMetadata}' does not exist."); ValidationUtils.IsTrue<ArgumentException>(DatabaseExists(objectMetadata.Name).Result, $"Database '{objectMetadata}' does not exist.");
@@ -637,12 +639,18 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
LoadTableSchema(objectMetadata); LoadTableSchema(objectMetadata);
LoadFunctionSchema(objectMetadata); LoadFunctionSchema(objectMetadata);
if (!includeSizeDetails) return GetAllMetadata(objectMetadata.Urn);
}
private IEnumerable<DataSourceObjectMetadata> GetTablesForDashboard(DataSourceObjectMetadata objectMetadata)
{
string newKey = $"{DatabaseKeyPrefix}.{objectMetadata.Urn}";
if (!_tableMetadata.ContainsKey(newKey) || !_tableMetadata[newKey].Any())
{ {
return GetAllMetadata(objectMetadata.Urn); LoadTableSchema(objectMetadata);
} }
string newKey = $"{DatabaseKeyPrefix}.{objectMetadata.Urn}";
return _tableMetadata[newKey].OrderBy(x => x.PrettyName, StringComparer.OrdinalIgnoreCase); return _tableMetadata[newKey].OrderBy(x => x.PrettyName, StringComparer.OrdinalIgnoreCase);
} }