From aa057161863c39f31c3c68670c14f792c72ce37b Mon Sep 17 00:00:00 2001 From: Ashley Van Spankeren <25673124+ashleyvansp@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:39:10 -0700 Subject: [PATCH 1/2] Fix delta external table kind detection The KQL case expression compared tolower(TableType) against "Delta" (capitalized), which never matches since tolower() produces "delta". This caused all delta external tables to be incorrectly loaded as kind=storage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Parser/KustoLoader/KustoExternalTableBulkLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs b/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs index 0c99c31..f89c810 100644 --- a/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs +++ b/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs @@ -4,7 +4,7 @@ namespace KustoSchemaTools.Parser.KustoLoader { public class KustoExternalTableBulkLoader : KustoBulkEntityLoader { - const string LoadExternalTables = ".show external tables | extend Properties = parse_json(Properties), ConnectionString=tostring(parse_json(ConnectionStrings)[0]) | project EntityName = TableName, Folder, DocString, Kind = case(tolower(TableType) == \"sql\", \"sql\", tolower(TableType) ==\"Delta\", \"delta\", \"storage\"), DataFormat = tolower(tostring(Properties.Format)), FileExtentions = tostring(Properties.FileExtension), IncludeHeaders = tostring(Properties.IncludeHeaders), Encoding = tostring(Properties.Encoding), NamePrefix = tostring(Properties.NamePrefix), Compressed = tobool(Properties.Compressed), SqlTable = tostring(Properties.TargetEntityName), CreateIfNotExists = tobool(Properties. CreateIfNotExists), PrimaryKey = tostring(Properties.PrimaryKey), SqlDialect = tostring(Properties.SqlDialect), Properties | project EntityName, Body = bag_pack_columns(Folder, DocString, Kind, DataFormat,FileExtentions, IncludeHeaders, Encoding, NamePrefix, Compressed, SqlTable, CreateIfNotExists, PrimaryKey, SqlDialect, Properties)"; + const string LoadExternalTables = ".show external tables | extend Properties = parse_json(Properties), ConnectionString=tostring(parse_json(ConnectionStrings)[0]) | project EntityName = TableName, Folder, DocString, Kind = case(tolower(TableType) == \"sql\", \"sql\", tolower(TableType) ==\"delta\", \"delta\", \"storage\"), DataFormat = tolower(tostring(Properties.Format)), FileExtentions = tostring(Properties.FileExtension), IncludeHeaders = tostring(Properties.IncludeHeaders), Encoding = tostring(Properties.Encoding), NamePrefix = tostring(Properties.NamePrefix), Compressed = tobool(Properties.Compressed), SqlTable = tostring(Properties.TargetEntityName), CreateIfNotExists = tobool(Properties. CreateIfNotExists), PrimaryKey = tostring(Properties.PrimaryKey), SqlDialect = tostring(Properties.SqlDialect), Properties | project EntityName, Body = bag_pack_columns(Folder, DocString, Kind, DataFormat,FileExtentions, IncludeHeaders, Encoding, NamePrefix, Compressed, SqlTable, CreateIfNotExists, PrimaryKey, SqlDialect, Properties)"; const string LoadExternalTableAdditionalData = ".show database schema as csl script | where DatabaseSchemaScript contains \".create external table\" or DatabaseSchemaScript contains \".create-or-alter external table\" | parse DatabaseSchemaScript with * \"pathformat = \" PathFormat:string \"\\n\"* | parse DatabaseSchemaScript with * \"partition by \" Partitions:string \"\\n\"* | parse DatabaseSchemaScript with *\"h@\\\"\" ConnectionString:string \"\\\"\"* | parse DatabaseSchemaScript with * \".create\" * \"external table \" Table:string \" (\" Columns:string \")\"* | mv-apply S=split(Columns,\",\") to typeof(string) on (extend C = split(S, ':') | extend B=bag_pack(trim('\\\\W',tostring(C[0])), C[1]) | summarize Schema=make_bag(B)) | extend Partitions = trim(\"[\\\\(\\\\)\\\\r]\",Partitions), PathFormat = trim(\"\\\\)\",trim(\"\\\\r\",trim(\"\\\\(\",PathFormat))) | project EntityName=Table, Body= bag_pack_columns(Schema, ConnectionString, Partitions, PathFormat)"; public KustoExternalTableBulkLoader() : base(d => d.ExternalTables) { } From c75668193287432f61900b66a882535b35baf43f Mon Sep 17 00:00:00 2001 From: Ashley Van Spankeren <25673124+ashleyvansp@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:51:06 -0700 Subject: [PATCH 2/2] Update KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Parser/KustoLoader/KustoExternalTableBulkLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs b/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs index f89c810..686013c 100644 --- a/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs +++ b/KustoSchemaTools/Parser/KustoLoader/KustoExternalTableBulkLoader.cs @@ -4,7 +4,7 @@ namespace KustoSchemaTools.Parser.KustoLoader { public class KustoExternalTableBulkLoader : KustoBulkEntityLoader { - const string LoadExternalTables = ".show external tables | extend Properties = parse_json(Properties), ConnectionString=tostring(parse_json(ConnectionStrings)[0]) | project EntityName = TableName, Folder, DocString, Kind = case(tolower(TableType) == \"sql\", \"sql\", tolower(TableType) ==\"delta\", \"delta\", \"storage\"), DataFormat = tolower(tostring(Properties.Format)), FileExtentions = tostring(Properties.FileExtension), IncludeHeaders = tostring(Properties.IncludeHeaders), Encoding = tostring(Properties.Encoding), NamePrefix = tostring(Properties.NamePrefix), Compressed = tobool(Properties.Compressed), SqlTable = tostring(Properties.TargetEntityName), CreateIfNotExists = tobool(Properties. CreateIfNotExists), PrimaryKey = tostring(Properties.PrimaryKey), SqlDialect = tostring(Properties.SqlDialect), Properties | project EntityName, Body = bag_pack_columns(Folder, DocString, Kind, DataFormat,FileExtentions, IncludeHeaders, Encoding, NamePrefix, Compressed, SqlTable, CreateIfNotExists, PrimaryKey, SqlDialect, Properties)"; + const string LoadExternalTables = ".show external tables | extend Properties = parse_json(Properties), ConnectionString=tostring(parse_json(ConnectionStrings)[0]) | project EntityName = TableName, Folder, DocString, Kind = case(tolower(TableType) == \"sql\", \"sql\", tolower(TableType) ==\"delta\", \"delta\", \"storage\"), DataFormat = tolower(tostring(Properties.Format)), FileExtensions = tostring(Properties.FileExtension), IncludeHeaders = tostring(Properties.IncludeHeaders), Encoding = tostring(Properties.Encoding), NamePrefix = tostring(Properties.NamePrefix), Compressed = tobool(Properties.Compressed), SqlTable = tostring(Properties.TargetEntityName), CreateIfNotExists = tobool(Properties. CreateIfNotExists), PrimaryKey = tostring(Properties.PrimaryKey), SqlDialect = tostring(Properties.SqlDialect), Properties | project EntityName, Body = bag_pack_columns(Folder, DocString, Kind, DataFormat,FileExtensions, IncludeHeaders, Encoding, NamePrefix, Compressed, SqlTable, CreateIfNotExists, PrimaryKey, SqlDialect, Properties)"; const string LoadExternalTableAdditionalData = ".show database schema as csl script | where DatabaseSchemaScript contains \".create external table\" or DatabaseSchemaScript contains \".create-or-alter external table\" | parse DatabaseSchemaScript with * \"pathformat = \" PathFormat:string \"\\n\"* | parse DatabaseSchemaScript with * \"partition by \" Partitions:string \"\\n\"* | parse DatabaseSchemaScript with *\"h@\\\"\" ConnectionString:string \"\\\"\"* | parse DatabaseSchemaScript with * \".create\" * \"external table \" Table:string \" (\" Columns:string \")\"* | mv-apply S=split(Columns,\",\") to typeof(string) on (extend C = split(S, ':') | extend B=bag_pack(trim('\\\\W',tostring(C[0])), C[1]) | summarize Schema=make_bag(B)) | extend Partitions = trim(\"[\\\\(\\\\)\\\\r]\",Partitions), PathFormat = trim(\"\\\\)\",trim(\"\\\\r\",trim(\"\\\\(\",PathFormat))) | project EntityName=Table, Body= bag_pack_columns(Schema, ConnectionString, Partitions, PathFormat)"; public KustoExternalTableBulkLoader() : base(d => d.ExternalTables) { }