==== VARIATION: optimized $match with $or: pipeline is able to use a SargableNode with a disjunction of point intervals. ====
-- INPUTS:
pipeline: [{$match: {$or: [{a: 1}, {a: 2}, {a: 3}]}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Sargable [Complete]
|   |   |   requirements: 
|   |   |       {{{scan_0, 'PathGet [a] PathTraverse [1] PathIdentity []', {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}}}}
|   |   candidateIndexes: 
|   |       candidateId: 1, index1, {}, {Compound}, {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}
|   scanParams: 
|       {'a': evalTemp_0}
|           residualReqs: 
|               {{{evalTemp_0, 'PathTraverse [1] PathIdentity []', {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}, entryIndex: 0}}}
Scan [collection, {scan_0}]


==== VARIATION: optimized $match with $in and a list of equalities becomes a comparison to an EqMember list. ====
-- INPUTS:
pipeline: [{$match: {a: {$in: [1, 2, 3]}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Sargable [Complete]
|   |   |   requirements: 
|   |   |       {{{scan_0, 'PathGet [a] PathTraverse [1] PathIdentity []', {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}}}}
|   |   candidateIndexes: 
|   |       candidateId: 1, index1, {}, {Compound}, {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}
|   scanParams: 
|       {'a': evalTemp_0}
|           residualReqs: 
|               {{{evalTemp_0, 'PathTraverse [1] PathIdentity []', {{{=Const [1]}} U {{=Const [2]}} U {{=Const [3]}}}, entryIndex: 0}}}
Scan [collection, {scan_0}]


==== VARIATION: optimized $project inclusion then $match: observe the Filter can be reordered against the Eval node ====
-- INPUTS:
pipeline: [{$project: {a: 1, b: 1}}, {$match: {a: 2}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [b]
|   |   PathConstant []
|   |   Variable [fieldProj_2]
|   PathComposeM []
|   |   PathField [a]
|   |   PathConstant []
|   |   Variable [fieldProj_1]
|   PathField [_id]
|   PathConstant []
|   Variable [fieldProj_0]
Filter []
|   EvalFilter []
|   |   Variable [fieldProj_1]
|   PathTraverse [1]
|   PathCompare [Eq]
|   Const [2]
PhysicalScan [{'_id': fieldProj_0, 'a': fieldProj_1, 'b': fieldProj_2}, collection]


==== VARIATION: optimized $match basic ====
-- INPUTS:
pipeline: [{$match: {a: 1, b: 2}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Filter []
|   EvalFilter []
|   |   Variable [evalTemp_3]
|   PathTraverse [1]
|   PathCompare [Eq]
|   Const [2]
Filter []
|   EvalFilter []
|   |   Variable [evalTemp_2]
|   PathTraverse [1]
|   PathCompare [Eq]
|   Const [1]
PhysicalScan [{'<root>': scan_0, 'a': evalTemp_2, 'b': evalTemp_3}, collection]


==== VARIATION: optimized $expr filter: make sure we have a single array constant for (1, 2, 'str', ...) ====
-- INPUTS:
pipeline: [{$project: {a: {$filter: {input: [1, 2, 'str', {a: 2.0, b:'s'}, 3, 4], as: 'num', cond: {$and: [{$gte: ['$$num', 2]}, {$lte: ['$$num', 3]}]}}}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Variable [scan_0]
|   PathComposeM []
|   |   PathDefault []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [a]
|   |   PathConstant []
|   |   EvalPath []
|   |   |   Const [[1, 2, "str", {"a" : 2, "b" : "s"}, 3, 4]]
|   |   PathTraverse [inf]
|   |   PathLambda []
|   |   LambdaAbstraction [var_1]
|   |   If []
|   |   |   |   Const [Nothing]
|   |   |   Variable [var_1]
|   |   BinaryOp [And]
|   |   |   BinaryOp [Gte]
|   |   |   |   Const [2]
|   |   |   Variable [var_1]
|   |   BinaryOp [Lte]
|   |   |   Const [3]
|   |   Variable [var_1]
|   PathKeep [_id, a]
Scan [collection, {scan_0}]


==== VARIATION: optimized $group local global ====
-- INPUTS:
pipeline: [{$group: {_id: '$a', c: {$sum: '$b'}}}]
metadata: 
	number of partitions: 5
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: UnknownPartitioning
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{agg_project_0}]
Exchange []
|   |   distribution: 
|   |       type: Centralized
Evaluation [{agg_project_0}]
|   EvalPath []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [c]
|   |   PathConstant []
|   |   Variable [field_agg_0]
|   PathField [_id]
|   PathConstant []
|   Variable [groupByProj_0]
GroupBy [{groupByProj_0}, Global]
|   aggregations: 
|       [field_agg_0]
|           FunctionCall [$sum]
|           Variable [preagg_0]
Exchange []
|   |   distribution: 
|   |       type: HashPartitioning
|   |           projections: 
|   |               groupByProj_0
GroupBy [{groupByProj_0}, Local]
|   aggregations: 
|       [preagg_0]
|           FunctionCall [$sum]
|           Variable [groupByInputProj_0]
PhysicalScan [{'a': groupByProj_0, 'b': groupByInputProj_0}, collection, parallel]


==== VARIATION: optimized $unwind then $sort ====
-- INPUTS:
pipeline: [{$unwind: '$x'}, {$sort: {'x': 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPost
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse
	PathLower

-- OUTPUT:
Root [{embedProj_0}]
Collation [{sort_0: Ascending}]
Evaluation [{sort_0} = Variable [unwoundProj_0]]
Evaluation [{embedProj_0}]
|   FunctionCall [makeBsonObj]
|   |   |   |   Variable [unwoundProj_0]
|   |   |   Const [false]
|   |   Variable [scan_0]
|   Const [MakeObjSpec([x = Set(0)], Open, NewObj, 0)]
Unwind [{unwoundProj_0, unwoundPid_0}]
PhysicalScan [{'<root>': scan_0, 'x': unwoundProj_0}, collection]


==== VARIATION: optimized $match with index ====
-- INPUTS:
pipeline: [{$match: {'a': 10}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
NestedLoopJoin [joinType: Inner, {rid_0}]
|   |   Const [true]
|   LimitSkip [limit: 1, skip: 0]
|   Seek [ridProjection: rid_0, {'<root>': scan_0}, collection]
IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [10]}]


==== VARIATION: optimized $match index covered ====
-- INPUTS:
pipeline: [{$project: {_id: 0, a: 1}}, {$match: {'a': 10}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 0
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathField [a]
|   PathConstant []
|   Variable [fieldProj_0]
IndexScan [{'<indexKey> 0': fieldProj_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [10]}]


==== VARIATION: optimized $match index covered, match then project ====
-- INPUTS:
pipeline: [{$match: {'a': 10}}, {$project: {_id: 0, a: 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 0
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathField [a]
|   PathConstant []
|   Variable [fieldProj_0]
IndexScan [{'<indexKey> 0': fieldProj_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [10]}]


==== VARIATION: optimized $match index covered, match on two indexed keys then project ====
-- INPUTS:
pipeline: [{$match: {'a': 10, 'b': 20}}, {$project: {_id: 0, a: 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [b]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 0
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathField [a]
|   PathConstant []
|   Variable [fieldProj_0]
IndexScan [{'<indexKey> 0': fieldProj_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [10 | 20]}]


==== VARIATION: optimized $match index covered, match on three indexed keys then project ====
-- INPUTS:
pipeline: [{$match: {'a': 10, 'b': 20, 'c': 30}}, {$project: {_id: 0, a: 1, b: 1, c: 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [b]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [c]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 0
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [c]
|   |   PathConstant []
|   |   Variable [fieldProj_2]
|   PathComposeM []
|   |   PathField [b]
|   |   PathConstant []
|   |   Variable [fieldProj_1]
|   PathField [a]
|   PathConstant []
|   Variable [fieldProj_0]
IndexScan [{'<indexKey> 0': fieldProj_0, '<indexKey> 1': fieldProj_1, '<indexKey> 2': fieldProj_2}, scanDefName: collection, indexDefName: index1, interval: {=Const [10 | 20 | 30]}]


==== VARIATION: optimized $match index covered, inclusion project then match on three indexed keys ====
-- INPUTS:
pipeline: [{$project: {_id: 0, a: 1, b: 1, c: 1}}, {$match: {'a': 10, 'b': 20, 'c': 30}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [b]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [c]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 0
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [c]
|   |   PathConstant []
|   |   Variable [fieldProj_2]
|   PathComposeM []
|   |   PathField [b]
|   |   PathConstant []
|   |   Variable [fieldProj_1]
|   PathField [a]
|   PathConstant []
|   Variable [fieldProj_0]
IndexScan [{'<indexKey> 0': fieldProj_0, '<indexKey> 1': fieldProj_1, '<indexKey> 2': fieldProj_2}, scanDefName: collection, indexDefName: index1, interval: {=Const [10 | 20 | 30]}]


==== VARIATION: optimized $match sort index ====
-- INPUTS:
pipeline: [{$match: {'a': 10}}, {$sort: {'a': 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Collation [{sort_0: Ascending}]
NestedLoopJoin [joinType: Inner, {rid_0}]
|   |   Const [true]
|   LimitSkip [limit: 1, skip: 0]
|   Seek [ridProjection: rid_0, {'<root>': scan_0, 'a': sort_0}, collection]
IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [10]}]


==== VARIATION: optimized range index ====
-- INPUTS:
pipeline: [{$match: {'a': {$gt: 70, $lt: 90}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
NestedLoopJoin [joinType: Inner, {rid_0}]
|   |   Const [true]
|   LimitSkip [limit: 1, skip: 0]
|   Seek [ridProjection: rid_0, {'<root>': scan_0}, collection]
Filter []
|   EvalFilter []
|   |   FunctionCall [getArraySize]
|   |   Variable [sides_0]
|   PathCompare [Eq]
|   Const [2]
GroupBy [{rid_0}]
|   aggregations: 
|       [sides_0]
|           FunctionCall [$addToSet]
|           Variable [sideId_0]
Union [{rid_0, sideId_0}]
|   Evaluation [{sideId_0} = Const [1]]
|   IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {(Const [70], Const [""])}]
Evaluation [{sideId_0} = Const [0]]
IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {(Const [nan], Const [90])}]


==== VARIATION: optimized index on two keys ====
-- INPUTS:
pipeline: [{$match: {'a': 2, 'b': 2}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
						ABT path: 
							PathGet [b]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
NestedLoopJoin [joinType: Inner, {rid_0}]
|   |   Const [true]
|   LimitSkip [limit: 1, skip: 0]
|   Seek [ridProjection: rid_0, {'<root>': scan_0}, collection]
IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [2 | 2]}]


==== VARIATION: optimized index on one key ====
-- INPUTS:
pipeline: [{$match: {'a': 2, 'b': 2}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
				index1: 
					collation spec: 
						ABT path: 
							PathGet [a]
							PathTraverse [1]
							PathIdentity []

						collation op: Ascending
					version: 1
					ordering bits: 0
					is multi-key: 1
					distribution and paths: 
						distribution type: Centralized
						distribution paths: 
					requirements: 

			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPost
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
NestedLoopJoin [joinType: Inner, {rid_0}]
|   |   Const [true]
|   Filter []
|   |   EvalFilter []
|   |   |   Variable [evalTemp_4]
|   |   PathTraverse [1]
|   |   PathCompare [Eq]
|   |   Const [2]
|   LimitSkip [limit: 1, skip: 0]
|   Seek [ridProjection: rid_0, {'<root>': scan_0, 'b': evalTemp_4}, collection]
IndexScan [{'<rid>': rid_0}, scanDefName: collection, indexDefName: index1, interval: {=Const [2]}]


==== VARIATION: optimized $group eval no inline: verify that "b" is not inlined in the group expression, but is coming from the physical scan ====
-- INPUTS:
pipeline: [{$group: {_id: null, a: {$first: '$b'}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collection: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPost
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse
	PathLower

-- OUTPUT:
Root [{agg_project_0}]
Evaluation [{agg_project_0}]
|   FunctionCall [makeBsonObj]
|   |   |   |   |   Variable [field_agg_0]
|   |   |   |   Variable [groupByProj_0]
|   |   |   Const [false]
|   |   Const [{}]
|   Const [MakeObjSpec([_id = Set(0), a = Set(1)], Open, NewObj, 0)]
GroupBy [{groupByProj_0}]
|   aggregations: 
|       [field_agg_0]
|           FunctionCall [$first]
|           Variable [groupByInputProj_0]
Evaluation [{groupByProj_0} = Const [null]]
PhysicalScan [{'b': groupByInputProj_0}, collection]


==== VARIATION: optimized union ====
-- INPUTS:
pipeline: [{$unionWith: 'collB'}, {$match: {_id: 1}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		collA: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
		collB: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Union [{scan_0}]
|   Evaluation [{scan_0} = Variable [scan_1]]
|   Filter []
|   |   EvalFilter []
|   |   |   Variable [evalTemp_1]
|   |   PathTraverse [1]
|   |   PathCompare [Eq]
|   |   Const [1]
|   PhysicalScan [{'<root>': scan_1, '_id': evalTemp_1}, collB]
Filter []
|   EvalFilter []
|   |   Variable [evalTemp_0]
|   PathTraverse [1]
|   PathCompare [Eq]
|   Const [1]
PhysicalScan [{'<root>': scan_0, '_id': evalTemp_0}, collA]


==== VARIATION: optimized common expression elimination ====
-- INPUTS:
pipeline: [{$project: {foo: {$add: ['$b', 1]}, bar: {$add: ['$b', 1]}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		test: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre

-- OUTPUT:
Root [{combinedProjection_0}]
Evaluation [{combinedProjection_0}]
|   EvalPath []
|   |   Variable [scan_0]
|   PathComposeM []
|   |   PathDefault []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [foo]
|   |   PathConstant []
|   |   Variable [projGetPath_0]
|   PathComposeM []
|   |   PathField [bar]
|   |   PathConstant []
|   |   Variable [projGetPath_0]
|   PathKeep [_id, bar, foo]
Evaluation [{projGetPath_0}]
|   BinaryOp [Add]
|   |   Const [1]
|   EvalPath []
|   |   Variable [scan_0]
|   PathGet [b]
|   PathIdentity []
Scan [test, {scan_0}]


==== VARIATION: optimized group by dependency: demonstrate that "c" is set to the array size (not the array itself coming from the group) ====
-- INPUTS:
pipeline: [{$group: {_id: {}, b: {$addToSet: '$a'}}}, {$project: {_id: 0, b: {$size: '$b'}}}, {$project: {_id: 0, c: '$b'}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		test: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	ConstEvalPre
	MemoExplorationPhase
	MemoImplementationPhase
	MemoSubstitutionPhase
	PathFuse

-- OUTPUT:
Root [{combinedProjection_1}]
Evaluation [{combinedProjection_1}]
|   EvalPath []
|   |   Const [{}]
|   PathComposeM []
|   |   PathField [c]
|   |   PathConstant []
|   |   FunctionCall [getArraySize]
|   |   Variable [field_agg_0]
|   PathKeep []
GroupBy [{groupByProj_0}]
|   aggregations: 
|       [field_agg_0]
|           FunctionCall [$addToSet]
|           Variable [groupByInputProj_0]
Evaluation [{groupByProj_0} = Const [{}]]
PhysicalScan [{'a': groupByInputProj_0}, test]


==== VARIATION: optimized double $elemMatch ====
-- INPUTS:
pipeline: [{$match: {a: {$elemMatch: {$gte: 5, $lte: 6}}, b: {$elemMatch: {$gte: 1, $lte: 3}}}}]
metadata: 
	number of partitions: 1
	scan definitions: 
		test: 
			options: 
			distribution and paths: 
				distribution type: Centralized
				distribution paths: 
			indexes: 
			collection exists: 1
			CE type: (empty)
optimization phases: 
	MemoSubstitutionPhase

-- OUTPUT:
Root [{scan_0}]
Sargable [Complete]
|   |   requirements: 
|   |       {{
|   |           {scan_0, 'PathGet [a] PathIdentity []', {{{[Const [[]], Const [BinData(0, )])}}}}
|   |        ^ 
|   |           {scan_0, 'PathGet [a] PathTraverse [1] PathIdentity []', {{{[Const [5], Const [6]]}}}}
|   |        ^ 
|   |           {scan_0, 'PathGet [b] PathIdentity []', {{{[Const [[]], Const [BinData(0, )])}}}}
|   |        ^ 
|   |           {scan_0, 'PathGet [b] PathTraverse [1] PathIdentity []', {{{[Const [1], Const [3]]}}}}
|   |       }}
|   scanParams: 
|       {'a': evalTemp_7, 'b': evalTemp_8}
|           residualReqs: 
|               {{
|                   {evalTemp_7, 'PathIdentity []', {{{[Const [[]], Const [BinData(0, )])}}}, entryIndex: 0}
|                ^ 
|                   {evalTemp_7, 'PathTraverse [1] PathIdentity []', {{{[Const [5], Const [6]]}}}, entryIndex: 1}
|                ^ 
|                   {evalTemp_8, 'PathIdentity []', {{{[Const [[]], Const [BinData(0, )])}}}, entryIndex: 2}
|                ^ 
|                   {evalTemp_8, 'PathTraverse [1] PathIdentity []', {{{[Const [1], Const [3]]}}}, entryIndex: 3}
|               }}
Scan [test, {scan_0}]


