@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };
@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };
@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };