Type.TableSchema
TypeReturns a table describing the columns of a table type, including column names, positions, type names, and kinds.
Syntax
Type.TableSchema(type as type) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | type | Yes | A table type whose schema is described. |
Return Value
table — A table with columns Name, Position, TypeName, and Kind describing each column of the table type.
Remarks
Type.TableSchema returns a table that describes the columns declared in a table type. The result has four columns:
- Name — the column name as text
- Position — the zero-based column index (0 for the first column)
- TypeName — the column's type as a text string (e.g., "number", "text", "nullable number")
- Kind — the kind of the type as text (e.g., "Primitive" for type number, "Nullable" for type nullable number)
This function operates on a table type value — not the table itself. Pass Value.Type(table) to obtain the table's type before calling Type.TableSchema.
Type.TableSchema provides a human-readable, table-formatted alternative to Type.TableColumn for inspecting schemas. Common uses include:
- Programmatic schema inspection: determining column count, order, names, and types in one call - Documentation generation: producing a schema summary that can be returned or logged - Generic validation: filtering for columns of a specific kind or type name before applying transforms
For structured programmatic access to individual column types, prefer Type.TableColumn. For key information, use Type.TableKeys.
Examples
Example 1: Get the full schema of a typed table
let
T = #table(
type table [OrderID = number, Product = text, UnitPrice = nullable number],
{{1, "Widget A", 25.0}}
),
Schema = Type.TableSchema(Value.Type(T))
in
SchemaThe final output — the schema table showing all three columns with their positions, type names, and kinds.
Name | Position | TypeName | Kind | |
|---|---|---|---|---|
| 1 | OrderID | 0 | number | Primitive |
| 2 | Product | 1 | text | Primitive |
| 3 | UnitPrice | 2 | nullable number | Nullable |
Example 2: Count columns declared in the Sales table type
Table.RowCount(Type.TableSchema(Value.Type(Sales)))Result | |
|---|---|
| 1 | 8 |
Example 3: Find all nullable columns in a table type
let
T = #table(
type table [OrderID = number, Product = text, Notes = nullable text],
{{1, "Widget A", null}}
),
Schema = Type.TableSchema(Value.Type(T)),
NullableCols = Table.SelectRows(Schema, each [Kind] = "Nullable")
in
NullableCols[Name]The final output — extracts the Name column from the filtered schema table, returning a list of nullable column names.
Result | |
|---|---|
| 1 | Notes |