Search in sources :

Example 1 with ConnectionDetails

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails in project elide by yahoo.

the class SQLUnitTest method init.

public static void init(SQLDialect sqlDialect, Set<Optimizer> optimizers, MetaDataStore metaDataStore) {
    Properties properties = new Properties();
    properties.put("driverClassName", "org.h2.Driver");
    String jdbcUrl = "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1" + ";NON_KEYWORDS=VALUE,USER" + ";DATABASE_TO_UPPER=FALSE" + getCompatabilityMode(sqlDialect.getDialectType());
    properties.put("jdbcUrl", jdbcUrl);
    HikariConfig config = new HikariConfig(properties);
    DataSource dataSource = new HikariDataSource(config);
    try (Connection h2Conn = dataSource.getConnection()) {
        h2Conn.createStatement().execute("RUNSCRIPT FROM 'classpath:prepare_tables.sql'");
    } catch (SQLException e) {
        ((HikariDataSource) dataSource).close();
        throw new IllegalStateException(e);
    }
    SQLUnitTest.metaDataStore = metaDataStore;
    dictionary = EntityDictionary.builder().build();
    dictionary.bindEntity(PlayerStatsWithView.class);
    dictionary.bindEntity(PlayerStatsView.class);
    dictionary.bindEntity(PlayerStats.class);
    dictionary.bindEntity(Country.class);
    dictionary.bindEntity(SubCountry.class);
    dictionary.bindEntity(Player.class);
    dictionary.bindEntity(CountryView.class);
    dictionary.bindEntity(CountryViewNested.class);
    dictionary.bindEntity(Continent.class);
    dictionary.bindEntity(GameRevenue.class);
    filterParser = RSQLFilterDialect.builder().dictionary(dictionary).build();
    // Manually register the serdes because we are not running a complete Elide service.
    CoerceUtil.register(Day.class, new Day.DaySerde());
    CoerceUtil.register(Hour.class, new Hour.HourSerde());
    CoerceUtil.register(ISOWeek.class, new ISOWeek.ISOWeekSerde());
    CoerceUtil.register(Minute.class, new Minute.MinuteSerde());
    CoerceUtil.register(Month.class, new Month.MonthSerde());
    CoerceUtil.register(Quarter.class, new Quarter.QuarterSerde());
    CoerceUtil.register(Second.class, new Second.SecondSerde());
    CoerceUtil.register(Week.class, new Week.WeekSerde());
    CoerceUtil.register(Year.class, new Year.YearSerde());
    metaDataStore.populateEntityDictionary(dictionary);
    // Need to provide details for connections used by all available models.
    Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
    connectionDetailsMap.put("mycon", new ConnectionDetails(dataSource, sqlDialect));
    connectionDetailsMap.put("SalesDBConnection", new ConnectionDetails(DUMMY_DATASOURCE, sqlDialect));
    Function<String, ConnectionDetails> connectionLookup = (name) -> connectionDetailsMap.getOrDefault(name, new ConnectionDetails(dataSource, sqlDialect));
    engine = new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
    playerStatsTable = (SQLTable) metaDataStore.getTable("playerStats", NO_VERSION);
    videoGameTable = (SQLTable) metaDataStore.getTable("videoGame", NO_VERSION);
    playerStatsViewTable = (SQLTable) metaDataStore.getTable("playerStatsView", NO_VERSION);
    playerStatsViewTableArgs = new HashMap<>();
    playerStatsViewTableArgs.put("rating", Argument.builder().name("overallRating").value("Great").build());
    playerStatsViewTableArgs.put("minScore", Argument.builder().name("minScore").value("0").build());
}
Also used : Quarter(com.yahoo.elide.datastores.aggregation.timegrains.Quarter) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) BeforeEach(org.junit.jupiter.api.BeforeEach) FilterPredicate(com.yahoo.elide.core.filter.predicates.FilterPredicate) Arrays(java.util.Arrays) Path(com.yahoo.elide.core.Path) Connection(java.sql.Connection) Provider(javax.inject.Provider) Include(com.yahoo.elide.annotation.Include) ParseException(com.yahoo.elide.core.filter.dialect.ParseException) SortingImpl(com.yahoo.elide.core.sort.SortingImpl) ClassType(com.yahoo.elide.core.type.ClassType) Argument(com.yahoo.elide.core.request.Argument) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) Continent(example.dimensions.Continent) ISOWeek(com.yahoo.elide.datastores.aggregation.timegrains.ISOWeek) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) Map(java.util.Map) MetricProjection(com.yahoo.elide.datastores.aggregation.query.MetricProjection) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) SQLDialectFactory(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory) STRING_TYPE(com.yahoo.elide.core.type.ClassType.STRING_TYPE) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) Set(java.util.Set) CoerceUtil(com.yahoo.elide.core.utils.coerce.CoerceUtil) Collectors(java.util.stream.Collectors) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) PlayerStats(example.PlayerStats) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) Query(com.yahoo.elide.datastores.aggregation.query.Query) List(java.util.List) Hour(com.yahoo.elide.datastores.aggregation.timegrains.Hour) ImmutablePagination(com.yahoo.elide.datastores.aggregation.query.ImmutablePagination) TypeHelper.getClassType(com.yahoo.elide.core.utils.TypeHelper.getClassType) HikariDataSource(com.zaxxer.hikari.HikariDataSource) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) Optimizer(com.yahoo.elide.datastores.aggregation.query.Optimizer) Pattern(java.util.regex.Pattern) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) Attribute(com.yahoo.elide.core.request.Attribute) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) CountryViewNested(example.dimensions.CountryViewNested) Day(com.yahoo.elide.datastores.aggregation.timegrains.Day) Quarter(com.yahoo.elide.datastores.aggregation.timegrains.Quarter) SubCountry(example.dimensions.SubCountry) Second(com.yahoo.elide.datastores.aggregation.timegrains.Second) Week(com.yahoo.elide.datastores.aggregation.timegrains.Week) HashMap(java.util.HashMap) TimeGrain(com.yahoo.elide.datastores.aggregation.metadata.enums.TimeGrain) CountryView(example.dimensions.CountryView) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SQLException(java.sql.SQLException) SQLDialect(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialect) Month(com.yahoo.elide.datastores.aggregation.timegrains.Month) DataSource(javax.sql.DataSource) NO_VERSION(com.yahoo.elide.core.dictionary.EntityDictionary.NO_VERSION) StreamSupport(java.util.stream.StreamSupport) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression) LinkedHashSet(java.util.LinkedHashSet) PlayerStatsView(example.PlayerStatsView) QueryEngine(com.yahoo.elide.datastores.aggregation.QueryEngine) DimensionProjection(com.yahoo.elide.datastores.aggregation.query.DimensionProjection) Properties(java.util.Properties) Sorting(com.yahoo.elide.core.request.Sorting) GameRevenue(example.GameRevenue) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) Player(example.Player) HikariConfig(com.zaxxer.hikari.HikariConfig) AfterEach(org.junit.jupiter.api.AfterEach) Country(example.dimensions.Country) TreeMap(java.util.TreeMap) SQLTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable) Type(com.yahoo.elide.core.type.Type) Operator(com.yahoo.elide.core.filter.Operator) PlayerStatsWithView(example.PlayerStatsWithView) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) HikariDataSource(com.zaxxer.hikari.HikariDataSource) SQLException(java.sql.SQLException) HashMap(java.util.HashMap) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) Properties(java.util.Properties) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) Month(com.yahoo.elide.datastores.aggregation.timegrains.Month) Minute(com.yahoo.elide.datastores.aggregation.timegrains.Minute) Hour(com.yahoo.elide.datastores.aggregation.timegrains.Hour) Connection(java.sql.Connection) HikariConfig(com.zaxxer.hikari.HikariConfig) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource) ISOWeek(com.yahoo.elide.datastores.aggregation.timegrains.ISOWeek) Second(com.yahoo.elide.datastores.aggregation.timegrains.Second) Year(com.yahoo.elide.datastores.aggregation.timegrains.Year) Day(com.yahoo.elide.datastores.aggregation.timegrains.Day) ISOWeek(com.yahoo.elide.datastores.aggregation.timegrains.ISOWeek) Week(com.yahoo.elide.datastores.aggregation.timegrains.Week)

