List<IAlgebraicRewriteRule> normalization = new LinkedList<IAlgebraicRewriteRule>();
normalization.add(new SetVariableIdContextRule());
// Remove unused functions.
normalization.add(new RemoveUnusedSortDistinctNodesRule());
normalization.add(new RemoveRedundantVariablesRule());
normalization.add(new RemoveUnusedAssignAndAggregateRule());
// TODO Fix the group by operator before putting back in the rule set.
// normalization.add(new ConvertAssignSortDistinctNodesToOperatorsRule());
normalization.add(new RemoveUnusedTreatRule());
normalization.add(new RemoveRedundantVariablesRule());
normalization.add(new RemoveUnusedAssignAndAggregateRule());
// Find unnest followed by aggregate in a subplan.
normalization.add(new EliminateUnnestAggregateSubplanRule());
normalization.add(new RemoveRedundantVariablesRule());
normalization.add(new RemoveUnusedAssignAndAggregateRule());
// Remove single tuple input subplans and merge unnest aggregate operators.
// TODO Fix EliminateSubplanForSinglePathsRule to check for variables used after the subplan.
// normalization.add(new EliminateSubplanForSinglePathsRule());
normalization.add(new EliminateUnnestAggregateSequencesRule());
normalization.add(new ConvertAssignToUnnestRule());
// Used to clean up any missing noops after all the subplans have been altered.
normalization.add(new RemoveRedundantVariablesRule());
normalization.add(new RemoveUnusedAssignAndAggregateRule());
// Convert to a data source scan operator.
normalization.add(new SetCollectionDataSourceRule());
normalization.add(new IntroduceCollectionRule());