buildschema() (aggregation function)
Learn how to use the buildschema() function to build a table schema from a dynamic expression.
Builds the minimal schema that admits all values of DynamicExpr.
Syntax
buildschema (DynamicExpr)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| DynamicExpr | dynamic | ✔️ | Expression used for the aggregation calculation. |
Returns
Returns the minimal schema that admits all values of DynamicExpr.
Example
The following example builds a schema based on:
{"x":1, "y":3.5}{"x":"somevalue", "z":[1, 2, 3]}{"y":{"w":"zzz"}, "t":["aa", "bb"], "z":["foo"]}
datatable(value: dynamic) [
dynamic({"x":1, "y":3.5}),
dynamic({"x":"somevalue", "z":[1, 2, 3]}),
dynamic({"y":{"w":"zzz"}, "t":["aa", "bb"], "z":["foo"]})
]
| summarize buildschema(value)
Results
| schema_value |
|---|
{“x”:[“long”,“string”],“y”:[“double”,{“w”:“string”}],“z”:{"indexer":[“long”,“string”]},“t”:{"indexer":“string”}} |
Schema breakdown
In the resulting schema:
- The root object is a container with four properties named
x,y,z, andt. - Property
xis either type long or type string. - Property
yis either type double or another container with a propertywof type string. - Property
zis an array, indicated by theindexerkeyword, where each item can be either type long or type string. - Property
tis an array, indicated by theindexerkeyword, where each item is a string. - Every property is implicitly optional, and any array might be empty.
Related content
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.