internal virtual GremlinSelectVariable GetSelectVar(GremlinToSqlContext currentContext, GremlinKeyword.Pop pop, List <string> selectKeys, List <GraphTraversal2> byList = null) { //TODO: refactor if (byList == null) { byList = new List <GraphTraversal2>() { GraphTraversal2.__() }; } List <GremlinToSqlContext> byContexts = new List <GremlinToSqlContext>(); List <GremlinVariable> steps = currentContext.GetGlobalPathStepList(); List <GremlinVariable> sideEffectVariables = currentContext.GetSideEffectVariables(); GremlinGlobalPathVariable pathVariable = new GremlinGlobalPathVariable(steps); currentContext.VariableList.Add(pathVariable); currentContext.TableReferences.Add(pathVariable); foreach (var by in byList) { GremlinToSqlContext newContext = new GremlinToSqlContext(); GremlinDecompose1Variable decompose1 = new GremlinDecompose1Variable(pathVariable); newContext.VariableList.Add(decompose1); newContext.TableReferences.Add(decompose1); newContext.SetPivotVariable(decompose1); by.GetStartOp().InheritedContextFromParent(newContext); byContexts.Add(by.GetEndOp().GetContext()); } GremlinSelectVariable newVariable = new GremlinSelectVariable(this, pathVariable, sideEffectVariables, pop, selectKeys, byContexts); currentContext.VariableList.Add(newVariable); currentContext.TableReferences.Add(newVariable); return(newVariable); }