Search in sources :

Example 1 with TimeDimensionGrain

use of com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimensionGrain in project elide by yahoo.

the class MetaDataStore method addColumn.

/**
 * Add a column metadata object.
 *
 * @param column column metadata
 */
private void addColumn(Column column) {
    String version = column.getVersion();
    if (!column.isHidden()) {
        addMetaData(column, version);
    }
    if (column instanceof TimeDimension) {
        TimeDimension timeDimension = (TimeDimension) column;
        for (TimeDimensionGrain grain : timeDimension.getSupportedGrains()) {
            addTimeDimensionGrain(grain, version);
        }
    }
    column.getArgumentDefinitions().forEach(arg -> addArgument(arg, version));
}
Also used : TimeDimensionGrain(com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimensionGrain) TimeDimension(com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension)

Example 2 with TimeDimensionGrain

use of com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimensionGrain 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

TimeDimensionGrain (com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimensionGrain)2 TimeDimension (com.yahoo.elide.datastores.aggregation.metadata.models.TimeDimension)1 ColumnProjection (com.yahoo.elide.datastores.aggregation.query.ColumnProjection)1 ExpressionParser (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.ExpressionParser)1 Reference (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference)1