Search in sources :

Example 1 with SQLFields

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;
}
Also used : MemoryGroupByMeta(org.pentaho.di.trans.steps.memgroupby.MemoryGroupByMeta) SQLFields(org.pentaho.di.core.sql.SQLFields) SQLField(org.pentaho.di.core.sql.SQLField) StepMeta(org.pentaho.di.trans.step.StepMeta)

Example 2 with SQLFields

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;
}
Also used : SQLFields(org.pentaho.di.core.sql.SQLFields) SQL(org.pentaho.di.core.sql.SQL)

Aggregations

SQLFields (org.pentaho.di.core.sql.SQLFields)2 SQL (org.pentaho.di.core.sql.SQL)1 SQLField (org.pentaho.di.core.sql.SQLField)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 MemoryGroupByMeta (org.pentaho.di.trans.steps.memgroupby.MemoryGroupByMeta)1