Type.TableColumn
TypeReturns the type of a specific column in a table type.
Syntax
Type.TableColumn(type as type, column as text) as typeParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | type | Yes | A table type whose column type is queried. |
column | text | Yes | The name of the column whose type is returned. |
Return Value
type — The type of the specified column in the table type.
Remarks
Type.TableColumn returns the declared type of a named column within a table type. This function operates on a table type value — not the table itself. To obtain a table's type, call Value.Type(table) and pass the result to Type.TableColumn.
If the specified column name does not exist in the table type, an error is raised. Use Type.TableSchema first if you need to check which columns are declared before accessing them.
Type.TableColumn is useful for:
- Generic transform functions that need to inspect or compare column types before deciding how to process data
- Schema validation — verifying that a column is typed as expected before applying a transformation
- Nullability checks — combining with Type.IsNullable to determine whether a column accepts null values
Note that most tables loaded from external sources have column types inferred or declared through the connector, and those types are often nullable variants of the base primitive types.
Examples
Example 1: Get the declared type of a column
let
T = #table(type table [Name = text, Age = number], {{"Alice", 30}}),
TType = Value.Type(T),
ColType = Type.TableColumn(TType, "Age")
in
ColTypeThe final output — extracts the declared type of the Age column from the table type using Type.TableColumn, returning type number.
Result | |
|---|---|
| 1 | type number |
Example 2: Check if a column type is nullable
let
T = #table(type table [Score = nullable number], {{null}}),
ColType = Type.TableColumn(Value.Type(T), "Score")
in
Type.IsNullable(ColType)The final output — extracts the declared type of the Score column using Type.TableColumn, then checks Type.IsNullable to confirm it is nullable, returning true.
Result | |
|---|---|
| 1 | TRUE |
Example 3: Compare the column type to a known type
let
T = #table(type table [OrderID = number, Product = text], {{1, "Widget A"}}),
ColType = Type.TableColumn(Value.Type(T), "Product")
in
ColType = type textThe final output — extracts the declared type of the Product column using Type.TableColumn, then compares it to type text to confirm they are equal, returning true.
Result | |
|---|---|
| 1 | TRUE |