Show / Hide Table of Contents

Class ExpressionExtensions

Extension methods for Expression nodes.

Inheritance
Object
ExpressionExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Mangrove.MetricSetSyntaxTree.Extensions
Assembly: MetricSetSyntaxTree.dll
Syntax
public static class ExpressionExtensions

Methods

View Source

AsPair(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.

View Source

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.

View Source

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
View Source

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.

View Source

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.

View Source

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
View Source

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.

View Source

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
View Source

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
  • View Source
Back to top Generated by DocFX