Search in sources :

Example 41 with Table

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

the class TableTypeTest method testInvalidResolver.

@Test
void testInvalidResolver() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").measure(Measure.builder().name("measure1").type(Type.BOOLEAN).maker("does.not.exist.class").build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("measure1");
    MetricFormula metricFormula = field.getAnnotation(MetricFormula.class);
    assertThrows(IllegalStateException.class, () -> metricFormula.maker());
}
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) MetricFormula(com.yahoo.elide.datastores.aggregation.annotation.MetricFormula) Test(org.junit.jupiter.api.Test)

Example 42 with Table

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

the class TableTypeTest method testDimensionAnnotations.

@Test
void testDimensionAnnotations() throws Exception {
    Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
    Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TEXT).category("category1").definition("{{region}}").hidden(false).friendlyName("Region").name("region").readAccess("Admin").description("A dimension").tags(tags).cardinality("small").tableSource(TableSource.builder().table("region").column("id").build()).build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("region");
    assertNotNull(field);
    ReadPermission readPermission = field.getAnnotation(ReadPermission.class);
    assertEquals("Admin", readPermission.expression());
    ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
    assertEquals("A dimension", columnMeta.description());
    assertEquals("category1", columnMeta.category());
    assertEquals("Region", columnMeta.friendlyName());
    assertEquals(CardinalitySize.SMALL, columnMeta.size());
    assertEquals(tags, new HashSet<>(Arrays.asList(columnMeta.tags())));
    DimensionFormula dimensionFormula = field.getAnnotation(DimensionFormula.class);
    assertEquals("{{region}}", dimensionFormula.value());
}
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) ColumnMeta(com.yahoo.elide.datastores.aggregation.annotation.ColumnMeta) DimensionFormula(com.yahoo.elide.datastores.aggregation.annotation.DimensionFormula) ReadPermission(com.yahoo.elide.annotation.ReadPermission) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 43 with Table

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

the class TableTypeTest method testTableAnnotations.

@Test
void testTableAnnotations() throws Exception {
    Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
    Set<String> hints = new HashSet<>(Arrays.asList("hint1", "hint2"));
    Table testTable = Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").schema("db1").category("category1").readAccess("Admin").dbConnectionName("dbConn").isFact(true).filterTemplate("a==b").tags(tags).hints(hints).build();
    TableType testType = new TableType(testTable);
    Include include = (Include) testType.getAnnotation(Include.class);
    assertEquals("Table", include.name());
    FromTable fromTable = (FromTable) testType.getAnnotation(FromTable.class);
    assertEquals("db1.table1", fromTable.name());
    assertEquals("dbConn", fromTable.dbConnectionName());
    TableMeta tableMeta = (TableMeta) testType.getAnnotation(TableMeta.class);
    assertEquals("foo", tableMeta.friendlyName());
    assertEquals(CardinalitySize.MEDIUM, tableMeta.size());
    assertEquals("A test table", tableMeta.description());
    assertEquals("category1", tableMeta.category());
    assertTrue(tableMeta.isFact());
    assertEquals(tags, new HashSet<>(Arrays.asList(tableMeta.tags())));
    assertEquals(hints, new HashSet<>(Arrays.asList(tableMeta.hints())));
    assertEquals("a==b", tableMeta.filterTemplate());
    ReadPermission readPermission = (ReadPermission) testType.getAnnotation(ReadPermission.class);
    assertEquals("Admin", readPermission.expression());
}
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) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) TableMeta(com.yahoo.elide.datastores.aggregation.annotation.TableMeta) ReadPermission(com.yahoo.elide.annotation.ReadPermission) HashSet(java.util.HashSet) 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