internal override GremlinToSqlContext GetContext() { GremlinToSqlContext inputContext = GetInputContext(); GremlinFreeVertexVariable newVariable = new GremlinFreeVertexVariable(); if (VertexIdsOrElements.Count > 0) { List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>(); foreach (var id in VertexIdsOrElements) { if (id is int || id is string) { WScalarExpression firstExpr = newVariable.GetVariableProperty(GremlinKeyword.NodeID).ToScalarExpression(); WScalarExpression secondExpr = SqlUtil.GetValueExpr(id); WBooleanComparisonExpression booleanExpr = SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr); booleanExprList.Add(booleanExpr); } else { throw new ArgumentException(); } } inputContext.AddPredicate(SqlUtil.ConcatBooleanExprWithOr(booleanExprList)); } inputContext.VariableList.Add(newVariable); inputContext.TableReferences.Add(newVariable); inputContext.SetPivotVariable(newVariable); return(inputContext); }
internal virtual void Is(GremlinToSqlContext currentContext, object value) { WScalarExpression firstExpr = DefaultVariableProperty().ToScalarExpression(); WScalarExpression secondExpr = SqlUtil.GetValueExpr(value); currentContext.AddPredicate(SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr)); }
internal static WSelectScalarExpression GetSelectScalarExpr(WScalarExpression valueExpr, string alias = null) { return(new WSelectScalarExpression() { SelectExpr = valueExpr, ColumnName = alias }); }
internal virtual void Is(GremlinToSqlContext currentContext, Predicate predicate) { WScalarExpression secondExpr = SqlUtil.GetValueExpr(predicate.Value); var firstExpr = DefaultVariableProperty().ToScalarExpression(); var booleanExpr = SqlUtil.GetBooleanComparisonExpr(firstExpr, secondExpr, predicate); currentContext.AddPredicate(booleanExpr); }
internal static WEdgeVertexBridgeExpression GetEdgeVertexBridgeExpression(WScalarExpression firstExpr, WScalarExpression secondExpr) { return(new WEdgeVertexBridgeExpression() { ComparisonType = BooleanComparisonType.Equals, FirstExpr = firstExpr, SecondExpr = secondExpr }); }
internal WInPredicate(WScalarExpression expression, List <string> values) { this.Expression = expression; this.Values = new List <WScalarExpression>(); this.NotDefined = false; foreach (string value in values) { this.Values.Add(new WValueExpression(value, true)); } }
internal static WBooleanComparisonExpression GetBooleanComparisonExpr(WScalarExpression firstExpr, WScalarExpression secondExpr, BooleanComparisonType type) { return(new WBooleanComparisonExpression() { ComparisonType = type, FirstExpr = firstExpr, SecondExpr = secondExpr }); }
internal void HasLabel(GremlinVariable lastVariable, List <object> values) { List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>(); foreach (var value in values) { WScalarExpression firstExpr = lastVariable.GetVariableProperty(GremlinKeyword.Label).ToScalarExpression(); WScalarExpression secondExpr = SqlUtil.GetValueExpr(value); booleanExprList.Add(SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr)); } WBooleanExpression concatSql = SqlUtil.ConcatBooleanExprWithOr(booleanExprList); AddPredicate(SqlUtil.GetBooleanParenthesisExpr(concatSql)); }
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)); }
internal List <WSelectElement> GetSelectElement(bool isToCompose1) { var selectElements = new List <WSelectElement>(); if (PivotVariable.GetVariableType() == GremlinVariableType.Null) { selectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetStarColumnReferenceExpr(), GremlinKeyword.TableDefaultColumnName)); return(selectElements); } if (isToCompose1) { selectElements.Add(SqlUtil.GetSelectScalarExpr(PivotVariable.ToCompose1(), GremlinKeyword.TableDefaultColumnName)); return(selectElements); } foreach (var projectProperty in ProjectedProperties) { WSelectScalarExpression selectScalarExpr; if (projectProperty == GremlinKeyword.Path) { selectScalarExpr = SqlUtil.GetSelectScalarExpr(ContextLocalPath.GetDefaultProjection().ToScalarExpression(), GremlinKeyword.Path); } else if (projectProperty == GremlinKeyword.TableDefaultColumnName) { GremlinVariableProperty defaultProjection = PivotVariable.GetDefaultProjection(); selectScalarExpr = SqlUtil.GetSelectScalarExpr(defaultProjection.ToScalarExpression(), GremlinKeyword.TableDefaultColumnName); } else if (PivotVariable.ProjectedProperties.Contains(projectProperty)) { WScalarExpression columnExpr = PivotVariable.GetVariableProperty(projectProperty).ToScalarExpression(); selectScalarExpr = SqlUtil.GetSelectScalarExpr(columnExpr, projectProperty); } else { selectScalarExpr = SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty); } selectElements.Add(selectScalarExpr); } if (selectElements.Count == 0) { GremlinVariableProperty defaultProjection = PivotVariable.GetDefaultProjection(); selectElements.Add(SqlUtil.GetSelectScalarExpr(defaultProjection.ToScalarExpression(), GremlinKeyword.TableDefaultColumnName)); } return(selectElements); }
private WBooleanExpression CreateBooleanExpression(GremlinVariableProperty variableProperty, object valuesOrPredicate) { if (valuesOrPredicate is string || valuesOrPredicate is int || valuesOrPredicate is bool) { WScalarExpression firstExpr = variableProperty.ToScalarExpression(); WScalarExpression secondExpr = SqlUtil.GetValueExpr(valuesOrPredicate); return(SqlUtil.GetEqualBooleanComparisonExpr(firstExpr, secondExpr)); } if (valuesOrPredicate is Predicate) { WScalarExpression firstExpr = variableProperty.ToScalarExpression(); WScalarExpression secondExpr = SqlUtil.GetValueExpr((valuesOrPredicate as Predicate).Value); return(SqlUtil.GetBooleanComparisonExpr(firstExpr, secondExpr, valuesOrPredicate as Predicate)); } throw new ArgumentException(); }
public WPropertyExpression ToPropertyExpr() { WScalarExpression valueExpr = ReplaceContextToScalerExpr(this.Value); Dictionary <WValueExpression, WScalarExpression> metaPropertiesExpr = new Dictionary <WValueExpression, WScalarExpression>(); foreach (string metaKey in MetaProperties.Keys) { metaPropertiesExpr[SqlUtil.GetValueExpr(metaKey)] = ReplaceContextToScalerExpr(MetaProperties[metaKey]); } return(new WPropertyExpression() { Cardinality = Cardinality, Key = SqlUtil.GetValueExpr(Key), Value = valueExpr, MetaProperties = metaPropertiesExpr }); }
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)); }
public override WTableReference ToTableReference() { if (RepeatContext.ContextLocalPath != null) { RepeatContext.ContextLocalPath.PathList.Insert(0, null); RepeatContext.ContextLocalPath.IsInRepeatContext = true; } //The following two variables are used for manually creating SelectScalarExpression of repeat List <WSelectScalarExpression> repeatFirstSelect = new List <WSelectScalarExpression>(); List <WSelectScalarExpression> repeatSecondSelect = new List <WSelectScalarExpression>(); // The following two variables are used for Generating a Map // such as N_0.id -> key_0 // Then we will use this map to replace ColumnRefernceExpression in the syntax tree which matchs n_0.id to R_0.key_0 Dictionary <WColumnReferenceExpression, string> repeatVistorMap = new Dictionary <WColumnReferenceExpression, string>(); Dictionary <WColumnReferenceExpression, string> conditionVistorMap = new Dictionary <WColumnReferenceExpression, string>(); //We should generate the syntax tree firstly //Some variables will populate ProjectProperty only when we call the ToTableReference function where they appear. WRepeatConditionExpression repeatConditionExpr = GetRepeatConditionExpression(); WSelectQueryBlock repeatQueryBlock = RepeatContext.ToSelectQueryBlock(); // TODO: explain this step in detail var repeatNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatContext); if (!repeatNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable)) { repeatNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatContext.VariableList.First(); } foreach (var pair in repeatNewToOldSelectedVarMap) { GremlinVariable newVariable = pair.Key; GremlinVariable oldVariable = pair.Value; foreach (var property in pair.Value.ProjectedProperties) { var aliasName = GenerateKey(); var firstSelectColumn = oldVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression; var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression; repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName)); repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName)); repeatVistorMap[firstSelectColumn.Copy()] = aliasName; } } if (RepeatCondition.TerminationContext != null && RepeatCondition.TerminationContext.VariableList.Count > 0) { var terminatedNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatCondition.TerminationContext); if (!terminatedNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable)) { terminatedNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatCondition.TerminationContext.VariableList.First(); } foreach (var pair in terminatedNewToOldSelectedVarMap) { GremlinVariable newVariable = pair.Key; GremlinVariable oldVariable = pair.Value; foreach (var property in oldVariable.ProjectedProperties) { var aliasName = GenerateKey(); var firstSelectColumn = RepeatCondition.StartFromContext ? oldVariable.GetVariableProperty(property).ToScalarExpression() : SqlUtil.GetValueExpr(null); var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression; repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName)); repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName)); if (RepeatCondition.StartFromContext) { conditionVistorMap[(firstSelectColumn as WColumnReferenceExpression).Copy()] = aliasName; } else { conditionVistorMap[secondSelectColumn.Copy()] = aliasName; } } } } if (RepeatCondition.EmitContext != null && RepeatCondition.EmitContext.VariableList.Count > 0) { var terminatedNewToOldSelectedVarMap = GetNewToOldSelectedVarMap(RepeatCondition.EmitContext); if (!terminatedNewToOldSelectedVarMap.ContainsKey(RepeatContext.PivotVariable)) { terminatedNewToOldSelectedVarMap[RepeatContext.PivotVariable] = RepeatCondition.EmitContext.VariableList.First(); } foreach (var pair in terminatedNewToOldSelectedVarMap) { GremlinVariable newVariable = pair.Key; GremlinVariable oldVariable = pair.Value; foreach (var property in pair.Value.ProjectedProperties) { var aliasName = GenerateKey(); var firstSelectColumn = RepeatCondition.IsEmitContext ? oldVariable.GetVariableProperty(property).ToScalarExpression() : SqlUtil.GetValueExpr(null); var secondSelectColumn = newVariable.GetVariableProperty(property).ToScalarExpression() as WColumnReferenceExpression; repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstSelectColumn, aliasName)); repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondSelectColumn, aliasName)); if (RepeatCondition.IsEmitContext) { conditionVistorMap[(firstSelectColumn as WColumnReferenceExpression).Copy()] = aliasName; } else { conditionVistorMap[secondSelectColumn.Copy()] = aliasName; } } } } foreach (var property in ProjectedProperties) { if (property == GremlinKeyword.Path) { repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), GremlinKeyword.Path)); repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(RepeatContext.ContextLocalPath.GetDefaultProjection().ToScalarExpression(), GremlinKeyword.Path)); continue; } WScalarExpression firstExpr = InputVariable.ProjectedProperties.Contains(property) ? InputVariable.GetVariableProperty(property).ToScalarExpression() : SqlUtil.GetValueExpr(null); WScalarExpression secondExpr = RepeatContext.PivotVariable.ProjectedProperties.Contains(property) ? RepeatContext.PivotVariable.GetVariableProperty(property).ToScalarExpression() : SqlUtil.GetValueExpr(null); repeatFirstSelect.Add(SqlUtil.GetSelectScalarExpr(firstExpr, property)); repeatSecondSelect.Add(SqlUtil.GetSelectScalarExpr(secondExpr, property)); } WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock(); foreach (var selectColumnExpr in repeatFirstSelect) { firstQueryExpr.SelectElements.Add(selectColumnExpr); } repeatQueryBlock = RepeatContext.ToSelectQueryBlock(); repeatQueryBlock.SelectElements.Clear(); foreach (var selectColumnExpr in repeatSecondSelect) { repeatQueryBlock.SelectElements.Add(selectColumnExpr); } //Replace N_0.id -> R_0.key_0, when N_0 is a outer variable new ModifyColumnNameVisitor().Invoke(repeatQueryBlock, repeatVistorMap); new ModifyColumnNameVisitor().Invoke(repeatConditionExpr, conditionVistorMap); List <WScalarExpression> repeatParameters = new List <WScalarExpression>() { SqlUtil.GetScalarSubquery(SqlUtil.GetBinaryQueryExpr(firstQueryExpr, repeatQueryBlock)), repeatConditionExpr }; var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Repeat, repeatParameters, GetVariableName()); return(SqlUtil.GetCrossApplyTableReference(tableRef)); }
internal static WBooleanExpression GetBooleanComparisonExpr(WScalarExpression firstExpr, WScalarExpression secondExpr, Predicate predicate) { List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>(); WScalarExpression lowExpr = null; WScalarExpression highExpr = null; switch (predicate.PredicateType) { case PredicateType.within: if (predicate.IsTag) { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(firstExpr); parameters.Add(secondExpr); return(GetFunctionBooleanExpression("WithInArray", parameters)); } else { foreach (var value in predicate.Values) { secondExpr = GetValueExpr(value); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, secondExpr, GetComparisonType(PredicateType.eq))); } return(ConcatBooleanExprWithOr(booleanExprList)); } case PredicateType.without: if (predicate.IsTag) { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(firstExpr); parameters.Add(secondExpr); return(GetFunctionBooleanExpression("WithOutArray", parameters)); } else { foreach (var value in predicate.Values) { secondExpr = GetValueExpr(value); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, secondExpr, GetComparisonType(PredicateType.neq))); } return(ConcatBooleanExprWithAnd(booleanExprList)); } case PredicateType.inside: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lt)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.outside: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gt)));; return(ConcatBooleanExprWithOr(booleanExprList)); case PredicateType.between: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lt)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.lteAndgte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gte)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.gteAndlte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lte)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.ltAndgte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gte)));; return(ConcatBooleanExprWithAnd(booleanExprList)); default: return(GetBooleanComparisonExpr(firstExpr, secondExpr, GetComparisonType(predicate.PredicateType))); } }
public virtual void Visit(WScalarExpression node) { node.AcceptChildren(this); }
internal static WBooleanExpression GetBooleanComparisonExpr(WScalarExpression firstExpr, WScalarExpression secondExpr, Predicate predicate) { List <WBooleanExpression> booleanExprList = new List <WBooleanExpression>(); WScalarExpression lowExpr = null; WScalarExpression highExpr = null; switch (predicate.PredicateType) { case PredicateType.and: var andPredicate = predicate as AndPredicate; foreach (var p in andPredicate.PredicateList) { WScalarExpression secExpr = GetValueExpr(p.Value); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, secExpr, p)); } return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.or: var orPredicate = predicate as OrPredicate; foreach (var p in orPredicate.PredicateList) { WScalarExpression secExpr = GetValueExpr(p.Value); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, secExpr, p)); } return(ConcatBooleanExprWithOr(booleanExprList)); case PredicateType.within: if (predicate.IsTag) { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(firstExpr); parameters.Add(secondExpr); return(GetFunctionBooleanExpression("WithInArray", parameters)); } else { return(new WInPredicate { Expression = firstExpr, NotDefined = false, Values = predicate.Values.Select(v => GetValueExpr(v) as WScalarExpression).ToList(), }); } case PredicateType.without: if (predicate.IsTag) { List <WScalarExpression> parameters = new List <WScalarExpression>(); parameters.Add(firstExpr); parameters.Add(secondExpr); return(GetFunctionBooleanExpression("WithOutArray", parameters)); } else { return(new WInPredicate { Expression = firstExpr, NotDefined = true, Values = predicate.Values.Select(v => GetValueExpr(v) as WScalarExpression).ToList(), }); } case PredicateType.inside: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lt)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.outside: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gt)));; return(ConcatBooleanExprWithOr(booleanExprList)); case PredicateType.between: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lt)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.lteOrgte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gte)));; return(ConcatBooleanExprWithOr(booleanExprList)); case PredicateType.gteAndlte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.gte))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.lte)));; return(ConcatBooleanExprWithAnd(booleanExprList)); case PredicateType.ltOrgte: lowExpr = GetValueExpr(predicate.Low); highExpr = GetValueExpr(predicate.High); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, lowExpr, GetComparisonType(PredicateType.lt))); booleanExprList.Add(GetBooleanComparisonExpr(firstExpr, highExpr, GetComparisonType(PredicateType.gte)));; return(ConcatBooleanExprWithOr(booleanExprList)); default: return(GetBooleanComparisonExpr(firstExpr, secondExpr, GetComparisonType(predicate.PredicateType))); } }
internal List <WSelectElement> GetSelectElement(List <string> ProjectedProperties) { var selectElements = new List <WSelectElement>(); if ((PivotVariable is GremlinUnionVariable && HomeVariable is GremlinSideEffectVariable) || PivotVariable.GetVariableType() == GremlinVariableType.NULL) { selectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetStarColumnReferenceExpr())); return(selectElements); } if (ProjectedProperties != null && ProjectedProperties.Count != 0) { foreach (var projectProperty in ProjectedProperties) { WSelectScalarExpression selectScalarExpr; if (projectProperty == GremlinKeyword.TableDefaultColumnName) { GremlinVariableProperty defaultProjection = PivotVariable.DefaultProjection(); selectScalarExpr = SqlUtil.GetSelectScalarExpr(defaultProjection.ToScalarExpression(), GremlinKeyword.TableDefaultColumnName); selectElements.Add(selectScalarExpr); } else if (ProjectVariablePropertiesList.All(p => p.Item2 != projectProperty)) { if (PivotVariable.ProjectedProperties.Contains(projectProperty)) { WScalarExpression columnExpr = PivotVariable.GetVariableProperty(projectProperty).ToScalarExpression(); selectScalarExpr = SqlUtil.GetSelectScalarExpr(columnExpr, projectProperty); selectElements.Add(selectScalarExpr); } else { selectScalarExpr = SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty); selectElements.Add(selectScalarExpr); } } } } else { selectElements.Add(SqlUtil.GetSelectScalarExpr(PivotVariable.DefaultProjection().ToScalarExpression(), GremlinKeyword.TableDefaultColumnName)); } if (IsPopulateGremlinPath) { selectElements.Add(SqlUtil.GetSelectScalarExpr(CurrentContextPath.DefaultProjection().ToScalarExpression(), GremlinKeyword.Path)); } foreach (var item in ProjectVariablePropertiesList) { selectElements.Add(SqlUtil.GetSelectScalarExpr(item.Item1.ToScalarExpression(), item.Item2)); } if (selectElements.Count == 0) { if (PivotVariable is GremlinTableVariable || (PivotVariable is GremlinUnionVariable && HomeVariable is GremlinSideEffectVariable)) { selectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetStarColumnReferenceExpr())); } else if (PivotVariable.GetVariableType() == GremlinVariableType.Table) { throw new Exception("Can't process table type"); } else { GremlinVariableProperty defaultProjection = PivotVariable.DefaultProjection(); selectElements.Add(SqlUtil.GetSelectScalarExpr(defaultProjection.ToScalarExpression())); } } return(selectElements); }
internal static WBooleanComparisonExpression GetEqualBooleanComparisonExpr(WScalarExpression firstExpr, WScalarExpression secondExpr) { return(GetBooleanComparisonExpr(firstExpr, secondExpr, BooleanComparisonType.Equals)); }