Search in sources :

Example 6 with Table

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

the class TableTypeTest method testMultipleTimeDimensionGrains.

@Test
void testMultipleTimeDimensionGrains() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TIME).definition("{{createdOn}}").name("createdOn").grain(Grain.builder().sql("some sql").type(Grain.GrainType.DAY).build()).grain(Grain.builder().sql("some other sql").type(Grain.GrainType.YEAR).build()).build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("createdOn");
    assertNotNull(field);
    Temporal temporal = field.getAnnotation(Temporal.class);
    assertEquals("UTC", temporal.timeZone());
    assertTrue(temporal.grains().length == 2);
    assertEquals("some sql", temporal.grains()[0].expression());
    assertEquals("some other sql", temporal.grains()[1].expression());
    assertEquals(TimeGrain.DAY, temporal.grains()[0].grain());
    assertEquals(TimeGrain.YEAR, temporal.grains()[1].grain());
}
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) Temporal(com.yahoo.elide.datastores.aggregation.annotation.Temporal) Test(org.junit.jupiter.api.Test)

Example 7 with Table

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

the class TableTypeTest method testEnumeratedDimension.

@Test
void testEnumeratedDimension() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().name("dim1").type("ENUM_ORDINAL").values(Set.of("A", "B", "C")).build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("dim1");
    assertNotNull(field);
    Enumerated enumerated = field.getAnnotation(Enumerated.class);
    assertNotNull(enumerated);
    assertEquals(EnumType.ORDINAL, enumerated.value());
}
Also used : Field(com.yahoo.elide.core.type.Field) Enumerated(javax.persistence.Enumerated) Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) Test(org.junit.jupiter.api.Test)

Example 8 with Table

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

the class TableTypeTest method testTimeDimensionAnnotations.

@Test
void testTimeDimensionAnnotations() throws Exception {
    Set<String> tags = new HashSet<>(Arrays.asList("tag1", "tag2"));
    Table testTable = Table.builder().table("table1").name("Table").dimension(Dimension.builder().type(Type.TIME).category("category1").definition("{{createdOn  }}").hidden(false).friendlyName("Created On").name("createdOn").readAccess("Admin").description("A time dimension").tags(tags).build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("createdOn");
    assertNotNull(field);
    ReadPermission readPermission = field.getAnnotation(ReadPermission.class);
    assertEquals("Admin", readPermission.expression());
    ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
    assertEquals("A time dimension", columnMeta.description());
    assertEquals("category1", columnMeta.category());
    assertEquals("Created On", columnMeta.friendlyName());
    assertEquals(CardinalitySize.UNKNOWN, columnMeta.size());
    assertEquals(tags, new HashSet<>(Arrays.asList(columnMeta.tags())));
    DimensionFormula dimensionFormula = field.getAnnotation(DimensionFormula.class);
    assertEquals("{{createdOn}}", dimensionFormula.value());
    Temporal temporal = field.getAnnotation(Temporal.class);
    assertEquals("UTC", temporal.timeZone());
    assertTrue(temporal.grains().length == 0);
}
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) Temporal(com.yahoo.elide.datastores.aggregation.annotation.Temporal) ReadPermission(com.yahoo.elide.annotation.ReadPermission) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 9 with Table

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

the class TableTypeTest method testTableNameWithoutSchema.

@Test
void testTableNameWithoutSchema() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").build();
    TableType testType = new TableType(testTable);
    FromTable fromTable = (FromTable) testType.getAnnotation(FromTable.class);
    assertEquals("table1", fromTable.name());
}
Also used : Table(com.yahoo.elide.modelconfig.model.Table) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) FromTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.FromTable) Test(org.junit.jupiter.api.Test)

Example 10 with Table

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

the class TableTypeTest method testHiddenMeasure.

@Test
void testHiddenMeasure() throws Exception {
    Table testTable = Table.builder().table("table1").name("Table").measure(Measure.builder().name("measure1").type(Type.BOOLEAN).hidden(true).build()).build();
    TableType testType = new TableType(testTable);
    Field field = testType.getDeclaredField("measure1");
    assertNotNull(field);
    ColumnMeta columnMeta = field.getAnnotation(ColumnMeta.class);
    assertNotNull(columnMeta);
    assertTrue(columnMeta.isHidden());
}
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) 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