Search in sources :

Example 1 with DimensionProjection

use of com.yahoo.elide.datastores.aggregation.query.DimensionProjection in project elide by yahoo.

the class EntityProjectionTranslator method resolveNonTimeDimensions.

/**
 * Gets dimensions except time dimensions based on relationships and attributes from {@link EntityProjection}.
 */
private Set<DimensionProjection> resolveNonTimeDimensions() {
    Set<DimensionProjection> attributes = entityProjection.getAttributes().stream().filter(attribute -> queriedTable.getTimeDimension(attribute.getName()) == null).map(dimAttr -> {
        Dimension dimension = queriedTable.getDimension(dimAttr.getName());
        return dimension == null ? null : engine.constructDimensionProjection(dimension, dimAttr.getAlias(), getArgumentMapFromArgumentSet(dimAttr.getArguments()));
    }).filter(Objects::nonNull).collect(Collectors.toSet());
    Set<DimensionProjection> relationships = entityProjection.getRelationships().stream().map(dimAttr -> {
        Dimension dimension = queriedTable.getDimension(dimAttr.getName());
        return dimension == null ? null : engine.constructDimensionProjection(dimension, dimAttr.getAlias(), Collections.emptyMap());
    }).filter(Objects::nonNull).collect(Collectors.toSet());
    return Sets.union(attributes, relationships);
}
Also used : PredicateExtractionVisitor(com.yahoo.elide.core.filter.expression.PredicateExtractionVisitor) DimensionProjection(com.yahoo.elide.datastores.aggregation.query.DimensionProjection) Set(java.util.Set) EntityProjection(com.yahoo.elide.core.request.EntityProjection) Dimension(com.yahoo.elide.datastores.aggregation.metadata.models.Dimension) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) InvalidOperationException(com.yahoo.elide.core.exceptions.InvalidOperationException) FilterConstraints(com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints) Query(com.yahoo.elide.datastores.aggregation.query.Query) List(java.util.List) ImmutablePagination(com.yahoo.elide.datastores.aggregation.query.ImmutablePagination) Argument.getArgumentMapFromArgumentSet(com.yahoo.elide.core.request.Argument.getArgumentMapFromArgumentSet) TimeDimension(com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension) Table(com.yahoo.elide.datastores.aggregation.metadata.models.Table) TimeDimensionProjection(com.yahoo.elide.datastores.aggregation.query.TimeDimensionProjection) MetricProjection(com.yahoo.elide.datastores.aggregation.query.MetricProjection) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) RequestScope(com.yahoo.elide.core.RequestScope) SplitFilterExpressionVisitor(com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor) DimensionProjection(com.yahoo.elide.datastores.aggregation.query.DimensionProjection) TimeDimensionProjection(com.yahoo.elide.datastores.aggregation.query.TimeDimensionProjection) Dimension(com.yahoo.elide.datastores.aggregation.metadata.models.Dimension) TimeDimension(com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension)

Aggregations

Sets (com.google.common.collect.Sets)1 RequestScope (com.yahoo.elide.core.RequestScope)1 InvalidOperationException (com.yahoo.elide.core.exceptions.InvalidOperationException)1 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)1 PredicateExtractionVisitor (com.yahoo.elide.core.filter.expression.PredicateExtractionVisitor)1 Argument.getArgumentMapFromArgumentSet (com.yahoo.elide.core.request.Argument.getArgumentMapFromArgumentSet)1 EntityProjection (com.yahoo.elide.core.request.EntityProjection)1 FilterConstraints (com.yahoo.elide.datastores.aggregation.filter.visitor.FilterConstraints)1 SplitFilterExpressionVisitor (com.yahoo.elide.datastores.aggregation.filter.visitor.SplitFilterExpressionVisitor)1 Dimension (com.yahoo.elide.datastores.aggregation.metadata.models.Dimension)1 Table (com.yahoo.elide.datastores.aggregation.metadata.models.Table)1 TimeDimension (com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension)1 DimensionProjection (com.yahoo.elide.datastores.aggregation.query.DimensionProjection)1 ImmutablePagination (com.yahoo.elide.datastores.aggregation.query.ImmutablePagination)1 MetricProjection (com.yahoo.elide.datastores.aggregation.query.MetricProjection)1 Query (com.yahoo.elide.datastores.aggregation.query.Query)1 TimeDimensionProjection (com.yahoo.elide.datastores.aggregation.query.TimeDimensionProjection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1