public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); foreach (GremlinToSqlContext context in this.CoalesceContextList) { WSelectQueryBlock selectQueryBlock = context.ToSelectQueryBlock(); Dictionary <string, WSelectElement> projectionMap = new Dictionary <string, WSelectElement>(); WSelectElement value = selectQueryBlock.SelectElements[0]; foreach (WSelectElement selectElement in selectQueryBlock.SelectElements) { projectionMap[(selectElement as WSelectScalarExpression).ColumnName] = selectElement; } selectQueryBlock.SelectElements.Clear(); selectQueryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr((value as WSelectScalarExpression).SelectExpr, this.DefaultProperty())); foreach (string property in this.ProjectedProperties) { selectQueryBlock.SelectElements.Add( projectionMap.TryGetValue(property, out value) ? value : SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), property)); } parameters.Add(SqlUtil.GetScalarSubquery(selectQueryBlock)); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Coalesce, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
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>(); WTableReference tableReference; if (PredicateContext != null) { parameters.Add(SqlUtil.GetScalarSubquery(PredicateContext.ToSelectQueryBlock())); parameters.Add(SqlUtil.GetScalarSubquery(TrueChoiceContext.ToSelectQueryBlock())); parameters.Add(SqlUtil.GetScalarSubquery(FalseChocieContext.ToSelectQueryBlock())); tableReference = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Choose, parameters, GetVariableName()); } else { parameters.Add(SqlUtil.GetScalarSubquery(ChoiceContext.ToSelectQueryBlock())); foreach (var option in Options) { if (option.Key is GremlinKeyword.Pick && (GremlinKeyword.Pick)option.Key == GremlinKeyword.Pick.None) { parameters.Add(SqlUtil.GetValueExpr(null)); } else { parameters.Add(SqlUtil.GetValueExpr(option.Key)); } parameters.Add(SqlUtil.GetScalarSubquery(option.Value.ToSelectQueryBlock())); } tableReference = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.ChooseWithOptions, parameters, GetVariableName()); } return(SqlUtil.GetCrossApplyTableReference(tableReference)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); if (DedupVariables.Count > 0) { foreach (var dedupVariable in DedupVariables) { parameters.Add(dedupVariable.DefaultVariableProperty().ToScalarExpression()); } } else if (DedupContext != null) { parameters.Add(SqlUtil.GetScalarSubquery(DedupContext.ToSelectQueryBlock())); } else { parameters.Add(InputVariable.DefaultVariableProperty().ToScalarExpression()); } var tableRef = SqlUtil.GetFunctionTableReference( Scope == GremlinKeyword.Scope.global ? GremlinKeyword.func.DedupGlobal : GremlinKeyword.func.DedupLocal, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
internal WScalarExpression ReplaceContextToScalerExpr(object value) { if (value is GremlinToSqlContext) { GremlinToSqlContext valueContext = value as GremlinToSqlContext; return(SqlUtil.GetScalarSubquery(valueContext.ToSelectQueryBlock())); } return(SqlUtil.GetValueExpr(value)); }
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() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(SideEffectContext.ToSelectQueryBlock())); var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.SideEffect, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(MapContext.ToSelectQueryBlock(ProjectedProperties))); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Map, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression> { SqlUtil.GetScalarSubquery(this.DedupContext.ToSelectQueryBlock()) }; var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.DedupLocal, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); WSelectQueryBlock selectQueryBlock = ProjectContext.ToSelectQueryBlock(true); parameters.Add(SqlUtil.GetScalarSubquery(selectQueryBlock)); parameters.Add(SqlUtil.GetValueExpr(SideEffectKey)); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Store, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(SideEffectKey)); parameters.Add(SqlUtil.GetScalarSubquery(GroupByContext.ToSelectQueryBlock())); parameters.Add(SqlUtil.GetScalarSubquery(ProjectByContext.ToSelectQueryBlock())); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Group, parameters, GetVariableName()); ((WGroupTableReference)tableRef).IsProjectingACollection = IsProjectingACollection; return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); foreach (var context in CoalesceContextList) { parameters.Add(SqlUtil.GetScalarSubquery(context.ToSelectQueryBlock(ProjectedProperties))); } var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Coalesce, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
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 ByContexts) { queryBlocks.Add(byContext.ToSelectQueryBlock(true)); } parameters.Add(InputVariable.GetDefaultProjection().ToScalarExpression()); parameters.Add(PathVariable.GetDefaultProjection().ToScalarExpression()); switch (Pop) { case GremlinKeyword.Pop.All: parameters.Add(SqlUtil.GetValueExpr("All")); break; case GremlinKeyword.Pop.First: parameters.Add(SqlUtil.GetValueExpr("First")); break; case GremlinKeyword.Pop.Last: parameters.Add(SqlUtil.GetValueExpr("Last")); break; } foreach (var selectKey in SelectKeys) { parameters.Add(SqlUtil.GetValueExpr(selectKey)); } foreach (var block in queryBlocks) { parameters.Add(SqlUtil.GetScalarSubquery(block)); } if (SelectKeys.Count == 1) { foreach (var projectProperty in ProjectedProperties) { parameters.Add(SqlUtil.GetValueExpr(projectProperty)); } } var tableRef = SqlUtil.GetFunctionTableReference( SelectKeys.Count == 1 ? GremlinKeyword.func.SelectOne: GremlinKeyword.func.Select, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); for (var i = 0; i < ProjectKeys.Count; i++) { parameters.Add(SqlUtil.GetScalarSubquery(ProjectContextList[i % ProjectContextList.Count].ToSelectQueryBlock())); parameters.Add(SqlUtil.GetValueExpr(ProjectKeys[i])); } var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Project, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); //TODO: refactor WSelectQueryBlock selectQueryBlock = ProjectContext.ToSelectQueryBlock(); selectQueryBlock.SelectElements.Clear(); selectQueryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(ProjectContext.PivotVariable.ToCompose1(), GremlinKeyword.TableDefaultColumnName)); parameters.Add(SqlUtil.GetScalarSubquery(selectQueryBlock)); parameters.Add(SqlUtil.GetValueExpr(SideEffectKey)); var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Store, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
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)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression> { SqlUtil.GetValueExpr(this.AmountToSample) }; if (this.ProbabilityContext != null) { parameters.Add(SqlUtil.GetScalarSubquery(this.ProbabilityContext.ToSelectQueryBlock())); } WSchemaObjectFunctionTableReference tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.SampleGlobal, parameters, this.GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.OrderGlobal, parameters, GetVariableName()) as WOrderGlobalTableReference; foreach (var pair in this.ByModulatingList) { WScalarExpression scalarExpr = SqlUtil.GetScalarSubquery(pair.Item1.ToSelectQueryBlock()); tableRef.OrderParameters.Add(new Tuple <WScalarExpression, IComparer>(scalarExpr, pair.Item2)); tableRef.Parameters.Add(scalarExpr); } return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(AmountToSample)); if (ProbabilityContext != null) { parameters.Add(SqlUtil.GetScalarSubquery(ProbabilityContext.ToSelectQueryBlock())); } var tableRef = Scope == GremlinKeyword.Scope.global ? SqlUtil.GetFunctionTableReference(GremlinKeyword.func.SampleGlobal, parameters, GetVariableName()) : SqlUtil.GetFunctionTableReference(GremlinKeyword.func.SampleLocal, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
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 ByContexts) { queryBlocks.Add(byContext.ToSelectQueryBlock(true)); } foreach (var path in PathList) { if (path == null) { if (IsInRepeatContext) { parameters.Add(SqlUtil.GetColumnReferenceExpr(GremlinKeyword.RepeatInitalTableName, GremlinKeyword.Path)); } } else if (path is GremlinContextVariable) { foreach (var label in path.Labels) { parameters.Add(SqlUtil.GetValueExpr(label)); } } else { parameters.Add(path.ToStepScalarExpr()); foreach (var label in path.Labels) { parameters.Add(SqlUtil.GetValueExpr(label)); } } } foreach (var block in queryBlocks) { parameters.Add(SqlUtil.GetScalarSubquery(block)); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Path, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); if (this.DedupVariables.Count > 0) { parameters.AddRange(this.DedupVariables.Select(dedupVariable => dedupVariable.GetDefaultProjection().ToScalarExpression())); } else { parameters.Add(SqlUtil.GetScalarSubquery(this.DedupContext.ToSelectQueryBlock())); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.DedupGlobal, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); var tableRef = Scope == GremlinKeyword.Scope.global ? SqlUtil.GetFunctionTableReference(GremlinKeyword.func.OrderGlobal, parameters, GetVariableName()) : SqlUtil.GetFunctionTableReference(GremlinKeyword.func.OrderLocal, parameters, GetVariableName()); var wOrderTableReference = tableRef as WOrderTableReference; if (wOrderTableReference != null) { wOrderTableReference.OrderParameters = new List <Tuple <WScalarExpression, IComparer> >(); } foreach (var pair in ByModulatingMap) { WScalarExpression scalrExpr; if (pair.Item1 is GremlinToSqlContext) { scalrExpr = SqlUtil.GetScalarSubquery(((GremlinToSqlContext)pair.Item1).ToSelectQueryBlock()); } else if (pair.Item1 is GremlinKeyword.Column) { GremlinKeyword.Column column = (GremlinKeyword.Column)pair.Item1; scalrExpr = column == GremlinKeyword.Column.keys ? SqlUtil.GetValueExpr("keys") : SqlUtil.GetValueExpr("values"); } else if (pair.Item1 == "") { scalrExpr = SqlUtil.GetValueExpr(null); } else { throw new ArgumentException(); } var orderTableReference = tableRef as WOrderTableReference; orderTableReference?.OrderParameters.Add(new Tuple <WScalarExpression, IComparer>(scalrExpr, pair.Item2)); orderTableReference?.Parameters.Add(scalrExpr); } return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); if (UnionContextList.Count == 0) { foreach (var property in ProjectedProperties) { parameters.Add(SqlUtil.GetValueExpr(property)); } } foreach (var context in UnionContextList) { parameters.Add(SqlUtil.GetScalarSubquery(context.ToSelectQueryBlock())); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Union, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetValueExpr(SideEffectKey)); for (var i = 0; i < Parameters.Count; i++) { if (Parameters[i] is GremlinToSqlContext) { parameters.Add(SqlUtil.GetScalarSubquery((Parameters[i] as GremlinToSqlContext).ToSelectQueryBlock())); } else { parameters.Add(PrimaryVariable.GetVariableProperty(Parameters[i] as string).ToScalarExpression()); } } var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Group, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
public override WTableReference ToTableReference() { List <WSelectQueryBlock> selectQueryBlocks = new List <WSelectQueryBlock>(); selectQueryBlocks.Add(new WSelectQueryBlock()); selectQueryBlocks.Add(this.OptionalContext.ToSelectQueryBlock()); Dictionary <string, WSelectElement> projectionMap = new Dictionary <string, WSelectElement>(); WSelectElement value = selectQueryBlocks[1].SelectElements[0]; foreach (WSelectElement selectElement in selectQueryBlocks[1].SelectElements) { projectionMap[(selectElement as WSelectScalarExpression).ColumnName] = selectElement; } selectQueryBlocks[1].SelectElements.Clear(); selectQueryBlocks[0].SelectElements.Add(SqlUtil.GetSelectScalarExpr(this.InputVariable.DefaultProjection().ToScalarExpression(), this.DefaultProperty())); selectQueryBlocks[1].SelectElements.Add(SqlUtil.GetSelectScalarExpr((value as WSelectScalarExpression).SelectExpr, this.DefaultProperty())); foreach (string property in this.ProjectedProperties) { selectQueryBlocks[0].SelectElements.Add( SqlUtil.GetSelectScalarExpr( this.InputVariable.RealVariable.ProjectedProperties.Contains(property) ? this.InputVariable.RealVariable.GetVariableProperty(property).ToScalarExpression() : SqlUtil.GetValueExpr(null), property)); selectQueryBlocks[1].SelectElements.Add( projectionMap.TryGetValue(property, out value) ? value : SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), property)); } WBinaryQueryExpression binaryQueryExpression = SqlUtil.GetBinaryQueryExpr(selectQueryBlocks[0], selectQueryBlocks[1]); List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(binaryQueryExpression)); var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Optional, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
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 ByContexts) { //TODO: select compose1 WSelectQueryBlock queryBlock = byContext.ToSelectQueryBlock(); queryBlock.SelectElements.Clear(); queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(byContext.PivotVariable.ToCompose1(), GremlinKeyword.TableDefaultColumnName)); queryBlocks.Add(queryBlock); } if (IsInRepeatContext) { //Must add as the first parameter parameters.Add(SqlUtil.GetColumnReferenceExpr(GremlinKeyword.RepeatInitalTableName, GremlinKeyword.Path)); } foreach (var path in PathList) { if (path.AttachedVariable != null) { parameters.Add(SqlUtil.GetColumnReferenceExpr(path.AttachedVariable.GetVariableName(), GremlinKeyword.Path)); } else { parameters.Add(path.StepVariable.First().ToCompose1()); } } foreach (var block in queryBlocks) { parameters.Add(SqlUtil.GetScalarSubquery(block)); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Path2, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); foreach (var row in rows) { if (row is string || row is int) { var queryBlock = new WSelectQueryBlock(); queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(row), "_value")); parameters.Add(SqlUtil.GetScalarSubquery(queryBlock)); } else { throw new NotImplementedException(); } } var secondTableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Inject, parameters, this, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(null, secondTableRef)); }
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)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(SqlUtil.GetScalarSubquery(GetSelectQueryBlock(FromVertexContext))); parameters.Add(SqlUtil.GetScalarSubquery(GetSelectQueryBlock(ToVertexContext))); if (ToVertexContext == null && FromVertexContext != null) { OtherVIndex = 0; } if (ToVertexContext != null && FromVertexContext == null) { OtherVIndex = 1; } if (ToVertexContext != null && FromVertexContext != null) { OtherVIndex = 1; } parameters.Add(SqlUtil.GetValueExpr(OtherVIndex)); parameters.Add(this.EdgeLabel != null ? SqlUtil.GetValueExpr(this.EdgeLabel) : SqlUtil.GetValueExpr(null)); foreach (var property in EdgeProperties) { parameters.Add(property.ToPropertyExpr()); //parameters.Add(SqlUtil.GetValueExpr(property.Value)); } foreach (string property in this.ProjectedProperties) { parameters.Add(SqlUtil.GetValueExpr(property)); } var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.AddE, parameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
public override WTableReference ToTableReference() { List <WScalarExpression> parameters = new List <WScalarExpression>(); List <Tuple <WScalarExpression, IComparer> > orderParameters = new List <Tuple <WScalarExpression, IComparer> >(); if (this.Scope == GremlinKeyword.Scope.Local) { parameters.Add(this.InputVariable.DefaultProjection().ToScalarExpression()); foreach (var pair in ByModulatingList) { WScalarExpression scalarExpr = SqlUtil.GetScalarSubquery(pair.Item1.ToSelectQueryBlock()); orderParameters.Add(new Tuple <WScalarExpression, IComparer>(scalarExpr, pair.Item2)); parameters.Add(scalarExpr); } foreach (var property in this.ProjectedProperties) { parameters.Add(SqlUtil.GetValueExpr(property)); } } else { foreach (var pair in ByModulatingList) { WScalarExpression scalarExpr = SqlUtil.GetScalarSubquery(pair.Item1.ToSelectQueryBlock()); orderParameters.Add(new Tuple <WScalarExpression, IComparer>(scalarExpr, pair.Item2)); parameters.Add(scalarExpr); } } var tableRef = Scope == GremlinKeyword.Scope.Global ? SqlUtil.GetFunctionTableReference(GremlinKeyword.func.OrderGlobal, parameters, GetVariableName()) : SqlUtil.GetFunctionTableReference(GremlinKeyword.func.OrderLocal, parameters, GetVariableName()); ((WOrderTableReference)tableRef).OrderParameters = orderParameters; return(SqlUtil.GetCrossApplyTableReference(tableRef)); }