Search in sources :

Example 36 with Table

use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.

the class TableArgumentValidatorTest method testArgumentValues.

@Test
public void testArgumentValues() {
    Table mainTable = mainTableBuilder.argument(Argument.builder().name("testArg").type(Type.INTEGER).values(Sets.newHashSet("1", "2.5")).defaultValue("").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. Value: '2.5' for Argument 'testArg' with Type 'INTEGER' is invalid.", 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 37 with Table

use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.

the class TableTypeTest method testTableSQL.

@Test
void testTableSQL() throws Exception {
    Table testTable = Table.builder().sql("SELECT * FROM FOO").name("Table").dbConnectionName("dbConn").build();
    TableType testType = new TableType(testTable);
    FromSubquery fromSubquery = (FromSubquery) testType.getAnnotation(FromSubquery.class);
    assertEquals("SELECT * FROM FOO", fromSubquery.sql());
    assertEquals("dbConn", fromSubquery.dbConnectionName());
}
Also used : Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) FromSubquery(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromSubquery) Test(org.junit.jupiter.api.Test)

Example 38 with Table

use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.

the class TableTypeTest method testGetAndSetField.

@Test
void testGetAndSetField() throws Exception {
    Table testTable = Table.builder().dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).build()).build();
    TableType testType = new TableType(testTable);
    DynamicModelInstance testTypeInstance = testType.newInstance();
    Field field = testType.getDeclaredField("dim1");
    field.set(testTypeInstance, true);
    assertTrue((Boolean) field.get(testTypeInstance));
    field.set(testTypeInstance, false);
    assertFalse((Boolean) field.get(testTypeInstance));
}
Also used : Field(com.yahoo.elide.core.type.Field) Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) Test(org.junit.jupiter.api.Test)

Example 39 with Table

use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.

the class TableTypeTest method testIdField.

@Test
void testIdField() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").build();
    TableType testType = new TableType(testTable);
    assertTrue(testType.getFields().length == 1);
    Field field = testType.getDeclaredField("id");
    assertNotNull(field);
    Id id = field.getAnnotation(Id.class);
    assertNotNull(id);
}
Also used : Field(com.yahoo.elide.core.type.Field) Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) Id(javax.persistence.Id) Test(org.junit.jupiter.api.Test)

Example 40 with Table

use of com.yahoo.elide.modelconfig.model.Table in project elide by yahoo.

the class TableTypeTest method testHiddenTableAnnotations.

@Test
void testHiddenTableAnnotations() throws Exception {
    Table testTable = Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").hidden(true).schema("db1").category("category1").build();
    TableType testType = new TableType(testTable);
    Include include = (Include) testType.getAnnotation(Include.class);
    assertNotNull(include);
    TableMeta tableMeta = (TableMeta) testType.getAnnotation(TableMeta.class);
    assertNotNull(tableMeta);
    assertTrue(tableMeta.isHidden());
}
Also used : Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) Include(com.yahoo.elide.annotation.Include) TableMeta(com.yahoo.elide.datastores.aggregation.annotation.TableMeta) Test(org.junit.jupiter.api.Test)

Aggregations

Table (com.yahoo.elide.modelconfig.model.Table)43 Test (org.junit.jupiter.api.Test)39 HashSet (java.util.HashSet)23 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)17 DefaultQueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.DefaultQueryPlanMerger)16 QueryPlanMerger (com.yahoo.elide.datastores.aggregation.query.QueryPlanMerger)16 SQLQueryEngine (com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine)16 FromTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable)16 Field (com.yahoo.elide.core.type.Field)12 ColumnMeta (com.yahoo.elide.datastores.aggregation.annotation.ColumnMeta)6 ReadPermission (com.yahoo.elide.annotation.ReadPermission)4 BadRequestException (com.yahoo.elide.core.exceptions.BadRequestException)3 Include (com.yahoo.elide.annotation.Include)2 DimensionFormula (com.yahoo.elide.datastores.aggregation.annotation.DimensionFormula)2 MetricFormula (com.yahoo.elide.datastores.aggregation.annotation.MetricFormula)2 TableMeta (com.yahoo.elide.datastores.aggregation.annotation.TableMeta)2 Temporal (com.yahoo.elide.datastores.aggregation.annotation.Temporal)2 NamespacePackage (com.yahoo.elide.datastores.aggregation.dynamic.NamespacePackage)1 TableType (com.yahoo.elide.datastores.aggregation.dynamic.TableType)1 SQLUnitTest (com.yahoo.elide.datastores.aggregation.framework.SQLUnitTest)1