RowExpression.From
ExpressionReturns the abstract syntax tree (AST) for the body of a function, normalized into a row expression.
Syntax
RowExpression.From(function as function) as recordParameters
| Name | Type | Required | Description |
|---|---|---|---|
function | function | Yes | A single-argument lambda function whose body will be converted to an AST. |
Return Value
record — A record representing the abstract syntax tree (AST) of the function body as a row expression.
Remarks
RowExpression.From returns the abstract syntax tree (AST) for the body of function, normalized into a *row expression*. This is an advanced/internal function used by the Power Query engine and custom connector infrastructure for query folding.
### Requirements
- The function must be a single-argument lambda (e.g., an
eachexpression). - All references to the function parameter are replaced with
RowExpression.Row. - All references to columns are replaced with
RowExpression.Column(columnName). - The AST is simplified to contain only these node kinds:
Constant,Invocation,Unary,Binary,If, andFieldAccess.
An error is raised if the function body cannot be represented as a valid row expression AST.
This function is identical to ItemExpression.From. The difference is semantic: RowExpression.From is used in table contexts (where the parameter represents a row record), while ItemExpression.From is used in list contexts.
### Use cases
- Custom connectors implementing
Table.Viewhandlers that need to inspect filter predicates, sort expressions, or computed column definitions. - Translating M row expressions into SQL WHERE clauses, OData filters, or other native query syntax.
Examples
Example 1: Get the AST for a row filter
let
AST = RowExpression.From(each [CustomerName] = "ALFKI")
in
#table(
{"Kind", "Operator"},
{{AST[Kind], AST[Operator]}}
)Kind | Operator | |
|---|---|---|
| 1 | Binary | Equals |