Example 2 with ConnectionDetails

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails in project elide by yahoo.

the class AggregationDataStoreIntegrationTest method createHarness.

@Override
protected DataStoreTestHarness createHarness() {
    HikariConfig config = new HikariConfig(File.separator + "jpah2db.properties");
    DataSource defaultDataSource = new HikariDataSource(config);
    SQLDialect defaultDialect = SQLDialectFactory.getDefaultDialect();
    ConnectionDetails defaultConnectionDetails = new ConnectionDetails(defaultDataSource, defaultDialect);
    Properties prop = new Properties();
    prop.put("javax.persistence.jdbc.driver", config.getDriverClassName());
    prop.put("javax.persistence.jdbc.url", config.getJdbcUrl());
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("aggregationStore", prop);
    Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
    // Add an entry for "mycon" connection which is not from hjson
    connectionDetailsMap.put("mycon", defaultConnectionDetails);
    // Add connection details fetched from hjson
    VALIDATOR.getElideSQLDBConfig().getDbconfigs().forEach(dbConfig -> connectionDetailsMap.put(dbConfig.getName(), new ConnectionDetails(getDataSource(dbConfig, getDBPasswordExtractor()), SQLDialectFactory.getDialect(dbConfig.getDialect()))));
    return new AggregationDataStoreTestHarness(emf, defaultConnectionDetails, connectionDetailsMap, VALIDATOR);
}
Also used : AggregationDataStoreTestHarness(com.yahoo.elide.datastores.aggregation.framework.AggregationDataStoreTestHarness) HikariDataSource(com.zaxxer.hikari.HikariDataSource) HashMap(java.util.HashMap) SQLDialect(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialect) EntityManagerFactory(javax.persistence.EntityManagerFactory) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) HikariConfig(com.zaxxer.hikari.HikariConfig) Properties(java.util.Properties) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource)

