Search in sources :

Example 1 with DummyRelation

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

the class SymbolToTrueVisitorTest method prepare.

@Before
public void prepare() throws Exception {
    visitor = new SymbolToTrueVisitor();
    DummyRelation dummyRelation = new DummyRelation("clustered_by", "number_of_shards", "table_name", "number_of_replicas", "schema_name");
    ImmutableMap<QualifiedName, AnalyzedRelation> sources = ImmutableMap.<QualifiedName, AnalyzedRelation>of(new QualifiedName("dummy"), dummyRelation);
    expressions = new SqlExpressions(sources);
}
Also used : QualifiedName(io.crate.sql.tree.QualifiedName) AnalyzedRelation(io.crate.analyze.relations.AnalyzedRelation) SqlExpressions(io.crate.testing.SqlExpressions) DummyRelation(io.crate.testing.DummyRelation) Before(org.junit.Before)

Example 2 with DummyRelation

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

the class ExpressionAnalyzerTest method prepare.

@Before
public void prepare() throws Exception {
    paramTypeHints = ParamTypeHints.EMPTY;
    DummyRelation dummyRelation = new DummyRelation("obj.x", "myObj.x", "myObj.x.AbC");
    dummySources = ImmutableMap.of(new QualifiedName("foo"), dummyRelation);
    context = new ExpressionAnalysisContext();
    functions = getFunctions();
}
Also used : DummyRelation(io.crate.testing.DummyRelation) Before(org.junit.Before)

Example 3 with DummyRelation

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

the class FieldProviderTest method testMultipleSourcesWithDynamicReferenceAndReference.

@Test
public void testMultipleSourcesWithDynamicReferenceAndReference() throws Exception {
    AnalyzedRelation barT = new DummyRelation("name");
    AnalyzedRelation fooT = new DummyRelation("name");
    AnalyzedRelation fooA = new DummyRelation("name");
    AnalyzedRelation customT = new DummyRelation("tags");
    FieldProvider<Field> resolver = new FullQualifedNameFieldProvider(ImmutableMap.of(newQN("bar.t"), barT, newQN("foo.t"), fooT, newQN("foo.a"), fooA, newQN("custom.t"), customT));
    Field field = resolver.resolveField(newQN("foo.t.name"), Operation.READ);
    assertThat(field.relation(), equalTo(fooT));
    // reference > dynamicReference - not ambiguous
    Field tags = resolver.resolveField(newQN("tags"), Operation.READ);
    assertThat(tags.relation(), equalTo(customT));
    field = resolver.resolveField(newQN("a.name"), Operation.READ);
    assertThat(field.relation(), equalTo(fooA));
}
Also used : Field(io.crate.analyze.symbol.Field) DummyRelation(io.crate.testing.DummyRelation) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 4 with DummyRelation

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

the class FieldProviderTest method testAliasRelationNameResolver.

@Test
public void testAliasRelationNameResolver() throws Exception {
    AnalyzedRelation barT = new DummyRelation("name");
    FieldProvider<Field> resolver = new FullQualifedNameFieldProvider(ImmutableMap.of(newQN("\"Bar\""), barT));
    Field field = resolver.resolveField(newQN("\"Bar\".name"), Operation.READ);
    assertThat(field.relation(), equalTo(barT));
}
Also used : Field(io.crate.analyze.symbol.Field) DummyRelation(io.crate.testing.DummyRelation) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 5 with DummyRelation

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

the class FieldProviderTest method testSimpleResolverUnknownColumn.

@Test
public void testSimpleResolverUnknownColumn() throws Exception {
    expectedException.expect(ColumnUnknownException.class);
    expectedException.expectMessage("Column unknown unknown");
    AnalyzedRelation relation = new DummyRelation("name");
    FieldProvider<Field> resolver = new FullQualifedNameFieldProvider(ImmutableMap.of(newQN("doc.t"), relation));
    resolver.resolveField(new QualifiedName(Arrays.asList("unknown")), Operation.READ);
}
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)

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