Search in sources :

Example 1 with JoinExpressionExtractor

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.JoinExpressionExtractor in project elide by yahoo.

the class QueryTranslator method extractJoinExpressions.

/**
 * Get required join expressions for given column in given Query.
 * @param column {@link ColumnProjection}
 * @param query Expanded Query.
 * @return A set of Join expressions that capture a relationship traversal.
 */
private Set<String> extractJoinExpressions(ColumnProjection column, Query query) {
    Set<String> joinExpressions = new LinkedHashSet<>();
    ColumnContext context = ColumnContext.builder().queryable(query).alias(query.getSource().getAlias()).metaDataStore(metaDataStore).column(column).tableArguments(query.getArguments()).build();
    JoinExpressionExtractor visitor = new JoinExpressionExtractor(context);
    List<Reference> references = parser.parse(query.getSource(), column);
    references.forEach(ref -> joinExpressions.addAll(ref.accept(visitor)));
    return joinExpressions;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JoinExpressionExtractor(com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.JoinExpressionExtractor) Reference(com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference) ColumnContext(com.yahoo.elide.datastores.aggregation.metadata.ColumnContext)

Aggregations

ColumnContext (com.yahoo.elide.datastores.aggregation.metadata.ColumnContext)1 JoinExpressionExtractor (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.JoinExpressionExtractor)1 Reference (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference)1 LinkedHashSet (java.util.LinkedHashSet)1