Example 3 with ConnectionDetails

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails in project elide by yahoo.

the class MetaDataStoreIntegrationTest method createHarness.

@Override
protected DataStoreTestHarness createHarness() {
    HikariConfig config = new HikariConfig(File.separator + "jpah2db.properties");
    DataSource defaultDataSource = new HikariDataSource(config);
    SQLDialect defaultDialect = SQLDialectFactory.getDefaultDialect();
    ConnectionDetails defaultConnectionDetails = new ConnectionDetails(defaultDataSource, defaultDialect);
    Properties prop = new Properties();
    prop.put("javax.persistence.jdbc.driver", config.getDriverClassName());
    prop.put("javax.persistence.jdbc.url", config.getJdbcUrl());
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("aggregationStore", prop);
    Map<String, ConnectionDetails> connectionDetailsMap = new HashMap<>();
    // Add an entry for "mycon" connection which is not from hjson
    connectionDetailsMap.put("mycon", defaultConnectionDetails);
    // Add connection details fetched from hjson
    VALIDATOR.getElideSQLDBConfig().getDbconfigs().forEach(dbConfig -> connectionDetailsMap.put(dbConfig.getName(), new ConnectionDetails(getDataSource(dbConfig, getDBPasswordExtractor()), SQLDialectFactory.getDialect(dbConfig.getDialect()))));
    return new AggregationDataStoreTestHarness(emf, defaultConnectionDetails, connectionDetailsMap, VALIDATOR);
}
Also used : AggregationDataStoreTestHarness(com.yahoo.elide.datastores.aggregation.framework.AggregationDataStoreTestHarness) HikariDataSource(com.zaxxer.hikari.HikariDataSource) HashMap(java.util.HashMap) SQLDialect(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialect) EntityManagerFactory(javax.persistence.EntityManagerFactory) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) HikariConfig(com.zaxxer.hikari.HikariConfig) Properties(java.util.Properties) DataSource(javax.sql.DataSource) HikariDataSource(com.zaxxer.hikari.HikariDataSource) AggregationDataStoreIntegrationTest.getDataSource(com.yahoo.elide.datastores.aggregation.integration.AggregationDataStoreIntegrationTest.getDataSource)

