DenseRankAnalytic

A DenseRankAnalytic is an AnalyticFunction that determines the dense ranking over any values, returning the dense rank as a Long. Values range from 1 through a number less than or equal to the number of rows in the partition. Distinct order by values result in evenly spaced values, e.g. 1 2 3 4 5. If there are equivalent order by values, then all equivalent values receive the same value, and the next value will have no gaps, e.g. 1 2 2 3 4.

Usage

Create and use a DenseRankAnalytic, with one of the following methods:

  • AnalyticAggregator ana = new AnalyticAggregator.Builder()
        .setAnalyticFunction(new DenseRankAnalytic())
        .setPartition(new PartitionClause(Arrays.asList("category1")))
        .setOrderBy(new OrderByClause(Arrays.asList(new OrderByElement("value2", OrderByElement.SortDir.DESC))))
        .build();
    
  • AnalyticAggregator agg = AnalyticAggregator.getAnalytic("DenseRank() partitionBy(category1) orderBy(value2 DESC)");
    

DenseRankAnalytic is a NoPropAnalytic, so it is an error to specify a property. It does not take a user-given window clause.

If every order by value is distinct, then this generates the same values as RowNumberAnalytic.