Fix variable names in QueryOptimizationsTest
Fix distinct