Search in sources :

Example 31 with ReferenceIdent

use of io.crate.metadata.ReferenceIdent in project crate by crate.

the class SymbolPrinterTest method testReference.

@Test
public void testReference() throws Exception {
    Reference r = new Reference(new ReferenceIdent(new RelationName("sys", "table"), new ColumnIdent("column", Arrays.asList("path", "nested"))), RowGranularity.DOC, DataTypes.STRING, 1, null);
    assertPrint(r, "sys.\"table\".\"column\"['path']['nested']");
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 32 with ReferenceIdent

use of io.crate.metadata.ReferenceIdent in project crate by crate.

the class SymbolPrinterTest method testReferenceEscaped.

@Test
public void testReferenceEscaped() throws Exception {
    Reference r = new Reference(new ReferenceIdent(new RelationName("doc", "table"), new ColumnIdent("colum\"n")), RowGranularity.DOC, DataTypes.STRING, 0, null);
    assertPrint(r, "doc.\"table\".\"colum\"\"n\"");
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 33 with ReferenceIdent

use of io.crate.metadata.ReferenceIdent in project crate by crate.

the class SymbolPrinterTest method testVoidReference.

@Test
public void testVoidReference() throws Exception {
    Reference r = new VoidReference(new ReferenceIdent(new RelationName("schema", "table"), new ColumnIdent("column", Arrays.asList("path", "nested"))), RowGranularity.DOC, 0);
    assertPrint(r, "schema.\"table\".\"column\"['path']['nested']");
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) VoidReference(io.crate.expression.symbol.VoidReference) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 34 with ReferenceIdent

use of io.crate.metadata.ReferenceIdent in project crate by crate.

the class SymbolPrinterTest method testDynamicReference.

@Test
public void testDynamicReference() throws Exception {
    Reference r = new DynamicReference(new ReferenceIdent(new RelationName("schema", "table"), new ColumnIdent("column", Arrays.asList("path", "nested"))), RowGranularity.DOC, 0);
    assertPrint(r, "schema.\"table\".\"column\"['path']['nested']");
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) DynamicReference(io.crate.expression.symbol.DynamicReference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 35 with ReferenceIdent

use of io.crate.metadata.ReferenceIdent in project crate by crate.

the class FetchPhaseTest method testStreaming.

@Test
public void testStreaming() throws Exception {
    RelationName t1 = new RelationName(Schemas.DOC_SCHEMA_NAME, "t1");
    TreeMap<String, Integer> bases = new TreeMap<>();
    bases.put(t1.name(), 0);
    bases.put("i2", 1);
    HashMap<RelationName, Collection<String>> tableIndices = new HashMap<>();
    tableIndices.put(t1, List.of(t1.name()));
    tableIndices.put(new RelationName(Schemas.DOC_SCHEMA_NAME, "i2"), List.of("i2_s1", "i2_s2"));
    ReferenceIdent nameIdent = new ReferenceIdent(t1, "name");
    Reference name = new Reference(nameIdent, RowGranularity.DOC, DataTypes.STRING, 0, null);
    FetchPhase orig = new FetchPhase(1, Set.of("node1", "node2"), bases, tableIndices, List.of(name));
    BytesStreamOutput out = new BytesStreamOutput();
    ExecutionPhases.toStream(out, orig);
    StreamInput in = out.bytes().streamInput();
    FetchPhase streamed = (FetchPhase) ExecutionPhases.fromStream(in);
    assertThat(orig.phaseId(), is(streamed.phaseId()));
    assertThat(orig.nodeIds(), is(streamed.nodeIds()));
    assertThat(orig.fetchRefs(), is(streamed.fetchRefs()));
    assertThat(orig.bases(), is(streamed.bases()));
    assertThat(orig.tableIndices(), is(streamed.tableIndices()));
}
Also used : HashMap(java.util.HashMap) Reference(io.crate.metadata.Reference) TreeMap(java.util.TreeMap) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ReferenceIdent(io.crate.metadata.ReferenceIdent) FetchPhase(io.crate.execution.dsl.phases.FetchPhase) StreamInput(org.elasticsearch.common.io.stream.StreamInput) RelationName(io.crate.metadata.RelationName) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

Reference (io.crate.metadata.Reference)44 ReferenceIdent (io.crate.metadata.ReferenceIdent)44 Test (org.junit.Test)31 RelationName (io.crate.metadata.RelationName)21 ColumnIdent (io.crate.metadata.ColumnIdent)19 DynamicReference (io.crate.expression.symbol.DynamicReference)12 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)12 SymbolMatchers.isReference (io.crate.testing.SymbolMatchers.isReference)9 VoidReference (io.crate.expression.symbol.VoidReference)8 DocTableInfo (io.crate.metadata.doc.DocTableInfo)8 Symbol (io.crate.expression.symbol.Symbol)6 FetchReference (io.crate.expression.symbol.FetchReference)5 OrderBy (io.crate.analyze.OrderBy)4 RoutedCollectPhase (io.crate.execution.dsl.phases.RoutedCollectPhase)4 CollectorContext (io.crate.expression.reference.doc.lucene.CollectorContext)3 TestingRowConsumer (io.crate.testing.TestingRowConsumer)3 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)3 Before (org.junit.Before)3 Bucket (io.crate.data.Bucket)2 SumAggregation (io.crate.execution.engine.aggregation.impl.SumAggregation)2