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: optional annotations that describe a type in more detail than its base kind, such as a text column's maximum length or a decimal column's precision. The record always has the same nine fields: NumericPrecisionBase, NumericPrecision, NumericScale, DateTimePrecision, MaxLength, IsVariableLength, NativeTypeName, NativeDefaultExpression, and NativeExpression. These match the facet columns that Table.Schema reports.
For types written as literals (like type number or type text), every field is null, meaning no facet has been set. Facets become meaningful on types that come from data sources. For example, a SQL Server nvarchar(50) column's type can carry MaxLength = 50, IsVariableLength = true, and NativeTypeName = "nvarchar".
Facets are informational only: M does not enforce them when values are created or converted.
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 | NumericPrecisionBase | null |
| 2 | NumericPrecision | null |
| 3 | NumericScale | null |
| 4 | DateTimePrecision | null |
| 5 | MaxLength | null |
| 6 | IsVariableLength | null |
| 7 | NativeTypeName | null |
| 8 | NativeDefaultExpression | null |
| 9 | NativeExpression | null |
Example 2: Facets of a nullable text type
Type.Facets(type nullable text)Name | Value | |
|---|---|---|
| 1 | NumericPrecisionBase | null |
| 2 | NumericPrecision | null |
| 3 | NumericScale | null |
| 4 | DateTimePrecision | null |
| 5 | MaxLength | null |
| 6 | IsVariableLength | null |
| 7 | NativeTypeName | null |
| 8 | NativeDefaultExpression | null |
| 9 | NativeExpression | null |
Example 3: Facets after applying precision and scale with Type.ReplaceFacets
let
Constrained = Type.ReplaceFacets(type number, [NumericPrecision = 10, NumericScale = 2])
in
Type.Facets(Constrained)The final output — Type.Facets returns the full facet record, with NumericPrecision 10, NumericScale 2, and every other facet null.
Name | Value | |
|---|---|---|
| 1 | NumericPrecisionBase | null |
| 2 | NumericPrecision | 10 |
| 3 | NumericScale | 2 |
| 4 | DateTimePrecision | null |
| 5 | MaxLength | null |
| 6 | IsVariableLength | null |
| 7 | NativeTypeName | null |
| 8 | NativeDefaultExpression | null |
| 9 | NativeExpression | null |