use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TableArgumentValidatorTest method testArgumentValues.
@Test
public void testArgumentValues() {
Table mainTable = mainTableBuilder.argument(Argument.builder().name("testArg").type(Type.INTEGER).values(Sets.newHashSet("1", "2.5")).defaultValue("").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Value: '2.5' for Argument 'testArg' with Type 'INTEGER' is invalid.", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class LoopCountryB method testCrossClassReferenceLoop.
@Test
public void testCrossClassReferenceLoop() {
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), getClassType(Sets.newLinkedHashSet(Arrays.asList(LoopCountryA.class, LoopCountryB.class))), true);
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new SQLQueryEngine(metaDataStore, (unused) -> DUMMY_CONNECTION));
String exception1 = "Formula reference loop found: loopCountryA.inUsa->loopCountryB.inUsa->loopCountryA.inUsa";
String exception2 = "Formula reference loop found: loopCountryB.inUsa->loopCountryA.inUsa->loopCountryB.inUsa";
assertTrue(exception1.equals(exception.getMessage()) || exception2.equals(exception.getMessage()));
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class MetricFormulaTest method testReferenceLoop.
@Test
public void testReferenceLoop() {
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), Sets.newHashSet(ClassType.of(MeasureLoop.class)), true);
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> new SQLQueryEngine(metaDataStore, (unused) -> DUMMY_CONNECTION));
assertTrue(exception.getMessage().startsWith("Formula reference loop found:"));
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class JoinPathTest method init.
@BeforeAll
public static void init() {
Set<Type<?>> models = new HashSet<>();
models.add(ClassType.of(PlayerStats.class));
models.add(ClassType.of(CountryView.class));
models.add(ClassType.of(Country.class));
models.add(ClassType.of(SubCountry.class));
models.add(ClassType.of(Player.class));
models.add(ClassType.of(PlayerRanking.class));
models.add(ClassType.of(CountryViewNested.class));
models.add(ClassType.of(PlayerStatsWithView.class));
EntityDictionary dictionary = EntityDictionary.builder().build();
models.stream().forEach(dictionary::bindEntity);
store = new MetaDataStore(dictionary.getScanner(), models, true);
store.populateEntityDictionary(dictionary);
DataSource mockDataSource = mock(DataSource.class);
// The query engine populates the metadata store with actual tables.
new SQLQueryEngine(store, (unused) -> new ConnectionDetails(mockDataSource, SQLDialectFactory.getDefaultDialect()));
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class ElideStandaloneSettings method getQueryEngine.
/**
* Gets the QueryEngine for elide.
* @param metaDataStore MetaDataStore object.
* @param defaultConnectionDetails default DataSource Object and SQLDialect Object.
* @param dynamicConfiguration Optional dynamic config.
* @param dataSourceConfiguration DataSource Configuration.
* @param dbPasswordExtractor Password Extractor Implementation.
* @return QueryEngine object initialized.
*/
default QueryEngine getQueryEngine(MetaDataStore metaDataStore, ConnectionDetails defaultConnectionDetails, Optional<DynamicConfiguration> dynamicConfiguration, DataSourceConfiguration dataSourceConfiguration, DBPasswordExtractor dbPasswordExtractor) {
if (dynamicConfiguration.isPresent()) {
Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
dynamicConfiguration.get().getDatabaseConfigurations().forEach(dbConfig -> connectionDetailsMap.put(dbConfig.getName(), new ConnectionDetails(dataSourceConfiguration.getDataSource(dbConfig, dbPasswordExtractor), SQLDialectFactory.getDialect(dbConfig.getDialect()))));
Function<String, ConnectionDetails> connectionDetailsLookup = (name) -> {
if (StringUtils.isEmpty(name)) {
return defaultConnectionDetails;
}
return Optional.ofNullable(connectionDetailsMap.get(name)).orElseThrow(() -> new IllegalStateException("ConnectionDetails undefined for connection: " + name));
};
return new SQLQueryEngine(metaDataStore, connectionDetailsLookup, new HashSet<>(Arrays.asList(new AggregateBeforeJoinOptimizer(metaDataStore))), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
}
return new SQLQueryEngine(metaDataStore, (unused) -> defaultConnectionDetails);
}
Aggregations