use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class TableArgumentValidatorTest method testTableArgsTypeMismatchForJoinTable.
@Test
public void testTableArgsTypeMismatchForJoinTable() {
Table mainTable = mainTableBuilder.join(Join.builder().name("join").namespace("namespace").to("JoinTable").definition("start {{$$table.args.mainArg1}} end").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
tables.add(Table.builder().name("JoinTable").namespace("namespace").argument(Argument.builder().name("mainArg1").type(Type.TEXT).values(Collections.emptySet()).defaultValue("").build()).build());
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. Argument type mismatch. Join table: 'namespace_JoinTable' has same Argument: 'mainArg1' with type 'TEXT'.", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class TableArgumentValidatorTest method testUndefinedTableArgsInColumnDefinition.
@Test
public void testUndefinedTableArgsInColumnDefinition() {
Table mainTable = mainTableBuilder.dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$table.args.mainArg1}} blah {{$$table.args.mainArg2}} end").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. Argument 'mainArg2' is not defined but found '{{$$table.args.mainArg2}}' in definition of column: 'dim1'.", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class ElideAutoConfiguration method buildQueryEngine.
/**
* Create a QueryEngine instance for aggregation data store to use.
* @param defaultDataSource DataSource for JPA.
* @param dynamicConfig An instance of DynamicConfiguration.
* @param settings Elide configuration settings.
* @param dataSourceConfiguration DataSource Configuration
* @param dbPasswordExtractor Password Extractor Implementation
* @return An instance of a QueryEngine
*/
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "elide.aggregation-store.enabled", havingValue = "true")
@Scope(SCOPE_PROTOTYPE)
public QueryEngine buildQueryEngine(DataSource defaultDataSource, @Autowired(required = false) DynamicConfiguration dynamicConfig, ElideConfigProperties settings, ClassScanner scanner, DataSourceConfiguration dataSourceConfiguration, DBPasswordExtractor dbPasswordExtractor) {
boolean enableMetaDataStore = settings.getAggregationStore().isEnableMetaDataStore();
ConnectionDetails defaultConnectionDetails = new ConnectionDetails(defaultDataSource, SQLDialectFactory.getDialect(settings.getAggregationStore().getDefaultDialect()));
if (isDynamicConfigEnabled(settings)) {
MetaDataStore metaDataStore = new MetaDataStore(scanner, dynamicConfig.getTables(), dynamicConfig.getNamespaceConfigurations(), enableMetaDataStore);
Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
dynamicConfig.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()));
}
MetaDataStore metaDataStore = new MetaDataStore(scanner, enableMetaDataStore);
return new SQLQueryEngine(metaDataStore, (unused) -> defaultConnectionDetails);
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class ElideStandaloneSettings method getDataStore.
/**
* Gets the DataStore for elide.
* @param metaDataStore MetaDataStore object.
* @param aggregationDataStore AggregationDataStore object.
* @param entityManagerFactory EntityManagerFactory object.
* @return DataStore object initialized.
*/
default DataStore getDataStore(MetaDataStore metaDataStore, AggregationDataStore aggregationDataStore, EntityManagerFactory entityManagerFactory) {
List<DataStore> stores = new ArrayList<>();
DataStore jpaDataStore = new JpaDataStore(() -> entityManagerFactory.createEntityManager(), em -> new NonJtaTransaction(em, TXCANCEL, DEFAULT_LOGGER, true, true));
stores.add(jpaDataStore);
if (getAnalyticProperties().enableDynamicModelConfigAPI()) {
stores.add(new ConfigDataStore(getAnalyticProperties().getDynamicConfigPath(), new TemplateConfigValidator(getClassScanner(), getAnalyticProperties().getDynamicConfigPath())));
}
stores.add(metaDataStore);
stores.add(aggregationDataStore);
return new MultiplexManager(stores.toArray(new DataStore[0]));
}
use of com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore in project elide by yahoo.
the class SkipOptimizerTest method init.
@BeforeAll
public static void init() {
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), getClassType(DefaultClassScanner.getInstance().getAnnotatedClasses("example", Include.class)), false);
Set<Optimizer> optimizers = new HashSet<>(Arrays.asList(optimizer));
init(new H2Dialect(), optimizers, metaDataStore);
}
Aggregations