use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore 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.metadata.MetaDataStore 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.metadata.MetaDataStore in project elide by yahoo.
the class SQLUnitTest method init.
public static void init(SQLDialect dialect) {
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), getClassType(DefaultClassScanner.getInstance().getAnnotatedClasses("example", Include.class)), false);
init(dialect, new HashSet<>(), metaDataStore);
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore 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.metadata.MetaDataStore 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