Search in sources :

Example 36 with ColumnProjection

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

the class SQLTimeDimensionProjection method nest.

@Override
public Pair<ColumnProjection, Set<ColumnProjection>> nest(Queryable source, MetaDataStore store, boolean joinInOuter) {
    List<Reference> references = new ExpressionParser(store).parse(source, getExpression());
    boolean requiresJoin = SQLColumnProjection.requiresJoin(references);
    String columnId = source.isRoot() ? getName() : getAlias();
    boolean inProjection = source.getColumnProjection(columnId, getArguments(), true) != null;
    ColumnProjection outerProjection;
    Set<ColumnProjection> innerProjections;
    if (requiresJoin && joinInOuter) {
        String outerProjectionExpression = toPhysicalReferences(source, store);
        outerProjection = withExpression(outerProjectionExpression, inProjection);
        innerProjections = SQLColumnProjection.extractPhysicalReferences(source, references, store);
    } else {
        outerProjection = SQLTimeDimensionProjection.builder().name(name).alias(alias).valueType(valueType).columnType(columnType).grain(new TimeDimensionGrain(this.getName(), grain.getGrain())).expression("{{$" + this.getSafeAlias() + "}}").projected(isProjected()).arguments(arguments).timeZone(timeZone).build();
        innerProjections = new LinkedHashSet<>(Arrays.asList(this));
    }
    return Pair.of(outerProjection, innerProjections);
}
Also used : Reference(com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference) ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) TimeDimensionGrain(com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimensionGrain) ExpressionParser(com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.ExpressionParser)

Aggregations

ColumnProjection (com.yahoo.elide.datastores.aggregation.query.ColumnProjection)36 Test (org.junit.jupiter.api.Test)22 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)13 Argument (com.yahoo.elide.core.request.Argument)7 Queryable (com.yahoo.elide.datastores.aggregation.query.Queryable)6 Query (com.yahoo.elide.datastores.aggregation.query.Query)5 Argument.getArgumentMapFromString (com.yahoo.elide.core.request.Argument.getArgumentMapFromString)4 ValueType (com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType)4 Column (com.yahoo.elide.datastores.aggregation.metadata.models.Column)4 ExpressionParser (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.ExpressionParser)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Path (com.yahoo.elide.core.Path)3 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)3 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)3 Reference (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference)3 HashMap (java.util.HashMap)3 HandlebarsException (com.github.jknack.handlebars.HandlebarsException)2 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)2