Search in sources :

Example 11 with DummyRelation

use of io.crate.testing.DummyRelation in project crate by crate.

the class FieldProviderTest method testRelationOutputFromAlias.

@Test
public void testRelationOutputFromAlias() throws Exception {
    // t.name from doc.foo t
    AnalyzedRelation relation = new DummyRelation("name");
    FieldProvider<Field> resolver = new FullQualifedNameFieldProvider(ImmutableMap.of(new QualifiedName(Arrays.asList("t")), relation));
    Field field = resolver.resolveField(newQN("t.name"), Operation.READ);
    assertThat(field.relation(), equalTo(relation));
    assertThat(field.path().outputName(), is("name"));
}
Also used : Field(io.crate.analyze.symbol.Field) QualifiedName(io.crate.sql.tree.QualifiedName) DummyRelation(io.crate.testing.DummyRelation) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 12 with DummyRelation

use of io.crate.testing.DummyRelation in project crate by crate.

the class FieldProviderTest method testRelationOutputFromSchemaTableColumnName.

@Test
public void testRelationOutputFromSchemaTableColumnName() throws Exception {
    // doc.t.name from t.name
    AnalyzedRelation relation = new DummyRelation("name");
    FieldProvider<Field> resolver = new FullQualifedNameFieldProvider(ImmutableMap.of(newQN("doc.t"), relation));
    Field field = resolver.resolveField(newQN("doc.t.name"), Operation.INSERT);
    assertThat(field.relation(), equalTo(relation));
    assertThat(field.path().outputName(), is("name"));
}
Also used : Field(io.crate.analyze.symbol.Field) DummyRelation(io.crate.testing.DummyRelation) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

DummyRelation (io.crate.testing.DummyRelation)12 Field (io.crate.analyze.symbol.Field)10 CrateUnitTest (io.crate.test.integration.CrateUnitTest)10 Test (org.junit.Test)10 QualifiedName (io.crate.sql.tree.QualifiedName)6 Before (org.junit.Before)2 AnalyzedRelation (io.crate.analyze.relations.AnalyzedRelation)1 SqlExpressions (io.crate.testing.SqlExpressions)1