use of org.pentaho.di.core.sql.SQLFields in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGenerator method generateUniqueStep.
private StepMeta generateUniqueStep(RowMetaInterface rowMeta) {
SQLFields fields = sql.getSelectFields();
MemoryGroupByMeta meta = new MemoryGroupByMeta();
meta.allocate(fields.getFields().size(), 0);
for (int i = 0; i < fields.getFields().size(); i++) {
SQLField field = fields.getFields().get(i);
if (!Utils.isEmpty(field.getAlias()) && rowMeta.searchValueMeta(field.getAlias()) != null) {
meta.getGroupField()[i] = field.getAlias();
} else {
meta.getGroupField()[i] = field.getField();
}
}
StepMeta stepMeta = new StepMeta("DISTINCT", meta);
stepMeta.setLocation(xLocation, 50);
xLocation += 100;
stepMeta.setDraw(true);
return stepMeta;
}
use of org.pentaho.di.core.sql.SQLFields in project pdi-dataservice-server-plugin by pentaho.
the class CachedService method answersQuery.
public boolean answersQuery(DataServiceExecutor executor) {
SQL sql = executor.getSql();
// If this loader is complete, it always answers the query
if (isComplete()) {
return true;
}
// If aggregate functions or grouping is queried, a complete set is needed
SQLFields selectFields = sql.getSelectFields();
SQLFields groupFields = sql.getGroupFields();
if (selectFields.hasAggregates() || selectFields.isDistinct() || !groupFields.getFields().isEmpty()) {
if (ranking.or(Integer.MAX_VALUE) < Integer.MAX_VALUE) {
return false;
}
}
boolean outRanks = true;
if (this.ranking.isPresent()) {
outRanks &= this.ranking.get() >= calculateRank(executor);
}
// the two row limits my or may not be related, treating as independent
if (this.rankingServiceRows.isPresent()) {
outRanks &= this.rankingServiceRows.get() >= calculateServiceRowRank(executor);
}
return outRanks;
}
Aggregations