use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class TableArgumentValidator method verifyRequiredTableArgsForJoinTables.
private void verifyRequiredTableArgsForJoinTables() {
table.getJoins().forEach((joinName, sqlJoin) -> {
SQLTable joinTable = metaDataStore.getTable(sqlJoin.getJoinTableType());
joinTable.getArgumentDefinitions().forEach(joinArgDef -> {
String joinArgName = joinArgDef.getName();
if (table.hasArgumentDefinition(joinArgName)) {
if (joinArgDef.getType() != table.getArgumentDefinition(joinArgName).getType()) {
throw new IllegalStateException(String.format(errorMsgPrefix + "Argument type mismatch. Join table: '%s' has same Argument: '%s'" + " with type '%s'.", joinTable.getName(), joinArgName, joinArgDef.getType()));
}
} else if (StringUtils.isBlank(joinArgDef.getDefaultValue().toString())) {
throw new IllegalStateException(String.format(errorMsgPrefix + "Argument '%s' with type '%s' is not defined but is required by join table: %s.", joinArgName, joinArgDef.getType(), joinTable.getName()));
}
});
});
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class AggregationDataStoreTransactionTest method testRequiredColumnFilterArguments.
@Test
public void testRequiredColumnFilterArguments() throws Exception {
Type<PlayerStatsWithRequiredFilter> tableType = ClassType.of(PlayerStatsWithRequiredFilter.class);
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(PlayerStatsWithRequiredFilter.class);
SQLTable table = new SQLTable(new Namespace(DEFAULT_NAMESPACE), tableType, dictionary);
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
FilterExpression where = filterDialect.parse(tableType, new HashSet<>(), "recordedDate>2019-07-12T00:00Z", NO_VERSION);
Query query = Query.builder().column(SQLMetricProjection.builder().name("highScore").alias("highScore").build()).whereFilter(where).source(table).build();
AggregationDataStoreTransaction tx = new AggregationDataStoreTransaction(queryEngine, cache, queryLogger);
Query modifiedQuery = tx.addColumnFilterArguments(table, query, dictionary);
Map<String, Argument> columnArguments = modifiedQuery.getColumnProjection("highScore").getArguments();
assertTrue(columnArguments.containsKey("recordedDate"));
assertEquals(1, columnArguments.size());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class AggregationDataStoreTransactionTest method testRequiredTableFilterArguments.
@Test
public void testRequiredTableFilterArguments() throws Exception {
Type<PlayerStatsWithRequiredFilter> tableType = ClassType.of(PlayerStatsWithRequiredFilter.class);
EntityDictionary dictionary = EntityDictionary.builder().build();
dictionary.bindEntity(PlayerStatsWithRequiredFilter.class);
SQLTable table = new SQLTable(new Namespace(DEFAULT_NAMESPACE), tableType, dictionary);
RSQLFilterDialect filterDialect = RSQLFilterDialect.builder().dictionary(dictionary).build();
FilterExpression where = filterDialect.parse(tableType, new HashSet<>(), "recordedDate>=2019-07-12T00:00Z;recordedDate<2030-07-12T00:00Z", NO_VERSION);
Query query = Query.builder().source(table).whereFilter(where).build();
AggregationDataStoreTransaction tx = new AggregationDataStoreTransaction(queryEngine, cache, queryLogger);
Query modifiedQuery = tx.addTableFilterArguments(table, query, dictionary);
Map<String, Argument> tableArguments = modifiedQuery.getArguments();
assertTrue(tableArguments.containsKey("start"));
assertTrue(tableArguments.containsKey("end"));
assertEquals(2, tableArguments.size());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class DefaultQueryValidatorTest method testValidTableArgument.
@Test
public void testValidTableArgument() {
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> columnArguments = new HashMap<>();
columnArguments.put("format", Argument.builder().name("format").value("lower").build());
Query query = Query.builder().source(source).arguments(tableArguments).metricProjection(source.getMetricProjection("highScore")).dimensionProjection(source.getDimensionProjection("countryName", columnArguments)).build();
validateQueryDoesNotThrow(query);
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable in project elide by yahoo.
the class DefaultQueryValidatorTest method testValidColumnArgument.
@Test
public void testValidColumnArgument() {
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> argumentMap = new HashMap<>();
argumentMap.put("format", Argument.builder().name("format").value("lower").build());
Query query = Query.builder().source(source).arguments(tableArguments).metricProjection(source.getMetricProjection("highScore")).dimensionProjection(source.getDimensionProjection("countryName", "countryName", argumentMap)).build();
validateQueryDoesNotThrow(query);
}
Aggregations