Class NonAggregationGroupByToDistinctQueryRewriter

  • All Implemented Interfaces:
    QueryRewriter

    public class NonAggregationGroupByToDistinctQueryRewriter
    extends Object
    implements QueryRewriter
    Rewrite non-aggregation group-by query to distinct query. The query can be rewritten only if select expression set and group-by expression set are the same. E.g. SELECT col1, col2 FROM foo GROUP BY col1, col2 --> SELECT DISTINCT col1, col2 FROM foo SELECT col1, col2 FROM foo GROUP BY col2, col1 --> SELECT DISTINCT col1, col2 FROM foo SELECT col1 + col2 FROM foo GROUP BY col1 + col2 --> SELECT DISTINCT col1 + col2 FROM foo SELECT col1 AS c1 FROM foo GROUP BY col1 --> SELECT DISTINCT col1 AS c1 FROM foo SELECT col1, col1 AS c1, col2 FROM foo GROUP BY col1, col2 --> SELECT DISTINCT col1, col1 AS ci, col2 FROM foo Unsupported queries: SELECT col1 FROM foo GROUP BY col1, col2 (not equivalent to SELECT DISTINCT col1 FROM foo) SELECT col1 + col2 FROM foo GROUP BY col1, col2 (not equivalent to SELECT col1 + col2 FROM foo)
    • Constructor Detail

      • NonAggregationGroupByToDistinctQueryRewriter

        public NonAggregationGroupByToDistinctQueryRewriter()