Search in sources :

Example 6 with SQLQueryEngine

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

the class TemplateConfigValidator method rebuildMetaDataStore.

// Rebuilds the MetaDataStore for each validation so that we can validate templates.
MetaDataStore rebuildMetaDataStore(Map<String, ConfigFile> resourceMap) {
    DynamicConfigValidator validator = new DynamicConfigValidator(scanner, configRoot);
    validator.validate(resourceMap);
    MetaDataStore metaDataStore = new MetaDataStore(scanner, validator.getTables(), validator.getNamespaceConfigurations(), false);
    // Populates the metadata store with SQL tables.
    new SQLQueryEngine(metaDataStore, (unused) -> null, new HashSet<>(), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
    return metaDataStore;
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryValidator(com.yahoo.elide.datastores.aggregation.DefaultQueryValidator) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) DynamicConfigValidator(com.yahoo.elide.modelconfig.validator.DynamicConfigValidator)

Example 7 with SQLQueryEngine

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

the class TableArgumentValidatorTest method testUndefinedTableArgsInTableSql.

@Test
public void testUndefinedTableArgsInTableSql() {
    Table mainTable = mainTableBuilder.sql("SELECT something {{$$table.args.mainArg1}} blah {{$$table.args.mainArg2}} FROM").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 table's sql.", e.getMessage());
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) QueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger) Table(com.yahoo.elide.modelconfig.model.Table) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 8 with SQLQueryEngine

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

the class TableArgumentValidatorTest method testDefaultValueIsInValues.

@Test
public void testDefaultValueIsInValues() {
    Table mainTable = mainTableBuilder.argument(Argument.builder().name("testArg").type(Type.INTEGER).values(Sets.newHashSet("1", "2")).defaultValue("5").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. Default Value: '5' for Argument 'testArg' with Type 'INTEGER' must match one of these values: [1, 2].", e.getMessage());
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) QueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger) Table(com.yahoo.elide.modelconfig.model.Table) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 9 with SQLQueryEngine

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine 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());
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) QueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger) Table(com.yahoo.elide.modelconfig.model.Table) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 10 with SQLQueryEngine

use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine 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());
}
Also used : SQLQueryEngine(com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) QueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger) Table(com.yahoo.elide.modelconfig.model.Table) MetaDataStore(com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore) DefaultQueryPlanMerger(com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)25 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)25 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)21 HashSet (java.util.HashSet)21 Test (org.junit.jupiter.api.Test)19 QueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger)16 Table (com.yahoo.elide.modelconfig.model.Table)16 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)7 ConnectionDetails (com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails)7 SQLDialectFactory (com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory)6 Arrays (java.util.Arrays)6 ClassType (com.yahoo.elide.core.type.ClassType)5 DefaultQueryValidator (com.yahoo.elide.datastores.aggregation.DefaultQueryValidator)5 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)4 Type (com.yahoo.elide.core.type.Type)4 Include (com.yahoo.elide.annotation.Include)3 DataStore (com.yahoo.elide.core.datastore.DataStore)3 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)3 ClassScanner (com.yahoo.elide.core.utils.ClassScanner)3 TypeHelper.getClassType (com.yahoo.elide.core.utils.TypeHelper.getClassType)3