Type.Facets
TypeReturns a record containing the facets (type constraints) of a type, such as precision and scale for decimal types.
Syntax
Type.Facets(type as type) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | type | Yes | The type whose facets are returned. |
Return Value
record — A record of facet values for the given type.
Remarks
Type.Facets returns a record describing the facets of a type — the additional constraints or properties associated with the type beyond its base kind. Facets are type-specific: for number types, relevant facets include Precision and Scale; for text types, MaxLength is a relevant facet.
For most primitive M types created with literal type expressions (like type number or type text), facets are present in the record but their values are null, meaning no constraint has been applied. Facets become meaningful when working with types derived from data sources — for example, a SQL Server column typed as DECIMAL(10, 2) will expose Precision = 10 and Scale = 2 through its type facets.
Type.Facets is used in advanced introspection scenarios: custom connectors, schema comparison tools, or type annotation pipelines. The output of Type.Facets is a standard record that you can inspect with record field access or convert to a table with Record.ToTable. The complement function Type.ReplaceFacets creates a new type with modified facets.
Note that Type.Facets operates on a type value, not a data value. Use Value.Type(x) to obtain the type of a data value before passing it to Type.Facets.
Examples
Example 1: Facets of a plain number type — all null
Type.Facets(type number)Name | Value | |
|---|---|---|
| 1 | Precision | null |
| 2 | Scale | null |
Example 2: Facets of a nullable text type
Type.Facets(type nullable text)Name | Value | |
|---|---|---|
| 1 | MaxLength | null |
Example 3: Facets after applying precision and scale with Type.ReplaceFacets
let
Constrained = Type.ReplaceFacets(type number, [Precision = 10, Scale = 2])
in
Type.Facets(Constrained)Name | Value | |
|---|---|---|
| 1 | Precision | 10 |
| 2 | Scale | 2 |