Search in sources :

Example 16 with ColumnProjection

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

the class LogicalReferenceExtractorTest method testPhysicalReference.

@Test
public void testPhysicalReference() {
    ColumnProjection recordedDate = playerStats.getColumnProjection("recordedDate");
    List<Reference> references = parser.parse(playerStats, recordedDate.getExpression());
    assertTrue(references.size() == 1);
    ReferenceExtractor<LogicalReference> extractor = new ReferenceExtractor(LogicalReference.class, metaDataStore, ReferenceExtractor.Mode.SAME_QUERY);
    Set<LogicalReference> logicalReferences = references.get(0).accept(extractor);
    assertTrue(logicalReferences.size() == 0);
}
Also used : ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) Test(org.junit.jupiter.api.Test)

Example 17 with ColumnProjection

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

the class LogicalReferenceExtractorTest method testJoinReference.

@Test
public void testJoinReference() {
    ColumnProjection countryIsInUsa = playerStats.getColumnProjection("countryIsInUsa");
    List<Reference> references = parser.parse(playerStats, countryIsInUsa.getExpression());
    assertTrue(references.size() == 1);
    ReferenceExtractor<LogicalReference> extractor = new ReferenceExtractor(LogicalReference.class, metaDataStore, ReferenceExtractor.Mode.SAME_QUERY);
    Set<LogicalReference> logicalReferences = references.get(0).accept(extractor);
    assertEquals(0, logicalReferences.size());
}
Also used : ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) Test(org.junit.jupiter.api.Test)

Example 18 with ColumnProjection

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

the class PhysicalReferenceExtractorTest method testLogicalReference.

@Test
public void testLogicalReference() {
    ColumnProjection playerLevel = playerStats.getColumnProjection("playerLevel");
    List<Reference> references = parser.parse(playerStats, playerLevel.getExpression());
    assertTrue(references.size() == 1);
    ReferenceExtractor<PhysicalReference> extractor = new ReferenceExtractor(PhysicalReference.class, metaDataStore, ReferenceExtractor.Mode.SAME_QUERY);
    Set<PhysicalReference> physicalReferences = references.get(0).accept(extractor);
    assertEquals(1, physicalReferences.size());
    assertTrue(physicalReferences.contains(PhysicalReference.builder().source(playerStats).name("overallRating").build()));
}
Also used : ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) Test(org.junit.jupiter.api.Test)

Example 19 with ColumnProjection

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

the class PhysicalReferenceExtractorTest method testJoinReference.

@Test
public void testJoinReference() {
    ColumnProjection countryIsInUsa = playerStats.getColumnProjection("countryIsInUsa");
    List<Reference> references = parser.parse(playerStats, countryIsInUsa.getExpression());
    assertTrue(references.size() == 1);
    ReferenceExtractor<PhysicalReference> extractor = new ReferenceExtractor(PhysicalReference.class, metaDataStore, ReferenceExtractor.Mode.SAME_QUERY);
    Set<PhysicalReference> physicalReferences = references.get(0).accept(extractor);
    assertEquals(1, physicalReferences.size());
    assertTrue(physicalReferences.contains(PhysicalReference.builder().source(playerStats).name("country_id").build()));
}
Also used : ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) Test(org.junit.jupiter.api.Test)

Example 20 with ColumnProjection

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

the class SQLColumnProjectionTest method testColumnThatCannotNest.

@Test
public void testColumnThatCannotNest() throws Exception {
    SQLTable table = metaDataStore.getTable(ClassType.of(TableA.class));
    ColumnProjection projection = table.getColumnProjection("dim1");
    assertFalse(projection.canNest(table, metaDataStore));
}
Also used : SQLTable(com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable) ColumnProjection(com.yahoo.elide.datastores.aggregation.query.ColumnProjection) Test(org.junit.jupiter.api.Test)

Aggregations

ColumnProjection (com.yahoo.elide.datastores.aggregation.query.ColumnProjection)36 Test (org.junit.jupiter.api.Test)22 SQLTable (com.yahoo.elide.datastores.aggregation.queryengines.sql.metadata.SQLTable)13 Argument (com.yahoo.elide.core.request.Argument)7 Queryable (com.yahoo.elide.datastores.aggregation.query.Queryable)6 Query (com.yahoo.elide.datastores.aggregation.query.Query)5 Argument.getArgumentMapFromString (com.yahoo.elide.core.request.Argument.getArgumentMapFromString)4 ValueType (com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType)4 Column (com.yahoo.elide.datastores.aggregation.metadata.models.Column)4 ExpressionParser (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.ExpressionParser)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Path (com.yahoo.elide.core.Path)3 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)3 MetaDataStore (com.yahoo.elide.datastores.aggregation.metadata.MetaDataStore)3 Reference (com.yahoo.elide.datastores.aggregation.queryengines.sql.expression.Reference)3 HashMap (java.util.HashMap)3 HandlebarsException (com.github.jknack.handlebars.HandlebarsException)2 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)2