Search in sources :

Example 11 with DefaultQueryPlanMerger

use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.

the class ColumnArgumentValidatorTest method testColumnArgsTypeMismatchForDepenedentColumn.

@Test
public void testColumnArgsTypeMismatchForDepenedentColumn() {
    Table mainTable = mainTableBuilder.dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} blah {{dim2}} end").argument(mainArg1).build()).dimension(Dimension.builder().name("dim2").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("{{$dim2}} blah {{$$column.args.mainArg1}} end").argument(Argument.builder().name("mainArg1").type(Type.TEXT).values(Collections.emptySet()).defaultValue("").build()).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 column arguments for column: dim1 in table: namespace_MainTable. Argument type mismatch. Dependent Column: 'dim2' in table: 'namespace_MainTable'" + " 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 12 with DefaultQueryPlanMerger

use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.

the class ColumnArgumentValidatorTest method testUndefinedColumnArgsInJoinExpression.

@Test
public void testUndefinedColumnArgsInJoinExpression() {
    Table mainTable = mainTableBuilder.join(Join.builder().name("join").namespace("namespace").to("JoinTable").definition("start {{$$column.args.mainArg2}} blah").build()).dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} blah {{join.$joinCol}} end").argument(mainArg1).build()).build();
    Set<Table> tables = new HashSet<>();
    tables.add(mainTable);
    tables.add(joinTableBuilder.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 column arguments for column: dim1 in table: namespace_MainTable. Argument 'mainArg2' is not defined but found '{{$$column.args.mainArg2}}'.", 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 13 with DefaultQueryPlanMerger

use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.

the class ColumnArgumentValidatorTest method testRequiredColumnArgsInFilterTemplate.

@Test
public void testRequiredColumnArgsInFilterTemplate() {
    Table mainTable = mainTableBuilder.dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} end").filterTemplate("dim1=={{mainArg1}}").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);
    assertDoesNotThrow(() -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
}
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 14 with DefaultQueryPlanMerger

use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.

the class ColumnArgumentValidatorTest method testMissingRequiredColumnArgsForDepenedentColumnCase2.

@Test
public void testMissingRequiredColumnArgsForDepenedentColumnCase2() {
    Table mainTable = mainTableBuilder.join(Join.builder().name("join").namespace("namespace").to("JoinTable").definition("start {{$$column.args.mainArg1}} blah {{join.$joinCol}} end").build()).dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} blah {{join.joinCol}} end").argument(mainArg1).build()).build();
    Table joinTable = joinTableBuilder.dimension(Dimension.builder().name("joinCol").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("{{$joinCol}} blah {{$$column.args.joinArg1}} end").argument(Argument.builder().name("joinArg1").type(Type.INTEGER).values(Collections.emptySet()).defaultValue("").build()).build()).build();
    Set<Table> tables = new HashSet<>();
    tables.add(mainTable);
    tables.add(joinTable);
    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 column arguments for column: dim1 in table: namespace_MainTable. Argument 'joinArg1' with type 'INTEGER' is not defined but is" + " required for Dependent Column: 'joinCol' in table: 'namespace_JoinTable'.", e.getMessage());
    // If 'join.joinCol' is invoked using SQL helper, must not complain.
    mainTable = mainTableBuilder.join(Join.builder().name("join").namespace("namespace").to("JoinTable").definition("start {{$$column.args.mainArg1}} blah {{join.$joinCol}} end").build()).dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} blah {{sql from='join' column='joinCol[joinArg1:123]'}} end").argument(mainArg1).build()).build();
    tables = new HashSet<>();
    tables.add(mainTable);
    tables.add(joinTable);
    MetaDataStore metaDataStore1 = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
    assertDoesNotThrow(() -> new SQLQueryEngine(metaDataStore1, connectionLookup, optimizers, merger, queryValidator));
}
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 15 with DefaultQueryPlanMerger

use of com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger in project elide by yahoo.

the class ColumnArgumentValidatorTest method testMissingRequiredColumnArgs.

@Test
public void testMissingRequiredColumnArgs() {
    Table mainTable = mainTableBuilder.dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$column.args.mainArg1}} 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 column arguments for column: dim1 in table: namespace_MainTable. Argument 'mainArg1' is not defined but found '{{$$column.args.mainArg1}}'.", 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)21 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)21 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)21 HashSet (java.util.HashSet)20 QueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger)16 Table (com.yahoo.elide.modelconfig.model.Table)16 Test (org.junit.jupiter.api.Test)16 DefaultQueryValidator (com.yahoo.elide.datastores.aggregation.DefaultQueryValidator)5 DefaultClassScanner (com.yahoo.elide.core.utils.DefaultClassScanner)4 ConnectionDetails (com.yahoo.elide.datastores.aggregation.queryengines.sql.ConnectionDetails)4 SQLDialectFactory (com.yahoo.elide.datastores.aggregation.queryengines.sql.dialects.SQLDialectFactory)4 DataStore (com.yahoo.elide.core.datastore.DataStore)3 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)3 RSQLFilterDialect (com.yahoo.elide.core.filter.dialect.RSQLFilterDialect)3 ClassType (com.yahoo.elide.core.type.ClassType)3 Type (com.yahoo.elide.core.type.Type)3 ClassScanner (com.yahoo.elide.core.utils.ClassScanner)3 CoerceUtil (com.yahoo.elide.core.utils.coerce.CoerceUtil)3 AggregationDataStore (com.yahoo.elide.datastores.aggregation.AggregationDataStore)3 QueryEngine (com.yahoo.elide.datastores.aggregation.QueryEngine)3