public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); List <WSelectQueryBlock> queryBlocks = new List <WSelectQueryBlock>(); //Must toSelectQueryBlock before toCompose1 of variableList in order to populate needed columns foreach (var byContext in this.ByContexts) { queryBlocks.Add(byContext.ToSelectQueryBlock(true)); } for (int index = 0; index < this.StepList.Count; index++) { GremlinVariable step = this.StepList[index]; if (step is GremlinContextVariable && !((step is GremlinRepeatContextVariable) || (step is GremlinUntilContextVariable) || (step is GremlinEmitContextVariable))) { parameters.AddRange(this.AnnotatedLabels[index].Select(SqlUtil.GetValueExpr)); continue; } HashSet <string> composedProperties = new HashSet <string>(this.ProjectedProperties); foreach (var labelproperty in this.LabelPropertyList) { if (!composedProperties.Contains(labelproperty.Item1) && (this.AnnotatedLabels[index].Contains(labelproperty.Item1) || this.InheritedLabels[index].Contains(labelproperty.Item1))) { composedProperties.Add(labelproperty.Item2); } } if (composedProperties.Count > this.ProjectedProperties.Count) { composedProperties.RemoveWhere(s => String.IsNullOrEmpty(s)); parameters.Add(step.ToStepScalarExpr(composedProperties)); parameters.AddRange(this.AnnotatedLabels[index].Select(SqlUtil.GetValueExpr)); } } foreach (var block in queryBlocks) { parameters.Add(SqlUtil.GetScalarSubquery(block)); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Path, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }