in code/KustoCopyConsole/Kusto/DbCommandClient.cs [230:293]
public async Task CreateTempTableAsync(
KustoPriority priority,
string tableName,
string tempTableName,
CancellationToken ct)
{
await _commandQueue.RequestRunAsync(
priority,
async () =>
{
var commandText = @$"
.execute database script with (ContinueOnErrors=true) <|
.create table ['{tempTableName}'] based-on ['{tableName}'] with (folder=""kc"")
.delete table ['{tempTableName}'] policy extent_tags_retention
.alter table ['{tempTableName}'] policy ingestionbatching
```
{{
""MaximumBatchingTimeSpan"" : ""00:00:15"",
""MaximumNumberOfItems"" : 2000,
""MaximumRawDataSizeMB"": 2048
}}
```
.alter-merge table ['{tempTableName}'] policy merge
```
{{
""AllowRebuild"": false,
""AllowMerge"": false
}}
```
.delete table ['{tempTableName}'] policy partitioning
.alter table ['{tempTableName}'] policy restricted_view_access true
";
var properties = new ClientRequestProperties();
var reader = await _provider.ExecuteControlCommandAsync(
DatabaseName,
commandText,
properties);
var result = reader
.ToEnumerable(r => new
{
OperationId = (Guid)(r[0]),
CommandType = (string)(r[1]),
CommandText = (string)(r[2]),
Result = (string)(r[3]),
Reason = (string)(r[4])
})
.Where(o => o.Result != "Completed")
.FirstOrDefault();
if (result != null)
{
throw new CopyException(
$"Command failed in operation '{result.OperationId}': "
+ $"{result.CommandType} / '{result.CommandText}' / {result.Result} "
+ $"'{result.Reason}'",
false);
}
});
}