public override WTableReference ToTableReference()
        {
            WSelectQueryBlock queryBlock = this.SubqueryContext.ToSelectQueryBlock();

            queryBlock.SelectElements.Clear();

            List <WValueExpression> columnListExpr = new List <WValueExpression>();

            columnListExpr.Add(SqlUtil.GetValueExpr(this.SubqueryContext.PivotVariable.DefaultProperty()));
            columnListExpr.AddRange(this.ProjectedProperties.Select(SqlUtil.GetValueExpr));

            List <WScalarExpression> capParameters = new List <WScalarExpression>();

            foreach (var sideEffectKey in SideEffectKeys)
            {
                capParameters.Add(new WColumnNameList(columnListExpr));
                capParameters.Add(SqlUtil.GetValueExpr(sideEffectKey));
            }

            queryBlock.SelectElements.Add(
                SqlUtil.GetSelectScalarExpr(SqlUtil.GetFunctionCall(GremlinKeyword.func.Cap, capParameters),
                                            GremlinKeyword.TableDefaultColumnName));

            return(SqlUtil.GetDerivedTable(queryBlock, GetVariableName()));
        }
Example #2
0
        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()
        {
            WSelectQueryBlock queryBlock = SubqueryContext.ToSelectQueryBlock();

            queryBlock.SelectElements.Clear();
            queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetFunctionCall(GremlinKeyword.func.Count), GremlinKeyword.ScalarValue));
            return(SqlUtil.GetDerivedTable(queryBlock, GetVariableName()));
        }
        public override WTableReference ToTableReference()
        {
            WSelectQueryBlock queryBlock = SubqueryContext.ToSelectQueryBlock();

            queryBlock.SelectElements.Clear();
            queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetFunctionCall(GremlinKeyword.func.Tree, PathVariable.GetDefaultProjection().ToScalarExpression()), GremlinKeyword.TableDefaultColumnName));
            return(SqlUtil.GetDerivedTable(queryBlock, GetVariableName()));
        }
        public override WTableReference ToTableReference()
        {
            WSelectQueryBlock queryBlock = SubqueryContext.ToSelectQueryBlock();

            queryBlock.SelectElements.Clear();
            List <WScalarExpression> foldParameters = new List <WScalarExpression> {
                SubqueryContext.PivotVariable.ToCompose1()
            };

            queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetFunctionCall(GremlinKeyword.func.Fold, foldParameters), GremlinKeyword.TableDefaultColumnName));
            return(SqlUtil.GetDerivedTable(queryBlock, GetVariableName()));
        }
        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);
        }
Example #7
0
        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()
        {
            WSelectQueryBlock queryBlock = SubqueryContext.ToSelectQueryBlock();

            queryBlock.SelectElements.Clear();
            if (SubqueryContext.PivotVariable.ProjectedProperties.Count == 0)
            {
                SubqueryContext.PivotVariable.ProjectedProperties.Add(GetProjectKey());
            }

            List <WScalarExpression> foldParameters = new List <WScalarExpression> {
                SubqueryContext.PivotVariable.ToCompose1()
            };

            queryBlock.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetFunctionCall(GremlinKeyword.func.Fold, foldParameters), GremlinKeyword.ScalarValue));
            return(SqlUtil.GetDerivedTable(queryBlock, GetVariableName()));
        }
Example #9
0
        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()
 {
     return(SqlUtil.GetDerivedTable(SubqueryContext.ToSelectQueryBlock(ProjectedProperties), GetVariableName()));
 }
 public override WTableReference ToTableReference()
 {
     return(SqlUtil.GetDerivedTable(this.SubqueryContext.ToSelectQueryBlock(), GetVariableName()));
 }