Skip to content

Commit a3aa1df

Browse files
Merge pull request #2519 from MicrosoftDocs/main638729929686627026sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents a699209 + ad260eb commit a3aa1df

10 files changed

+121
-30
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
ms.topic: include
3+
ms.date: 01/13/2025
4+
---
5+
6+
In the [help cluster](https://dataexplorer.azure.com/clusters/help/), there's a `Samples` database with a `StormEvents` table.

data-explorer/kusto/query/alias-statement.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ title: Alias statement
33
description: Learn how to use an alias statement to define an alias for a database that is used for a query.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/12/2025
77
---
88
# Alias statement
99

1010
> [!INCLUDE [applies](../includes/applies-to-version/applies.md)] [!INCLUDE [fabric](../includes/applies-to-version/fabric.md)] [!INCLUDE [azure-data-explorer](../includes/applies-to-version/azure-data-explorer.md)] [!INCLUDE [monitor](../includes/applies-to-version/monitor.md)] [!INCLUDE [sentinel](../includes/applies-to-version/sentinel.md)]
1111
12-
Alias statements allow you to define an alias for databases, which can be used later in the same query.
12+
Alias statements allow you to define an alias for a database, which can be used in the same query.
1313

1414
:::moniker range="azure-data-explorer"
1515
This is useful when you're working with several clusters but want to appear as if you're working on fewer clusters.
1616
The alias must be defined according to the following syntax, where *clustername* and *databasename* are existing and valid entities.
1717

18+
1819
## Syntax
1920

2021
`alias` database *DatabaseAliasName* `=` cluster("https://*clustername*.kusto.windows.net").database("*DatabaseName*")
@@ -50,7 +51,7 @@ The alias must be defined according to the following syntax, where *Eventhouse*
5051

5152
## Examples
5253

53-
In the [help cluster](https://dataexplorer.azure.com/clusters/help/), there's a `Samples` database with a `StormEvents` table.
54+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
5455

5556
First, count the number of records in that table.
5657

data-explorer/kusto/query/batches.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Batches
33
description: This article describes Batches.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/13/2025
77
---
88
# Batches
99

@@ -18,6 +18,8 @@ A query can include multiple tabular expression statements, as long as they're d
1818
1919
## Examples
2020

21+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
22+
2123
### Name tabular results
2224

2325
The following query produces two tabular results. User agent tools can then display those results with the appropriate name associated with each (`Count of events in Florida` and `Count of events in Guam`, respectively).
@@ -32,9 +34,25 @@ StormEvents | where State == "FLORIDA" | count | as ['Count of events in Florida
3234
StormEvents | where State == "GUAM" | count | as ['Count of events in Guam']
3335
```
3436

37+
**Output**
38+
39+
### [Count of events in Florida](#tab/florida)
40+
41+
| Count |
42+
| -- |
43+
| 1042 |
44+
45+
### [Count of events in Guam](#tab/guam)
46+
47+
| Count |
48+
| -- |
49+
| 4 |
50+
51+
---
52+
3553
### Share a calculation
3654

37-
Batching is useful for scenarios where a common calculation is shared by multiple subqueries, such as for dashboards. If the common calculation is complex, use the [materialize() function](materialize-function.md) and construct the query so that it will be executed only once:
55+
Batching is useful for scenarios where a common calculation is shared by multiple subqueries, such as for dashboards. If the common calculation is complex, use the [materialize() function](materialize-function.md) and construct the query so that it will be executed only once.
3856

3957
:::moniker range="azure-data-explorer"
4058
> [!div class="nextstepaction"]
@@ -46,3 +64,26 @@ let m = materialize(StormEvents | summarize n=count() by State);
4664
m | where n > 2000;
4765
m | where n < 10
4866
```
67+
68+
**Output**
69+
70+
### [Table 1](#tab/table-1)
71+
72+
| State | n |
73+
|--|--|
74+
| ILLINOIS | 2022 |
75+
| IOWA | 2337 |
76+
| KANSAS | 3166 |
77+
| MISSOURI | 2016 |
78+
| TEXAS | 4701 |
79+
80+
### [Table 2](#tab/table-2)
81+
82+
| State | n |
83+
|--|--|
84+
| GUAM | 2022 |
85+
| GULF OF ALASKA | 2337 |
86+
| HAWAII WATERS | 3166 |
87+
| LAKE ONTARIO | 2016 |
88+
89+
---

data-explorer/kusto/query/let-statement.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ To optimize multiple uses of the `let` statement within a single query, see [Opt
6565
6666
## Examples
6767

68+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
69+
6870
### Define scalar values
6971

7072
The following example uses a scalar expression statement.
@@ -91,6 +93,16 @@ let ['some number'] = 20;
9193
range y from 0 to ['some number'] step 5
9294
```
9395

96+
**Output**
97+
98+
|y|
99+
|---|
100+
|0|
101+
|5|
102+
|10|
103+
|15|
104+
|20|
105+
94106
### Create a user defined function with scalar calculation
95107

96108
This example uses the let statement with arguments for scalar calculation. The query defines function `MultiplyByN` for multiplying two numbers.

data-explorer/kusto/query/pattern-statement.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ title: Pattern statement
33
description: Learn how to use pattern statements to map string tuples to tabular expressions.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/15/2025
77
monikerRange: "microsoft-fabric || azure-data-explorer"
88
---
99

1010
# Pattern statement
1111

1212
> [!INCLUDE [applies](../includes/applies-to-version/applies.md)] [!INCLUDE [fabric](../includes/applies-to-version/fabric.md)] [!INCLUDE [azure-data-explorer](../includes/applies-to-version/azure-data-explorer.md)] [!INCLUDE [monitor](../includes/applies-to-version/monitor.md)] [!INCLUDE [sentinel](../includes/applies-to-version/sentinel.md)]
1313
14-
A **pattern** is a construct that maps string tuples to tabular expressions. Each pattern must *declare* a pattern name and optionally *define* a pattern mapping. Patterns that define a mapping return a tabular expression when invoked. Any two statements must be separated by a semicolon.
14+
A **pattern** is a construct that maps string tuples to tabular expressions.
1515

16-
*Empty patterns* are patterns that are declared but don't define a mapping. When invoked, they return error *SEM0036* along with the details of the missing pattern definitions in the HTTP header. Middle-tier applications that provide a Kusto Query Language (KQL) experience can use the returned details as part of their process to enrich KQL query results.
16+
Each pattern must *declare* a pattern name and optionally *define* a pattern mapping. Patterns that define a mapping return a tabular expression when invoked. Separate any two statements by a semicolon.
17+
18+
Empty patterns are patterns that are declared but don't define a mapping. When invoked, they return error *SEM0036* along with the details of the missing pattern definitions in the HTTP header.
19+
20+
Middle-tier applications that provide a Kusto Query Language (KQL) experience can use the returned details as part of their process to enrich KQL query results.
1721
For more information, see [Working with middle-tier applications](#work-with-middle-tier-applications).
1822

1923
## Syntax
@@ -56,11 +60,13 @@ For more information, see [Working with middle-tier applications](#work-with-mid
5660

5761
## Examples
5862

59-
In each of the following examples, a pattern is declared, defined, and then invoked.
63+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
6064

61-
### Define simple patterns
65+
In these examples, a pattern is defined.
6266

63-
The following example defines a pattern that maps states to an expression that returns its capital/major city.
67+
### Define a simple pattern
68+
69+
This example defines a pattern that maps states to an expression that returns its capital/major city.
6470

6571
:::moniker range="azure-data-explorer"
6672
> [!div class="nextstepaction"]
@@ -77,21 +83,23 @@ declare pattern country = (name:string)[state:string]
7783
country("Canada").Alberta
7884
```
7985

80-
**Output**
86+
**Output**
8187

8288
|Capital|
8389
|-------|
8490
|Edmonton|
8591

92+
### Define a scoped pattern
93+
94+
This example defines a pattern to scope data and metrics of application data. The pattern is invoked to return a union of the data.
95+
8696
:::moniker range="azure-data-explorer"
8797
> [!div class="nextstepaction"]
8898
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA62RsQrCMBCGd6Hv8FOHtlDFtrgoHQQXB5+gdAhpLJWahCRCofruJpjBCi7SwJHckfv/fJeG0Z4oBkmMYYrjICVKxETKvqPEdIKfmp02quNtUmkqJPNZDQSLMVjArjgiWZSsq+hIDIlqVyoxQhHeMgy4KHFDBiOwhTZM2vMDUokro8Ybhm5bZmEKJ/EWGPDcf+mfmfWm2lr8re8lbM22N3HyaZLPAZFPILINVlOSYg6S4heJizu33+aueyT3mtTnbo6+8QXib67/+wEAAA==" target="_blank">Run the query</a>
8999
::: moniker-end
90100

91-
The following example defines a pattern that defines some scoped application data.
92-
93101
```kusto
94-
declare pattern App = (applicationId:string)[scope:string]
102+
declare pattern App = (applicationId:string)[scope:string]
95103
{
96104
('a1').['Data'] = { range x from 1 to 5 step 1 | project App = "App #1", Data = x };
97105
('a1').['Metrics'] = { range x from 1 to 5 step 1 | project App = "App #1", Metrics = rand() };
@@ -147,23 +155,34 @@ union app("ApplicationX").["*"]
147155
| count
148156
```
149157

150-
**Returns semantic error**
158+
**Output semantic error**
159+
151160
> One or more pattern references were not declared. Detected pattern references: ["app('ApplicationX').['*']"]
152161
153162
## Work with middle-tier applications
154163

155164
A middle-tier application provides its users with the ability to use KQL and wants to enhance the experience by enriching the query results with augmented data from its internal service.
156165

157-
To this end, the application provides users with a pattern statement that returns tabular data that their users can use in their queries. The pattern's arguments are the keys the application will use to retrieve the enrichment data. When the user runs the query, the application does not parse the query itself but instead plans to leverage the error returned by an empty pattern to retrieve the keys it requires. So it prepends the query with the empty pattern declaration, sends it to the cluster for processing, and then parses the returned HTTP header to retrieve the values of missing pattern arguments. The application uses these values to look up the enrichment data and builds a new declaration that defines the appropriate enrichment data mapping. Finally, the application prepends the new definition to the user's query, resends it for processing, and returns the result it receives to the user.
166+
To this end, the application provides users with a pattern statement that returns tabular data that their users can use in their queries. The pattern's arguments are the keys the application will use to retrieve the enrichment data.
167+
168+
When the user runs the query, the application doesn't parse the query itself but instead uses the error returned by an empty pattern to retrieve the keys it requires. So it prepends the query with the empty pattern declaration, sends it to the cluster for processing, and then parses the returned HTTP header to retrieve the values of missing pattern arguments. The application uses these values to look up the enrichment data and builds a new declaration that defines the appropriate enrichment data mapping.
169+
170+
Finally, the application prepends the new definition to the query, resends it for processing, and returns the result it receives to the user.
158171

159172
### Example
160173

161-
In the following example, a middle-tier application provides the ability to enrich queries with longitude/latitude locations. The application uses an internal service to map IP addresses to longitude/latitude locations, and provides a pattern called `map_ip_to_longlat` for this purpose. Let's suppose the application gets the following query from the user:
174+
In the examples, a pattern is declared, defined, and then invoked.
175+
176+
#### Declare an empty pattern
177+
178+
In this example, a middle-tier application enriches queries with longitude/latitude locations. The application uses an internal service to map IP addresses to longitude/latitude locations, and provides a pattern called `map_ip_to_longlat`. When the query is run, it returns an error with missing pattern definitions:
162179

163180
```kusto
164181
map_ip_to_longlat("10.10.10.10")
165182
```
166183

184+
#### Declare and define a pattern
185+
167186
The application does not parse this query and hence does not know which IP address (*10.10.10.10*) was passed to the pattern. So it prepends the user query with an empty `map_ip_to_longlat` pattern declaration and sends it for processing:
168187

169188
```kusto
@@ -174,7 +193,11 @@ map_ip_to_longlat("10.10.10.10")
174193
The application receives the following error in response.
175194
> One or more pattern references were not declared. Detected pattern references: ["map_ip_to_longlat('10.10.10.10')"]
176195
177-
The application inspects the error, determines that the error indicates a missing pattern reference, and retrieves the missing IP address (*10.10.10.10*). It uses the IP address to look up the enrichment data in its internal service and builds a new pattern defining the mapping of the IP address to the corresponding longitude and latitude data. The new pattern is prepended to the user's query and run again. This time the query succeeds because the enrichment data is now declared in the query, and the result is sent to the user.
196+
#### Invoke a pattern
197+
198+
The application inspects the error, determines that the error indicates a missing pattern reference, and retrieves the missing IP address (*10.10.10.10*). It uses the IP address to look up the enrichment data in its internal service and builds a new pattern defining the mapping of the IP address to the corresponding longitude and latitude data. The new pattern is prepended to the user's query and run again.
199+
200+
This time the query succeeds because the enrichment data is now declared in the query, and the result is sent to the user.
178201

179202
:::moniker range="azure-data-explorer"
180203
> [!div class="nextstepaction"]

data-explorer/kusto/query/query-parameters-statement.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Query parameters declaration statement
33
description: Learn how to use the query parameters declaration statement to parameterize queries and protect against injection attacks.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/13/2025
77
monikerRange: "microsoft-fabric || azure-data-explorer"
88
---
99
# Query parameters declaration statement
@@ -44,6 +44,8 @@ To reference query parameters, the query text, or functions it uses, must first
4444
4545
## Example
4646

47+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
48+
4749
:::moniker range="azure-data-explorer"
4850
> [!div class="nextstepaction"]
4951
> <a href="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA4WNuw7CMBAE+0j5hytBpKAFBBUpXEOPrHgFjvzifAEi8fEkQUBJO9qZNWicZtC1A/enpFl7CDjPvH6o0HYMs3YxnGlLq+V8UxYHiezrG4JkKosn3S8Y9GlqkfeW0QgtvkAF80Y7+hVHL3FsR14nm6OBMhVN1WOfUJFE0e7TGL7/9l+H314eyAAAAA==" target="_blank">Run the query</a>

data-explorer/kusto/query/restrict-statement.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Restrict statement
33
description: Learn how to use the restrict statement to limit tabular views that are visible to subsequent query statements.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/13/2025
77
monikerRange: "microsoft-fabric || azure-data-explorer"
88
---
99
# Restrict statement
@@ -38,9 +38,11 @@ The middle-tier application can prefix the user's query with a **logical model**
3838
3939
## Examples
4040

41+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
42+
4143
### Let statement
4244

43-
The following example uses a [let statement](let-statement.md) appearing before `restrict` statement.
45+
The example uses a [let statement](let-statement.md) appearing before `restrict` statement.
4446

4547
```kusto
4648
// Limit access to 'Test' let statement only
@@ -50,7 +52,7 @@ restrict access to (Test);
5052

5153
### Tables or functions
5254

53-
The following example uses references to [tables](../management/tables.md) or [functions](../management/functions.md) that are defined in the database metadata.
55+
The example uses references to [tables](../management/tables.md) or [functions](../management/functions.md) that are defined in the database metadata.
5456

5557
```kusto
5658
// Assuming the database that the query uses has table Table1 and Func1 defined in the metadata,
@@ -61,7 +63,7 @@ restrict access to (database().Table1, database().Func1, database('DB2').Table2)
6163

6264
### Patterns
6365

64-
The following example uses wildcard patterns that can match multiples of [let statements](let-statement.md) or tables/functions.
66+
The example uses wildcard patterns that can match multiples of [let statements](let-statement.md) or tables/functions.
6567

6668
```kusto
6769
let Test1 = () { print x=1 };
@@ -82,7 +84,7 @@ restrict access to (database('DB2').*);
8284

8385
### Prevent user from querying other user data
8486

85-
The following example shows how a middle-tier application can prepend a user's query
87+
The example shows how a middle-tier application can prepend a user's query
8688
with a logical model that prevents the user from querying any other user's data.
8789

8890
```kusto

data-explorer/kusto/query/set-statement.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Set statement
33
description: Learn how to use the set statement to set a request property for the duration of the query.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/13/2025
77
monikerRange: "microsoft-fabric || azure-data-explorer"
88
---
99
# Set statement
@@ -35,6 +35,8 @@ Request properties aren't formally a part of the Kusto Query Language and may be
3535

3636
## Example
3737

38+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
39+
3840
```kusto
3941
set querytrace;
4042
Events | take 100

data-explorer/kusto/query/tabular-expression-statements.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Tabular expression statements
33
description: Learn how to use tabular expression statements to produce tabular datasets.
44
ms.reviewer: alexans
55
ms.topic: reference
6-
ms.date: 08/11/2024
6+
ms.date: 01/13/2025
77
---
88
# Tabular expression statements
99

@@ -41,9 +41,11 @@ A tabular data source produces sets of records, to be further processed by tabul
4141

4242
## Examples
4343

44+
[!INCLUDE [help-cluster](../includes/help-cluster-samples-stormevents.md)]
45+
4446
### Filter rows by condition
4547

46-
The following query counts the number of records in the `StormEvents` table that have a value of "FLORIDA" in the `State` column.
48+
This query counts the number of records in the `StormEvents` table that have a value of "FLORIDA" in the `State` column.
4749

4850
:::moniker range="azure-data-explorer"
4951
> [!div class="nextstepaction"]
@@ -64,7 +66,7 @@ StormEvents
6466

6567
### Combine data from two tables
6668

67-
In the following example, the [join](join-operator.md) operator is used to combine records from two tabular data sources: the `StormEvents` table and the `PopulationData` table.
69+
In this example, the [join](join-operator.md) operator is used to combine records from two tabular data sources: the `StormEvents` table and the `PopulationData` table.
6870

6971
:::moniker range="azure-data-explorer"
7072
> [!div class="nextstepaction"]

data-explorer/monitor-queued-ingestion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,5 @@ Click away from the settings to get the full chart that compares the number of e
269269
## Related content
270270

271271
* [Monitor Azure Data Explorer performance, health, and usage with metrics](using-metrics.md)
272-
* [Monitor Azure Data Explorer ingestion, commands, queries, and tables using diagnostic logs](using-diagnostic-logs.md)
272+
* [Monitor Azure Data Explorer ingestion, commands, queries, and tables using diagnostic logs](monitor-data-explorer.md#monitor-azure-data-explorer-ingestion-commands-queries-and-tables-using-diagnostic-logs)
273273
* [Use Azure Monitor Insights](/azure/azure-monitor/insights/data-explorer)

0 commit comments

Comments
 (0)