Class ExpressionExtensions
Extension methods for Expression nodes.
Inherited Members
Namespace: Mangrove.MetricSetSyntaxTree.Extensions
Assembly: MetricSetSyntaxTree.dll
Syntax
public static class ExpressionExtensions
Methods
View SourceAsPair(ColumnReference)
Return a pair (column reference table name, column name).
Declaration
public static (string tableName, string columnName) AsPair(this ColumnReference cr)
Parameters
Type | Name | Description |
---|---|---|
ColumnReference | cr |
Returns
Type | Description |
---|---|
ValueTuple<String, String> |
Remarks
Because expressions often change during visitors, we use these string pairs to reference the expressions.
IsAggregation(Expression)
Whether or not the given expression is any kind of aggregation.
Declaration
public static bool IsAggregation(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr | Any expression node. |
Returns
Type | Description |
---|---|
Boolean |
Remarks
Don't use the type parameter of Expression<TExpr, TTable> for this because Aggregand expressions aren't aggregations, but are of that type.
IsConstant(Expression)
Whether or not the given expression is a constant. An expression is a constant if it has no ancestors (including itself) that are either a DataSourceColumn or an Aggregation e.g. a Literal 1 is a constant, 1/4 is also a constant, but SUM(1) is not a constant
Declaration
public static bool IsConstant(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr |
Returns
Type | Description |
---|---|
Boolean |
IsOfNonNullableType(Expression)
Whether or not expr
is one of the nullable
types, as defined by NonNullableTypes.
Declaration
public static bool IsOfNonNullableType(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr |
Returns
Type | Description |
---|---|
Boolean |
Remarks
NOTE: type Unknown is NOT a non-nullable type, and is NOT a nullable type either. Therefore, one must be careful when using this method as there are types that are neither nullable nor non-nullable.
IsOfNullableType(Expression)
Whether or not expr
is one of the nullable
types, as defined by NullableTypes.
Declaration
public static bool IsOfNullableType(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr |
Returns
Type | Description |
---|---|
Boolean |
Remarks
NOTE: type Unknown is NOT a nullable type, and is NOT a non-nullable type either. Therefore, one must be careful when using this method as there are types that are neither nullable nor non-nullable.
IsOperation(Expression)
Whether or not the given expression is any kind of operation.
Declaration
public static bool IsOperation(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr |
Returns
Type | Description |
---|---|
Boolean |
IsRecursive(UnaryAggregation)
agg
is called recursive if its UnaryAggregationKind
is recursive. This means that for any chain of Aggregations
t1 <--- t2 <--- t3
it is true that
aggregation<t3>(x) = aggregation<t3>(aggregation<t2>(x))
for any expression x in t1.
For more details, see discussion in this RFC.
Declaration
public static bool IsRecursive(this UnaryAggregation agg)
Parameters
Type | Name | Description |
---|---|---|
UnaryAggregation | agg |
Returns
Type | Description |
---|---|
Boolean |
Remarks
For example, MAX is a recursive aggregation because to compute MAX for any expression x you can compute MAX table by table.
ResolvedName(ColumnReference)
Fully resolved name, i.e. tableName.expressionName, of colRef
.
Declaration
public static string ResolvedName(this ColumnReference colRef)
Parameters
Type | Name | Description |
---|---|---|
ColumnReference | colRef |
Returns
Type | Description |
---|---|
String |
Type(Expression)
The inferred TypeKind of expr
.
Declaration
public static TypeKind Type(this Expression expr)
Parameters
Type | Name | Description |
---|---|---|
Expression | expr |
Returns
Type | Description |
---|---|
TypeKind |