use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class DefaultQueryValidatorTest method testHavingFilterMatchesProjection.
@Test
public void testHavingFilterMatchesProjection() throws ParseException {
SQLTable source = (SQLTable) metaDataStore.getTable("playerStatsView", NO_VERSION);
Map<String, Argument> tableArguments = new HashMap<>();
tableArguments.put("rating", Argument.builder().name("rating").value("Terrible").build());
Map<String, Argument> arguments = new HashMap<>();
arguments.put("format", Argument.builder().name("format").value("lower").build());
FilterExpression havingFilter = filterParser.parseFilterExpression("countryName[format:lower]==usa", playerStatsViewType, false);
Query query = Query.builder().source(source).arguments(tableArguments).dimensionProjection(source.getDimensionProjection("countryName", arguments)).havingFilter(havingFilter).build();
validateQueryDoesNotThrow(query);
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class DefaultQueryValidatorTest method testHavingFilterMismatchedWithProjection.
@Test
public void testHavingFilterMismatchedWithProjection() throws ParseException {
SQLTable source = (SQLTable) metaDataStore.getTable("playerStatsView", NO_VERSION);
FilterExpression havingFilter = filterParser.parseFilterExpression("countryName[format:upper]==USA", playerStatsViewType, false);
Query query = Query.builder().source(source).dimensionProjection(source.getDimensionProjection("countryName")).havingFilter(havingFilter).build();
validateQuery(query, "Invalid operation: Post aggregation filtering on 'countryName' requires the field to be projected in the response with matching arguments");
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class DefaultQueryValidatorTest method testMissingRequiredParameterInFilter.
@Test
public void testMissingRequiredParameterInFilter() throws ParseException {
SQLTable source = (SQLTable) metaDataStore.getTable("playerStatsView", NO_VERSION);
FilterExpression havingFilter = filterParser.parseFilterExpression("countryName==usa", playerStatsViewType, false);
Query query = Query.builder().source(source).dimensionProjection(source.getDimensionProjection("countryName")).havingFilter(havingFilter).build();
validateQuery(query, "Invalid operation: Argument 'format' for column 'countryName' is required");
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class SplitFilterExpressionVisitorTest method setupEntityDictionary.
@BeforeAll
public static void setupEntityDictionary() {
EntityDictionary entityDictionary = EntityDictionary.builder().build();
entityDictionary.bindEntity(PlayerStats.class);
entityDictionary.bindEntity(Country.class);
entityDictionary.bindEntity(SubCountry.class);
entityDictionary.bindEntity(Player.class);
Namespace namespace = new Namespace(DEFAULT_NAMESPACE);
Table table = new SQLTable(namespace, ClassType.of(PlayerStats.class), entityDictionary);
splitFilterExpressionVisitor = new SplitFilterExpressionVisitor(table);
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class ReferenceExtractor method visitJoinReference.
@Override
public Set<T> visitJoinReference(JoinReference reference) {
if (referenceType.equals(JoinReference.class)) {
references.add((T) reference);
}
JoinPath path = reference.getPath();
int pathLimit = (mode == Mode.SAME_QUERY) ? 1 : path.getPathElements().size() - 1;
for (int idx = 0; idx < pathLimit; idx++) {
Path.PathElement pathElement = path.getPathElements().get(idx);
String fieldName = pathElement.getFieldName();
Type<?> parentClass = pathElement.getType();
SQLTable table = metaDataStore.getTable(parentClass);
SQLJoin join = table.getJoin(fieldName);
if (visitedJoins.contains(join)) {
continue;
}
visitedJoins.add(join);
parser.parse(table, join.getJoinExpression()).stream().forEach(ref -> ref.accept(this));
}
if (mode != Mode.SAME_QUERY) {
return reference.getReference().accept(this);
}
return references;
}
Aggregations