private WSelectQueryBlock GetSelectQueryBlock(GremlinToSqlContext context) { if (context == null) { return(SqlUtil.GetSimpleSelectQueryBlock(InputVariable.DefaultProjection())); } else { return(context.ToSelectQueryBlock()); } }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(GremlinKeyword.Label)); parameters.Add(SqlUtil.GetValueExpr(VertexLabel)); for (var i = 0; i < VertexProperties.Count; i += 2) { parameters.Add(SqlUtil.GetValueExpr(VertexProperties[i])); parameters.Add(SqlUtil.GetValueExpr(VertexProperties[i + 1])); } var firstTableRef = IsFirstTableReference ? SqlUtil.GetDerivedTable(SqlUtil.GetSimpleSelectQueryBlock("1"), "_") : null; var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.AddV, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(firstTableRef, secondTableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(VertexLabel)); foreach (var vertexProperty in VertexProperties) { parameters.Add(vertexProperty.ToPropertyExpr()); } foreach (string property in this.ProjectedProperties) { parameters.Add(SqlUtil.GetValueExpr(property)); } var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.AddV, parameters, GetVariableName()); var crossApplyTableRef = SqlUtil.GetCrossApplyTableReference(secondTableRef); crossApplyTableRef.FirstTableRef = IsFirstTableReference ? SqlUtil.GetDerivedTable(SqlUtil.GetSimpleSelectQueryBlock("1"), "_") : null; return(crossApplyTableRef); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(GetSelectQueryBlock(this.FromVertexContext))); parameters.Add(SqlUtil.GetScalarSubquery(GetSelectQueryBlock(this.ToVertexContext))); if (this.ToVertexContext == null && this.FromVertexContext != null) { this.OtherVIndex = 0; } if (this.ToVertexContext != null && this.FromVertexContext == null) { this.OtherVIndex = 1; } if (this.ToVertexContext != null && this.FromVertexContext != null) { this.OtherVIndex = 1; } parameters.Add(SqlUtil.GetValueExpr(this.OtherVIndex)); parameters.Add(SqlUtil.GetValueExpr(this.EdgeLabel)); parameters.AddRange(this.EdgeProperties.Select(property => property.ToPropertyExpr())); var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.AddE, parameters, GetVariableName()); var crossApplyTableRef = SqlUtil.GetCrossApplyTableReference(secondTableRef); crossApplyTableRef.FirstTableRef = this.IsFirstTableReference ? SqlUtil.GetDerivedTable(SqlUtil.GetSimpleSelectQueryBlock("1"), "_") : null; return(SqlUtil.GetCrossApplyTableReference(crossApplyTableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(this.VertexLabel)); parameters.AddRange(this.VertexProperties.Select(property => property.ToPropertyExpr())); var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.AddV, parameters, GetVariableName()); var crossApplyTableRef = SqlUtil.GetCrossApplyTableReference(secondTableRef); crossApplyTableRef.FirstTableRef = this.IsFirstTableReference ? SqlUtil.GetDerivedTable(SqlUtil.GetSimpleSelectQueryBlock("1"), "_") : null; return(crossApplyTableRef); }