public override void Visit(SqlExistsScalarExpression sqlExistsScalarExpression) { this.writer.Write("EXISTS"); this.WriteStartContext("("); sqlExistsScalarExpression.Subquery.Accept(this); this.WriteEndContext(")"); }
public override int Visit(SqlExistsScalarExpression sqlExistsScalarExpression) { int hashCode = SqlExistsScalarExpressionHashCode; hashCode = CombineHashes(hashCode, sqlExistsScalarExpression.Subquery.Accept(this)); return(hashCode); }
public override CosmosElement Visit(SqlExistsScalarExpression scalarExpression, CosmosElement document) { // Only run on the current document since the subquery is always correlated. IEnumerable <CosmosElement> subqueryResults = SqlInterpreter.ExecuteQuery( new CosmosElement[] { document }, scalarExpression.Subquery); return(CosmosBoolean.Create(subqueryResults.Any())); }
public override SqlObject VisitExistsScalarExpression([NotNull] sqlParser.ExistsScalarExpressionContext context) { Contract.Requires(context != null); // K_EXISTS '(' sql_query ')' Contract.Requires(context.ChildCount == 4); SqlQuery subquery = (SqlQuery)this.Visit(context.children[2]); return(SqlExistsScalarExpression.Create(subquery)); }
public override bool Visit(SqlExistsScalarExpression first, SqlObject secondAsObject) { if (!(secondAsObject is SqlExistsScalarExpression second)) { return(false); } if (!Equals(first.Subquery, second.Subquery)) { return(false); } return(true); }
public abstract void Visit(SqlExistsScalarExpression sqlObject);
public override SqlObject Visit(SqlExistsScalarExpression sqlExistsScalarExpression) { return(SqlExistsScalarExpression.Create(sqlExistsScalarExpression.Subquery.Accept(this) as SqlQuery)); }
public abstract void Visit(SqlExistsScalarExpression scalarExpression);
public override bool Visit(SqlExistsScalarExpression sqlExistsScalarExpression) { // No need to worry about aggregates within the subquery (they will recursively get rewritten). return(false); }
public abstract TResult Visit(SqlExistsScalarExpression sqlObject);
public void SqlExistsScalarExpressionTest() { CosmosObject tag = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["name"] = CosmosString.Create("asdf") }); CosmosObject tags = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["tags"] = CosmosArray.Create(new List <CosmosElement>() { tag }), ["_rid"] = CosmosString.Create("AYIMAMmFOw8YAAAAAAAAAA==") }); CosmosObject tagsWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["c"] = tags, ["_rid"] = CosmosString.Create("AYIMAMmFOw8YAAAAAAAAAA==") }); // EXISTS(SELECT VALUE t.name FROM t in c.tags where t.name = "asdf") SqlExistsScalarExpression existsScalarExpressionMatched = SqlExistsScalarExpression.Create( SqlQuery.Create( SqlSelectClause.Create( SqlSelectValueSpec.Create( TestUtils.CreatePathExpression("t", "name"))), SqlFromClause.Create( SqlArrayIteratorCollectionExpression.Create( SqlIdentifier.Create("t"), SqlInputPathCollection.Create( SqlIdentifier.Create("c"), SqlStringPathExpression.Create( null, SqlStringLiteral.Create("tags"))))), SqlWhereClause.Create( SqlBinaryScalarExpression.Create( SqlBinaryScalarOperatorKind.Equal, TestUtils.CreatePathExpression("t", "name"), SqlLiteralScalarExpression.Create(SqlStringLiteral.Create("asdf")))), groupByClause: null, orderByClause: null, offsetLimitClause: null)); AssertEvaluation(CosmosBoolean.Create(true), existsScalarExpressionMatched, tagsWrapped); SqlExistsScalarExpression existsScalarExpressionNotMatched = SqlExistsScalarExpression.Create( SqlQuery.Create( SqlSelectClause.Create( SqlSelectValueSpec.Create( TestUtils.CreatePathExpression("t", "name"))), SqlFromClause.Create( SqlArrayIteratorCollectionExpression.Create( SqlIdentifier.Create("t"), SqlInputPathCollection.Create( SqlIdentifier.Create("c"), SqlStringPathExpression.Create( null, SqlStringLiteral.Create("tags"))))), SqlWhereClause.Create( SqlBinaryScalarExpression.Create( SqlBinaryScalarOperatorKind.NotEqual, TestUtils.CreatePathExpression("t", "name"), SqlLiteralScalarExpression.Create(SqlStringLiteral.Create("asdf")))), groupByClause: null, orderByClause: null, offsetLimitClause: null)); AssertEvaluation(CosmosBoolean.Create(false), existsScalarExpressionNotMatched, tagsWrapped); }
public override bool Visit(SqlExistsScalarExpression scalarExpression) { return(false); }
public abstract TOutput Visit(SqlExistsScalarExpression sqlObject, TArg input);
public abstract TResult Visit(SqlExistsScalarExpression scalarExpression);