use of com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.LogicalReference in project elide by yahoo.
the class QueryPlanTranslator method addHiddenProjections.
public static Query.QueryBuilder addHiddenProjections(MetaDataStore metaDataStore, Query.QueryBuilder builder, Query query) {
Set<ColumnProjection> directReferencedColumns = Streams.concat(query.getColumnProjections().stream(), query.getFilterProjections(query.getWhereFilter(), ColumnProjection.class).stream()).collect(Collectors.toSet());
ExpressionParser parser = new ExpressionParser(metaDataStore);
Set<ColumnProjection> indirectReferenceColumns = new HashSet<>();
directReferencedColumns.forEach(column -> {
parser.parse(query.getSource(), column).stream().map(reference -> reference.accept(new ReferenceExtractor<LogicalReference>(LogicalReference.class, metaDataStore, ReferenceExtractor.Mode.SAME_QUERY))).flatMap(Set::stream).map(LogicalReference::getColumn).forEach(indirectReferenceColumns::add);
});
Streams.concat(directReferencedColumns.stream(), indirectReferenceColumns.stream()).forEach(column -> {
if (query.getColumnProjection(column.getAlias(), column.getArguments()) == null) {
builder.column(column.withProjected(false));
}
});
return builder;
}
Aggregations