private static String getFunction(Selection column, DatabaseMeta databaseMeta) { String fn = ""; // $NON-NLS-1$ switch (column.getActiveAggregationType()) { case AVERAGE: fn = databaseMeta.getFunctionAverage(); break; case COUNT_DISTINCT: case COUNT: fn = databaseMeta.getFunctionCount(); break; case MAXIMUM: fn = databaseMeta.getFunctionMaximum(); break; case MINIMUM: fn = databaseMeta.getFunctionMinimum(); break; case SUM: fn = databaseMeta.getFunctionSum(); break; default: break; } return fn; }
// This method is for backwards compatibility of already defined // isExact formulas that may contain at the root an aggregate function. private static boolean hasAggregateDefinedAlready(String sql, DatabaseMeta databaseMeta) { String trimmed = sql.trim(); return trimmed.startsWith(databaseMeta.getFunctionAverage() + "(") || //$NON-NLS-1$ trimmed.startsWith(databaseMeta.getFunctionCount() + "(") || //$NON-NLS-1$ trimmed.startsWith(databaseMeta.getFunctionMaximum() + "(") || //$NON-NLS-1$ trimmed.startsWith(databaseMeta.getFunctionMinimum() + "(") || //$NON-NLS-1$ trimmed.startsWith(databaseMeta.getFunctionSum() + "("); // $NON-NLS-1$ }