-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal] Query: Adds deserializing logic for ClientQL Coordinator D…
…istribution Plan (#3988) * First commit. * Added remaining classes for ClientQL structure * Added ClientQLDeserializing class and added CoordinatorDistributionPlan folder * Added support for all Enumerable and Scalar Expressions * Added baseline tests for testing CoordinatorDistributionPlan deserializing * Made ClientQL objects immutable * Added error and null checks for Value calls * Updated List<> with IReadOnlyList<> * Made most functions in the Deserializing class private and static * Added static constant class for Enumerable expressions * Added null checking for arrays * Removed null checks from deserializing array functions * Removed support for JavaScript * Removed support for Unwind * Function names changed * Removed few functions. * Updated constants class * Function Formatting for ClientQL Deserializing (#4062) * Adding error handling for Deserializing functions * Finished updating code to remove all dependency on Newtonsoft.Json * Removed try catch for all upper level functions * Resolved comments * Resolved comments pt2 * Updated error message * Resolved comments pt3 * Changed parameter types from int to long * Removed ClientQLDelegate * Syntax Fixes * Removed ClientQLFlattenEnumerable file. This is JS. * Fixed List helper functions * Made singleton constructors from public to private * Updated the DeserializeClientQLBinaryLiteral function * Renamed ClientQL to QL * Fixed variable names * Updated more variable names * Removed support for Type * Removed all extra newlines * Added null checks * Updated the name CoordinatorDistributionPlan to ClientDistributionPlan * Removed all support for Cassandra, Mongo and Binary Literal * Updaed ClientQL to Cql * Updated baseline test class property.
- Loading branch information
Showing
59 changed files
with
2,502 additions
and
0 deletions.
There are no files selected for viewing
561 changes: 561 additions & 0 deletions
561
....Azure.Cosmos/src/Query/Core/ClientDistributionPlan/ClientDistributionPlanDeserializer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/ClientDistributionPlan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
|
||
internal class ClientDistributionPlan | ||
{ | ||
public ClientDistributionPlan(CqlEnumerableExpression cql) | ||
{ | ||
this.Cql = cql ?? throw new ArgumentNullException(nameof(cql)); | ||
} | ||
|
||
public CqlEnumerableExpression Cql { get; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlAggregate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal abstract class CqlAggregate | ||
{ | ||
protected CqlAggregate(CqlAggregateKind kind) | ||
{ | ||
this.Kind = kind; | ||
} | ||
|
||
public CqlAggregateKind Kind { get; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...zure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlAggregateEnumerableExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
|
||
internal class CqlAggregateEnumerableExpression : CqlEnumerableExpression | ||
{ | ||
public CqlAggregateEnumerableExpression(CqlEnumerableExpression sourceExpression, CqlAggregate aggregate) | ||
: base(CqlEnumerableExpressionKind.Aggregate) | ||
{ | ||
this.SourceExpression = sourceExpression ?? throw new ArgumentNullException(nameof(sourceExpression)); | ||
this.Aggregate = aggregate ?? throw new ArgumentNullException(nameof(aggregate)); | ||
} | ||
|
||
public CqlEnumerableExpression SourceExpression { get; } | ||
|
||
public CqlAggregate Aggregate { get; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlAggregateKind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal enum CqlAggregateKind | ||
{ | ||
Builtin, | ||
Tuple, | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlAggregateOperatorKind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal enum CqlAggregateOperatorKind | ||
{ | ||
All, | ||
Any, | ||
Array, | ||
Count, | ||
First, | ||
Last, | ||
Max, | ||
Min, | ||
Sum, | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
....Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlArrayCreateScalarExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
internal class CqlArrayCreateScalarExpression : CqlScalarExpression | ||
{ | ||
private const string Array = "Array"; | ||
|
||
public CqlArrayCreateScalarExpression(IReadOnlyList<CqlScalarExpression> items) | ||
: base(CqlScalarExpressionKind.ArrayCreate) | ||
{ | ||
this.ArrayKind = Array; | ||
this.Items = items ?? throw new ArgumentNullException(nameof(items)); | ||
} | ||
|
||
public string ArrayKind { get; } | ||
|
||
public IReadOnlyList<CqlScalarExpression> Items { get; } | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlArrayIndexerScalarExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
|
||
internal class CqlArrayIndexerScalarExpression : CqlScalarExpression | ||
{ | ||
public CqlArrayIndexerScalarExpression(CqlScalarExpression expression, ulong index) | ||
: base(CqlScalarExpressionKind.ArrayIndexer) | ||
{ | ||
this.Expression = expression ?? throw new ArgumentNullException(nameof(expression)); | ||
this.Index = index; | ||
} | ||
|
||
public CqlScalarExpression Expression { get; } | ||
|
||
public ulong Index { get; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlArrayLiteral.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
internal class CqlArrayLiteral : CqlLiteral | ||
{ | ||
public CqlArrayLiteral(IReadOnlyList<CqlLiteral> items) | ||
: base(CqlLiteralKind.Array) | ||
{ | ||
this.Items = items ?? throw new ArgumentNullException(nameof(items)); | ||
} | ||
|
||
public IReadOnlyList<CqlLiteral> Items { get; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...osoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlBinaryScalarExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
using System; | ||
|
||
internal class CqlBinaryScalarExpression : CqlScalarExpression | ||
{ | ||
public CqlBinaryScalarExpression(CqlBinaryScalarOperatorKind operatorKind, CqlScalarExpression leftExpression, CqlScalarExpression rightExpression) | ||
: base(CqlScalarExpressionKind.BinaryOperator) | ||
{ | ||
this.OperatorKind = operatorKind; | ||
this.LeftExpression = leftExpression ?? throw new ArgumentNullException(nameof(leftExpression)); | ||
this.RightExpression = rightExpression ?? throw new ArgumentNullException(nameof(rightExpression)); | ||
} | ||
|
||
public CqlBinaryScalarOperatorKind OperatorKind { get; } | ||
|
||
public CqlScalarExpression LeftExpression { get; } | ||
|
||
public CqlScalarExpression RightExpression { get; } | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...oft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlBinaryScalarOperatorKind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal enum CqlBinaryScalarOperatorKind | ||
{ | ||
Add, | ||
And, | ||
BitwiseAnd, | ||
BitwiseOr, | ||
BitwiseXor, | ||
Divide, | ||
Equal, | ||
GreaterThan, | ||
GreaterThanOrEqual, | ||
LeftShift, | ||
LessThan, | ||
LessThanOrEqual, | ||
Modulo, | ||
Multiply, | ||
NotEqual, | ||
Or, | ||
RightShift, | ||
Subtract, | ||
ZeroFillRightShift | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlBooleanLiteral.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal class CqlBooleanLiteral : CqlLiteral | ||
{ | ||
public CqlBooleanLiteral(bool value) | ||
: base(CqlLiteralKind.Boolean) | ||
{ | ||
this.Value = value; | ||
} | ||
|
||
public bool Value { get; } | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Microsoft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlBuiltinAggregate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal class CqlBuiltinAggregate : CqlAggregate | ||
{ | ||
public CqlBuiltinAggregate(CqlAggregateOperatorKind operatorKind) | ||
: base(CqlAggregateKind.Builtin) | ||
{ | ||
this.OperatorKind = operatorKind; | ||
} | ||
|
||
public CqlAggregateOperatorKind OperatorKind { get; } | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
...ft.Azure.Cosmos/src/Query/Core/ClientDistributionPlan/Cql/CqlBuiltinScalarFunctionKind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.Cosmos.Query.Core.ClientDistributionPlan.Cql | ||
{ | ||
internal enum CqlBuiltinScalarFunctionKind | ||
{ | ||
Abs, | ||
Acos, | ||
All, | ||
Any, | ||
Array, | ||
Array_Concat, | ||
Array_Contains, | ||
Array_Length, | ||
Array_Slice, | ||
Asin, | ||
Atan, | ||
Atn2, | ||
Avg, | ||
Ceiling, | ||
Choose, | ||
Concat, | ||
Contains, | ||
Cos, | ||
Cot, | ||
Count, | ||
DateTimeAdd, | ||
DateTimeBin, | ||
DateTimeDiff, | ||
DateTimeFromParts, | ||
DateTimePart, | ||
DateTimeToTicks, | ||
DateTimeToTimestamp, | ||
Degrees, | ||
DocumentId, | ||
EndsWith, | ||
Exp, | ||
First, | ||
Floor, | ||
GetCurrentDateTime, | ||
GetCurrentDateTimeStatic, | ||
GetCurrentTicks, | ||
GetCurrentTicksStatic, | ||
GetCurrentTimestamp, | ||
GetCurrentTimestampStatic, | ||
Iif, | ||
Index_Of, | ||
IntAdd, | ||
IntBitAnd, | ||
IntBitLeftShift, | ||
IntBitNot, | ||
IntBitOr, | ||
IntBitRightShift, | ||
IntBitXor, | ||
IntDiv, | ||
IntMod, | ||
IntMul, | ||
IntSub, | ||
Is_Array, | ||
Is_Bool, | ||
Is_DateTime, | ||
Is_Defined, | ||
Is_Finite_Number, | ||
Is_Integer, | ||
Is_Null, | ||
Is_Number, | ||
Is_Object, | ||
Is_Primitive, | ||
Is_String, | ||
Last, | ||
LastIndexOf, | ||
Left, | ||
Length, | ||
Like, | ||
Log, | ||
Log10, | ||
Lower, | ||
Ltrim, | ||
Max, | ||
Min, | ||
NumberBin, | ||
ObjectToArray, | ||
Pi, | ||
Power, | ||
Radians, | ||
Rand, | ||
RegexMatch, | ||
Replace, | ||
Replicate, | ||
Reverse, | ||
Right, | ||
Round, | ||
Rtrim, | ||
SetDifference, | ||
SetIntersect, | ||
SetUnion, | ||
Sign, | ||
Sin, | ||
Sqrt, | ||
Square, | ||
ST_Area, | ||
ST_Distance, | ||
ST_Intersects, | ||
ST_IsValid, | ||
ST_IsValidDetailed, | ||
ST_Within, | ||
StartsWith, | ||
StringEquals, | ||
StringToArray, | ||
StringToBoolean, | ||
StringToNull, | ||
StringToNumber, | ||
StringToObject, | ||
Substring, | ||
Sum, | ||
Tan, | ||
TicksToDateTime, | ||
TimestampToDateTime, | ||
ToString, | ||
Trim, | ||
Trunc, | ||
Upper | ||
} | ||
} |
Oops, something went wrong.