Skip to content

Commit f4abd1f

Browse files
committed
almost done with docs
1 parent 2f1dc69 commit f4abd1f

File tree

4 files changed

+89
-33
lines changed

4 files changed

+89
-33
lines changed

docs/en-US/New-KustoIngestionMapping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Accept wildcard characters: False
5858
5959
### -Kind
6060
61-
Specifies the type of mapping. __Default value is `Unknown`__.
61+
Specifies the type of mapping. __Default value is `Csv`__.
6262

6363
```yaml
6464
Type: IngestionMappingKind

docs/en-US/Set-KustoIngestionMapping.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,63 @@ schema: 2.0.0
99

1010
## SYNOPSIS
1111

12-
{{ Fill in the Synopsis }}
12+
Creates or updates an ingestion mapping that can be associated with a specific format and a specific table or database.
1313

1414
## SYNTAX
1515

1616
```powershell
1717
Set-KustoIngestionMapping
18-
[-MappingName] <String>
19-
[-Table] <String>
18+
[-Name] <String>
19+
[[-Table] <String>]
2020
[[-Database] <String>]
21-
-IngestionMapping <IngestionMapping>
22-
[-RemoveOldestIfRequired]
21+
-Mapping <IngestionMapping>
22+
[-Force]
2323
[-OutputType <OutputType>]
2424
[-RequestProperties <ClientRequestProperties>]
2525
[<CommonParameters>]
2626
```
2727

2828
## DESCRIPTION
2929

30-
{{ Fill in the Description }}
30+
The `Set-KustoIngestionMapping` cmdlet can be used to create or update an ingestion mapping that can be associated with a specific format and a specific table or database. For more information see [__.create ingestion mapping command__](https://learn.microsoft.com/en-us/kusto/management/create-ingestion-mapping-command?view=microsoft-fabric)
31+
and [__.create-or-alter ingestion mapping command__](https://learn.microsoft.com/en-us/kusto/management/create-or-alter-ingestion-mapping-command?view=microsoft-fabric).
3132

3233
## EXAMPLES
3334

34-
### Example 1
35+
### Example 1: Creates a new ingestion mapping on a Table
3536

3637
```powershell
37-
PS C:\> {{ Add example code here }}
38+
$mapping = New-KustoIngestionMapping -Columns $columns -Kind Json
39+
Set-KustoIngestionMapping myNewMapping -Table myTable -Mapping $mapping
3840
```
3941

40-
{{ Add example description here }}
42+
This example demonstrates how to create a new `Json` mapping with name `myNewMapping` on `myTable` in a Database specified by `Connect-Kusto -Database`.
43+
44+
### Example 2: Creates a new ingestion mapping on a Database
45+
46+
```powershell
47+
$mapping = New-KustoIngestionMapping -Columns $columns
48+
Set-KustoIngestionMapping myNewMapping -Database myDb -Mapping $mapping
49+
```
50+
51+
This example demonstrates how to create a new `Csv` mapping with name `myNewMapping` on `myDb`.
52+
53+
> [!TIP]
54+
>
55+
> When `-Table` isn't specified, the mapping is created at Database level.
56+
57+
### Example 3: Update an ingestion mapping on a Database
58+
59+
```powershell
60+
$mapping = New-KustoIngestionMapping -Columns $columns
61+
Set-KustoIngestionMapping myNewMapping -Database myDb -Mapping $mapping -Force
62+
```
4163

4264
## PARAMETERS
4365

4466
### -Database
4567

46-
{{ Fill Database Description }}
68+
Specifies the Kusto Database where the new ingestion mapping is being created.
4769

4870
> [!NOTE]
4971
>
@@ -61,9 +83,14 @@ Accept pipeline input: False
6183
Accept wildcard characters: False
6284
```
6385
64-
### -IngestionMapping
86+
### -Mapping
6587
66-
{{ Fill IngestionMapping Description }}
88+
This parameter indicates how to map data from the source file to the actual columns in the table.
89+
You can define the format value with the relevant mapping type.
90+
91+
To create a new mapping object, checkout [`New-KustoIngestionMapping`](New-KustoIngestionMapping.md) and [`New-KustoColumnMapping`](New-KustoColumnMapping.md) documentations.
92+
93+
See [__data mappings__](https://learn.microsoft.com/en-us/kusto/management/mappings?view=microsoft-fabric) and [__Class `KustoIngestionProperties`__](https://learn.microsoft.com/en-us/kusto/api/netfx/kusto-ingest-client-reference?view=microsoft-fabric#class-kustoingestionproperties) for more information.
6794

6895
```yaml
6996
Type: IngestionMapping
@@ -77,9 +104,9 @@ Accept pipeline input: False
77104
Accept wildcard characters: False
78105
```
79106

80-
### -MappingName
107+
### -Name
81108

82-
{{ Fill MappingName Description }}
109+
The name for the ingestion mapping.
83110

84111
```yaml
85112
Type: String
@@ -104,15 +131,15 @@ Aliases:
104131
Accepted values: PSObject, Json, Csv, DataTable, Html
105132
106133
Required: False
107-
Position: 1
134+
Position: Named
108135
Default value: None
109136
Accept pipeline input: False
110137
Accept wildcard characters: False
111138
```
112139

113-
### -RemoveOldestIfRequired
140+
### -Force
114141

115-
{{ Fill RemoveOldestIfRequired Description }}
142+
If a mapping with same name in the given scope already exists, `.create` fails. Use this switch to execute a `.create-or-alter` control command instead.
116143

117144
```yaml
118145
Type: SwitchParameter
@@ -148,14 +175,18 @@ Accept wildcard characters: False
148175

149176
### -Table
150177

151-
{{ Fill Table Description }}
178+
Specifies the Table where the new ingestion mapping is being created.
179+
180+
> [!NOTE]
181+
>
182+
> This parameter is optional. If not specified, the ingestion mapping is created on Database level.
152183

153184
```yaml
154185
Type: String
155186
Parameter Sets: (All)
156187
Aliases:
157188
158-
Required: True
189+
Required: False
159190
Position: 0
160191
Default value: None
161192
Accept pipeline input: False
@@ -182,3 +213,7 @@ For more information, see [about_CommonParameters](http://go.microsoft.com/fwlin
182213
## NOTES
183214

184215
## RELATED LINKS
216+
217+
[__.create ingestion mapping command__](https://learn.microsoft.com/en-us/kusto/management/create-ingestion-mapping-command?view=microsoft-fabric)
218+
219+
[__.create-or-alter ingestion mapping command__](https://learn.microsoft.com/en-us/kusto/management/create-or-alter-ingestion-mapping-command?view=microsoft-fabric)

src/PowerShellKusto/Commands/NewKustoIngestionMappingCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed class NewKustoIngestionMappingCommand : PSCmdlet
1414
public ColumnMapping[]? Columns { get; set; }
1515

1616
[Parameter(Position = 1)]
17-
public IngestionMappingKind Kind { get; set; } = IngestionMappingKind.Unknown;
17+
public IngestionMappingKind Kind { get; set; } = IngestionMappingKind.Csv;
1818

1919
[Parameter]
2020
[ValidateNotNullOrEmpty]

src/PowerShellKusto/Commands/SetKustoIngestionMappingCommand.cs

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,27 @@ namespace PowerShellKusto.Commands;
1212
public sealed class SetKustoIngestionMappingCommand : KustoReaderCommandBase
1313
{
1414
[Parameter(Mandatory = true, Position = 0)]
15-
public string Table { get; set; } = null!;
15+
public string Name { get; set; } = null!;
1616

17-
[Parameter(Mandatory = true, Position = 2)]
18-
public string MappingName { get; set; } = null!;
17+
[Parameter(Position = 2)]
18+
public string? Table { get; set; }
1919

2020
[Parameter(Mandatory = true)]
21-
public IngestionMapping IngestionMapping { get; set; } = null!;
21+
public IngestionMapping Mapping { get; set; } = null!;
2222

2323
[Parameter]
24-
public SwitchParameter RemoveOldestIfRequired { get; set; }
24+
public SwitchParameter Force { get; set; }
2525

2626
protected override void EndProcessing()
2727
{
2828
try
2929
{
3030
Database ??= Builder?.InitialCatalog;
31-
using ICslAdminProvider client = KustoClientFactory.CreateCslAdminProvider(Builder);
32-
string command = CslCommandGenerator.GenerateTableMappingCreateCommand(
33-
mappingKind: IngestionMapping.IngestionMappingKind,
34-
entityName: Table,
35-
mappingName: MappingName,
36-
mapping: IngestionMapping.IngestionMappings,
37-
removeOldestIfRequired: RemoveOldestIfRequired);
31+
string command = Table is null
32+
? GetDatabaseCommand()
33+
: GetTableCommand();
3834

35+
using ICslAdminProvider client = KustoClientFactory.CreateCslAdminProvider(Builder);
3936
using IDataReader reader = RequestProperties is null
4037
? client.ExecuteControlCommand(Database, command)
4138
: client.ExecuteControlCommand(Database, command, RequestProperties);
@@ -48,4 +45,28 @@ protected override void EndProcessing()
4845
WriteError(error);
4946
}
5047
}
48+
49+
private string GetTableCommand() => Force
50+
? CslCommandGenerator.GenerateTableMappingCreateOrAlterCommand(
51+
mappingKind: Mapping.IngestionMappingKind,
52+
tableName: Table,
53+
mappingName: Name,
54+
mapping: Mapping.IngestionMappings)
55+
: CslCommandGenerator.GenerateTableMappingCreateCommand(
56+
mappingKind: Mapping.IngestionMappingKind,
57+
entityName: Table,
58+
mappingName: Name,
59+
mapping: Mapping.IngestionMappings);
60+
61+
private string GetDatabaseCommand() => Force
62+
? CslCommandGenerator.GenerateDatabaseMappingCreateOrAlterCommand(
63+
mappingKind: Mapping.IngestionMappingKind,
64+
entityName: Database,
65+
mappingName: Name,
66+
mapping: Mapping.IngestionMappings)
67+
: CslCommandGenerator.GenerateDatabaseMappingCreateCommand(
68+
mappingKind: Mapping.IngestionMappingKind,
69+
entityName: Database,
70+
mappingName: Name,
71+
mapping: Mapping.IngestionMappings);
5172
}

0 commit comments

Comments
 (0)