public override WTableReference ToTableReference() { WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock(); foreach (var projectProperty in ProjectedProperties) { if (projectProperty == GremlinKeyword.TableDefaultColumnName) { firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(InputVariable.GetDefaultProjection().ToScalarExpression(), GremlinKeyword.TableDefaultColumnName)); } else if (InputVariable.ProjectedProperties.Contains(projectProperty)) { firstQueryExpr.SelectElements.Add( SqlUtil.GetSelectScalarExpr( InputVariable.GetVariableProperty(projectProperty).ToScalarExpression(), projectProperty)); } else { firstQueryExpr.SelectElements.Add( SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty)); } } WSelectQueryBlock secondQueryExpr = OptionalContext.ToSelectQueryBlock(); bool HasAggregateFunctionAsChildren = false; foreach (var variable in OptionalContext.TableReferences) { if (variable is GremlinFoldVariable || variable is GremlinCountVariable || variable is GremlinMinVariable || variable is GremlinMaxVariable || variable is GremlinSumVariable || variable is GremlinMeanVariable || variable is GremlinTreeVariable) { HasAggregateFunctionAsChildren = true; } var group = variable as GremlinGroupVariable; if (group != null && group.SideEffectKey == null) { HasAggregateFunctionAsChildren = true; } } var WBinaryQueryExpression = SqlUtil.GetBinaryQueryExpr(firstQueryExpr, secondQueryExpr); List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(WBinaryQueryExpression)); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Optional, parameters, GetVariableName()); ((WOptionalTableReference)tableRef).HasAggregateFunctionAsChildren = HasAggregateFunctionAsChildren; return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock(); foreach (var projectProperty in ProjectedProperties) { if (projectProperty == GremlinKeyword.TableDefaultColumnName) { firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(InputVariable.DefaultProjection().ToScalarExpression(), GremlinKeyword.TableDefaultColumnName)); } else if (InputVariable.ProjectedProperties.Contains(projectProperty)) { firstQueryExpr.SelectElements.Add( SqlUtil.GetSelectScalarExpr( InputVariable.GetVariableProperty(projectProperty).ToScalarExpression(), projectProperty)); } else { firstQueryExpr.SelectElements.Add( SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty)); } } if (OptionalContext.IsPopulateGremlinPath) { firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), GremlinKeyword.Path)); } WSelectQueryBlock secondQueryExpr = OptionalContext.ToSelectQueryBlock(ProjectedProperties); var WBinaryQueryExpression = SqlUtil.GetBinaryQueryExpr(firstQueryExpr, secondQueryExpr); List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(WBinaryQueryExpression)); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Optional, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }