Skip to content

Commit 5b7971e

Browse files
Merge pull request #7148 from dyadav7/user/deepyadav/pack_bag_links
Added related links to pack_all, bag_unpack, bag_pack, updated examples
2 parents 0adaeb6 + 11ccc05 commit 5b7971e

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

data-explorer/kusto/query/bag-unpack-plugin.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Use a wildcard `*` as the first parameter to include all columns of the source t
4040

4141
Using the plugin without an *OutputSchema* can have severe performance implications in large datasets and should be avoided.
4242

43-
Providing an *OutputSchema* allows the query engine to optimize the query execution, as it can determine the output schema without needing to parse and analyze the input data. This is beneficial when the input data is large or complex. See the [Examples with performance implications](#examples-with-performance-implications) of using the plugin with and without a defined *OutputSchema*.
43+
Providing an *OutputSchema* allows the query engine to optimize the query execution, as it can determine the output schema without needing to parse and analyze the input data. OutputSchema is beneficial when the input data is large or complex. See the [Examples with performance implications](#examples-with-performance-implications) of using the plugin with and without a defined *OutputSchema*.
4444

4545
## Returns
4646

@@ -196,26 +196,26 @@ datatable(d:dynamic)
196196

197197
:::moniker range="azure-data-explorer"
198198
> [!div class="nextstepaction"]
199-
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA0tJLAHCpJxUjRSrlMq8xNzMZE2uaC4FIIByNaqV/BJzU5WsFJS88jPylHQUlBzTgVwjg1pNHRwKXRLLUuEKTfAo9Eoszs3MQ6g1BquN5apRSC1LzClNLElVSEpMjy/NK0hMztZI0VSwUtAA6bUqLinKzEvXUQDqssrJz0vXBADtklvGyQAAAA==" target="_blank">Run the query</a>
199+
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA0tJLAHCpJxUjRSrlMq8xNzMZE2uaC4FIIByNaqV%2FBJzU5WsFJS88jPylHQUlBzTgVwjg1pNHVSFCnCVLollqSCVHqmZ6RklQBFDcwOYRhNMjQgbEotzM%2FNS4ZYYg9XGctUopJYl5pQmlqQqJCWmx5fmFSQmZ2ukaAIA%2Fh1sgL8AAAA%3D" target="_blank">Run the query</a>
200200
::: moniker-end
201201

202202
```kusto
203203
datatable(d:dynamic)
204204
[
205205
dynamic({"Name": "John", "Age":20}),
206-
dynamic({"Name": "Dave", "Age":40}),
206+
dynamic({ "Name": "Dave", "Height": 170, "Age":40}),
207207
dynamic({"Name": "Jasmine", "Age":30}),
208208
]
209-
| evaluate bag_unpack(d) : (Name:string, Age:long)
209+
| evaluate bag_unpack(d)
210210
```
211211

212212
**Output**
213213

214-
|Name |Age |
215-
|---------|---------|
216-
|John | 20 |
217-
|Dave | 40 |
218-
|Jasmine | 30 |
214+
|Age |Height |Name |
215+
|--|--|--|
216+
| 20 | | John |
217+
| 40 | 170 | Dave |
218+
| 30 | | Jasmine |
219219

220220
**Expand a bag with an *OutputSchema* and use the wildcard `*` option**:
221221

@@ -299,3 +299,4 @@ The output is the same for both queries. The first 10 rows of the output are sho
299299
300300
* [parse_json function](./parse-json-function.md)
301301
* [mv-expand operator](./mv-expand-operator.md)
302+
* [pack-all function](./pack-all-function.md)

data-explorer/kusto/query/pack-all-function.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.date: 08/11/2024
1212
Creates a [dynamic](scalar-data-types/dynamic.md) property bag object from all the columns of the tabular expression.
1313

1414
> [!NOTE]
15-
> The representation of the returned object isn't guaranteed to be byte-level-compatible between runs. For example, properties that appear in the bag may appear in a different order.
15+
> The representation of the returned object isn't guaranteed to be byte-level-compatible between runs. For example, properties that appear in the bag might appear in a different order.
1616
1717
## Syntax
1818

@@ -28,39 +28,37 @@ Creates a [dynamic](scalar-data-types/dynamic.md) property bag object from all t
2828

2929
## Example
3030

31-
The following query will use `pack_all()` to create columns for the below table.
32-
33-
|SourceNumber |TargetNumber| CharsCount
34-
|---|---|---
35-
|555-555-1234 |555-555-1212 | 46
36-
|555-555-1234 |555-555-1213 | 50
37-
|555-555-1313 | | 42
38-
| |555-555-3456 | 74
31+
The following query uses `pack_all()` to create packed columns.
3932

4033
:::moniker range="azure-data-explorer"
4134
> [!div class="nextstepaction"]
42-
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA32PsQrCMBCG9zxFtrRwgm2SCgWn4uAigm4ikrZHFNOkpCko+PCmIFgXOY6f+/j+4VoV4tQGk4MbfYO7savRl0PwN6vhqLzG8Muqq/JD5UYbSuOsTsmJMCnlYtos54LB7MxyBqKAfwZnIJdzg0+IxV4OlLCZzIUsGKwEJWfyovgIaFu6V80d23Uf46KMSVL4oK22zsd/jNl0fXh+jeBHTN/V81O7+AAAAA==" target="_blank">Run the query</a>
35+
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA22KvQrCMBSF9zxFttvCFWyTVCg4FQcXEXQTkWgvUYxJSRNQ8OGt0OIiZzh%2FX6vjoLOlbOdTuFDdx3BzBvc6GIpTa6469I1PLtbWO5OzAwOl1KwohQQcY1ECygr%2FPQJQzadHfCsMbImcwQgJqSrAheTsyN6cnpFcy7f6cqd22Q120tZmOY7T2jgfaJOsXT26%2BPoRMSTKPx5KvAnUAAAA" target="_blank">Run the query</a>
4336
::: moniker-end
4437

4538
```kusto
46-
datatable(SourceNumber:string,TargetNumber:string,CharsCount:long)
39+
datatable(Source:string,Target:string,CharsCount:long)
4740
[
48-
'555-555-1234','555-555-1212',46,
49-
'555-555-1234','555-555-1213',50,
50-
'555-555-1313','',42,
51-
'','555-555-3456',74
41+
'555-1234','555-1212',46,
42+
'555-1234','555-1213',50,
43+
'555-1313','',42,
44+
'','555-3456',74
5245
]
5346
| extend Packed=pack_all(), PackedIgnoreNullEmpty=pack_all(true)
5447
```
5548

5649
**Output**
5750

58-
|SourceNumber |TargetNumber | CharsCount | Packed |PackedIgnoreNullEmpty
59-
|---|---|---|---|---
60-
|555-555-1234 |555-555-1212 | 46 |{"SourceNumber":"555-555-1234", "TargetNumber":"555-555-1212", "CharsCount": 46} | {"SourceNumber":"555-555-1234", "TargetNumber":"555-555-1212", "CharsCount": 46}
61-
|555-555-1234 |555-555-1213 | 50 |{"SourceNumber":"555-555-1234", "TargetNumber":"555-555-1213", "CharsCount": 50} | {"SourceNumber":"555-555-1234", "TargetNumber":"555-555-1213", "CharsCount": 50}
62-
|555-555-1313 | | 42 | {"SourceNumber":"555-555-1313", "TargetNumber":"", "CharsCount": 42} | {"SourceNumber":"555-555-1313", "CharsCount": 42}
63-
| |555-555-3456 | 74 | {"SourceNumber":"", "TargetNumber":"555-555-3456", "CharsCount": 74} | {"TargetNumber":"555-555-3456", "CharsCount": 74}
51+
|Source |Target | CharsCount | Packed |PackedIgnoreNullEmpty|
52+
|---|---|---|---|---|
53+
|555-1234 |555-1212 | 46 |{"Source":"555-1234", "Target":"555-1212", "CharsCount": 46} | {"Source":"555-1234", "Target":"555-1212", "CharsCount": 46}|
54+
|555-1234 |555-1213 | 50 |{"Source":"555-1234", "Target":"555-1213", "CharsCount": 50} | {"Source":"555-1234", "Target":"555-1213", "CharsCount": 50}|
55+
|555-1313 | | 42 | {"Source":"555-1313", "Target":"", "CharsCount": 42} | {"Source":"555-1313", "CharsCount": 42}|
56+
| |555-3456 | 74 | {"Source":"", "Target":"555-3456", "CharsCount": 74} | {"Target":"555-3456", "CharsCount": 74}|
6457

6558
> [!NOTE]
66-
> There is a difference between the *Packed* and the *PackedIgnoreNullEmpty* columns in the last two rows of the above example. These two rows included empty values that were ignored by *pack_all(true)*.
59+
> There's a difference between the *Packed* and the *PackedIgnoreNullEmpty* columns in the last two rows of the example. These two rows included empty values that were ignored by *pack_all(true)*.
60+
61+
## Related content
62+
63+
* [bag-pack function](./pack-function.md)
64+
* [bag-unpack plugin](./bag-unpack-plugin.md)

data-explorer/kusto/query/pack-function.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ print bag_pack("Level", "Information", "ProcessID", 1234, "Data", bag_pack("url"
5252

5353
|print_0|
5454
|--|
55-
|{"Level":"Information","ProcessID":1234,"Data":{"url":"www.bing.com"}}|
55+
|{"Level": "Information", "ProcessID": 1234, "Data": {"url":"www.bing.com"}}|
5656

5757
**Example 2**
5858

5959
The following example creates a property bag and extract value from property bag using '.' operator.
6060

6161
:::moniker range="azure-data-explorer"
6262
> [!div class="nextstepaction"]
63-
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA12PXwuCMBTF3wW%2Fw2VPCiv8V0Hgg9qrTz1GyE3HWMUUXZTQh2%2FTBeL2cvjtnHvPGlT63p4MPNcBfc7tq6%2FZEYRUdCYnNighUYlWLnHJhgG5dg6qF5K7jg%2BX%2BSWM4oRCGAQUSJYRCjNOdvsDhWjCeU7o3xxGFOKJFgXR3qvrfIF9FJMNlGOOPL0hrzqsHx4xXfTARSUd0024hraQb%2BJd395ZrTb4xtF%2BaZWy7vWuypjSSW6NpBabHRYb%2BQMdY4ddNwEAAA%3D%3D" target="_blank">Run the query</a>
63+
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA12PPwvCMBDF936KI1MLUfpPBaGLOLh00k2kXGsI0ZKUJqIFP7xJzFB6WR4%2F3rt7uaOxr%2B0ZxBHYOavX2LE9CGmoB0emjZBohJIzWjOtkVufNqOQPErg6nmWFyWFLE0pkJMgFDwtN9sdhfxPWd8rQoM7yykUgU8Eolv0BfYxTN6hng7IqxZ5M2D3jIkrYhfO%2BtjUxZotDHUSmx5G9WCdWeEbp%2FCbRSiYF5ca56m8XDtJA3YXAnbyBz3NWFQwAQAA" target="_blank">Run the query</a>
6464
::: moniker-end
6565

6666
```kusto
@@ -69,22 +69,22 @@ datatable (
6969
Destination: int,
7070
Message: string
7171
) [
72-
1234, 100, "AA",
73-
4567, 200, "BB",
74-
1212, 300, "CC"
72+
1234, 100, "Hi",
73+
4567, 200, "Hello",
74+
1212, 300, "Hey"
7575
]
76-
| extend MyBag=bag_pack("Dest", Destination, "Mesg", Message)
76+
| extend MyBag=bag_pack("Dest", Destination, "Text", Message)
7777
| project-away Source, Destination, Message
78-
| extend MyBag_Dest=MyBag.Dest, MyBag_Mesg=MyBag.Mesg
78+
| extend MyBag_Dest=MyBag.Dest, MyBag_Text=MyBag.Text
7979
```
8080

8181
**Results**
8282

83-
|MyBag|MyBag_Dest|MyBag_Mesg|
83+
|MyBag|MyBag_Dest|MyBag_Text|
8484
|--|--|--|
85-
|{"Dest":100,"Mesg":"AA"}|100|AA|
86-
|{"Dest":200,"Mesg":"BB"}|200|BB|
87-
|{"Dest":300,"Mesg":"CC"}|300|CC|
85+
|{"Dest":100,"Text":"Hi" }|100|Hi|
86+
|{"Dest":200,"Text":"Hello" }|200|Hello|
87+
|{"Dest":300,"Text":"Hey" }|300|Hey|
8888

8989
**Example 3**
9090

@@ -147,3 +147,8 @@ SmsMessages
147147
| 555-555-1234 | 555-555-1212 | {"CharsCount":"46","AttachmentSize":"250","AttachmentType":"jpeg","AttachmentName":"Pic2"} |
148148
| 555-555-1234 | 555-555-1213 | {"CharsCount":"50","AttachmentSize":"300","AttachmentType":"png","AttachmentName":"Pic3"} |
149149
| 555-555-1234 | 555-555-1212 | {"CharsCount":"46","AttachmentSize":"300","AttachmentType":"png","AttachmentName":"Pic3"} |
150+
151+
## Related content
152+
153+
* [pack-all function](./pack-all-function.md)
154+
* [bag-unpack plugin](./bag-unpack-plugin.md)

0 commit comments

Comments
 (0)