Example 4 with ConnectionDetails

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails 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);
}
Also used : Arrays(java.util.Arrays) DynamicConfiguration(com.yahoo.elide.modelconfig.DynamicConfiguration) Autowired(org.springframework.beans.factory.annotation.Autowired) Role(com.yahoo.elide.core.security.checks.prefab.Role) StringUtils(org.apache.commons.lang3.StringUtils) ClassType(com.yahoo.elide.core.type.ClassType) DataSourceConfiguration(com.yahoo.elide.datastores.aggregation.queryengines.sql.DataSourceConfiguration) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) RSQLFilterDialect(com.yahoo.elide.core.filter.dialect.RSQLFilterDialect) DefaultJSONApiLinks(com.yahoo.elide.jsonapi.links.DefaultJSONApiLinks) ClassScanner(com.yahoo.elide.core.utils.ClassScanner) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Map(java.util.Map) JsonApiMapper(com.yahoo.elide.jsonapi.JsonApiMapper) AggregationDataStore(com.yahoo.elide.datastores.aggregation.AggregationDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) TableExport(com.yahoo.elide.async.models.TableExport) TemplateConfigValidator(com.yahoo.elide.datastores.aggregation.validator.TemplateConfigValidator) Elide(com.yahoo.elide.Elide) SQLDialectFactory(com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator) Cache(com.yahoo.elide.datastores.aggregation.cache.Cache) DefaultClassScanner(com.yahoo.elide.core.utils.DefaultClassScanner) TimeZone(java.util.TimeZone) AsyncQuery(com.yahoo.elide.async.models.AsyncQuery) CaffeineCache(com.yahoo.elide.datastores.aggregation.cache.CaffeineCache) Set(java.util.Set) CoerceUtil(com.yahoo.elide.core.utils.coerce.CoerceUtil) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) QueryRunners(com.yahoo.elide.graphql.QueryRunners) Info(io.swagger.models.Info) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) EntityManagerFactory(javax.persistence.EntityManagerFactory) DataStore(com.yahoo.elide.core.datastore.DataStore) SwaggerBuilder(com.yahoo.elide.swagger.SwaggerBuilder) Optional(java.util.Optional) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) Slf4jLogger(com.yahoo.elide.core.audit.Slf4jLogger) QueryLogger(com.yahoo.elide.datastores.aggregation.core.QueryLogger) ErrorMapper(com.yahoo.elide.core.exceptions.ErrorMapper) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) TransactionRegistry(com.yahoo.elide.core.TransactionRegistry) SwaggerController(com.yahoo.elide.spring.controllers.SwaggerController) ElideSettingsBuilder(com.yahoo.elide.ElideSettingsBuilder) Session(org.hibernate.Session) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory) HashMap(java.util.HashMap) MultiplexManager(com.yahoo.elide.datastores.multiplex.MultiplexManager) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ArrayList(java.util.ArrayList) NonJtaTransaction(com.yahoo.elide.datastores.jpa.transaction.NonJtaTransaction) HashSet(java.util.HashSet) DBPasswordExtractor(com.yahoo.elide.modelconfig.DBPasswordExtractor) ConditionalOnExpression(org.springframework.boot.autoconfigure.condition.ConditionalOnExpression) Injector(com.yahoo.elide.core.dictionary.Injector) Qualifier(org.springframework.beans.factory.annotation.Qualifier) DataSource(javax.sql.DataSource) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) CaffeineCacheMetrics(io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics) JpaDataStore(com.yahoo.elide.datastores.jpa.JpaDataStore) Slf4jQueryLogger(com.yahoo.elide.datastores.aggregation.core.Slf4jQueryLogger) QueryEngine(com.yahoo.elide.datastores.aggregation.QueryEngine) DEFAULT_LOGGER(com.yahoo.elide.datastores.jpa.JpaDataStore.DEFAULT_LOGGER) SCOPE_PROTOTYPE(org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE) Check(com.yahoo.elide.core.security.checks.Check) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) RefreshableElide(com.yahoo.elide.RefreshableElide) IOException(java.io.IOException) ConfigChecks(com.yahoo.elide.modelconfig.store.models.ConfigChecks) EntityManager(javax.persistence.EntityManager) ConfigDataStore(com.yahoo.elide.modelconfig.store.ConfigDataStore) Consumer(java.util.function.Consumer) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Type(com.yahoo.elide.core.type.Type) Bean(org.springframework.context.annotation.Bean) SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) HashMap(java.util.HashMap) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) AggregateBeforeJoinOptimizer(com.yahoo.elide.datastores.aggregation.queryengines.sql.query.AggregateBeforeJoinOptimizer) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Scope(org.springframework.context.annotation.Scope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 5 with ConnectionDetails

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails 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()));
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) Player(example.Player) CountryViewNested(example.dimensions.CountryViewNested) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) ConnectionDetails(com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails) PlayerStats(example.PlayerStats) SubCountry(example.dimensions.SubCountry) DataSource(javax.sql.DataSource) ClassType(com.yahoo.elide.core.type.ClassType) Type(com.yahoo.elide.core.type.Type) PlayerStatsWithView(example.PlayerStatsWithView) PlayerRanking(example.PlayerRanking) SubCountry(example.dimensions.SubCountry) Country(example.dimensions.Country) CountryView(example.dimensions.CountryView) EntityDictionary(com.yahoo.elide.core.dictionary.EntityDictionary) HashSet(java.util.HashSet) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

ConnectionDetails (com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails)6 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)4 ClassType (com.yahoo.elide.core.type.ClassType)4 Type (com.yahoo.elide.core.type.Type)4 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)4 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 DataSource (javax.sql.DataSource)4 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)3 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)3 CoerceUtil (com.yahoo.elide.core.utils.coerce.CoerceUtil)3 DefaultQueryValidator (com.yahoo.elide.datastores.aggregation.DefaultQueryValidator)3 QueryEngine (com.yahoo.elide.datastores.aggregation.QueryEngine)3 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)3 SQLDialect (com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialect)3 SQLDialectFactory (com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory)3 HikariConfig (com.zaxxer.hikari.HikariConfig)3 HikariDataSource (com.zaxxer.hikari.HikariDataSource)3 Properties (java.util.Properties)3