Search in sources :

Example 16 with ReferenceIdent

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

the class GroupByAnalyzerTest method testNegateAliasRealColumnGroupByAlias.

@Test
public void testNegateAliasRealColumnGroupByAlias() {
    QueriedSelectRelation relation = analyze("select age age, - age age from foo.users group by age;");
    assertThat(relation.groupBy().isEmpty(), is(false));
    List<Symbol> groupBySymbols = relation.groupBy();
    ReferenceIdent groupByIdent = ((Reference) groupBySymbols.get(0)).ident();
    assertThat(groupByIdent.columnIdent().fqn(), is("age"));
    assertThat(groupByIdent.tableIdent().fqn(), is("foo.users"));
}
Also used : Symbol(io.crate.expression.symbol.Symbol) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 17 with ReferenceIdent

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

the class LuceneReferenceResolverTest method testGetImplementationWithColumnsOfTypeCollection.

@Test
public void testGetImplementationWithColumnsOfTypeCollection() {
    Reference arrayRef = new Reference(new ReferenceIdent(name, "a"), RowGranularity.DOC, DataTypes.DOUBLE_ARRAY, 0, null);
    assertThat(luceneReferenceResolver.getImplementation(arrayRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
}
Also used : DynamicReference(io.crate.expression.symbol.DynamicReference) Reference(io.crate.metadata.Reference) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test)

Example 18 with ReferenceIdent

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

the class LuceneReferenceResolverTest method testGetImplementationForSequenceNumber.

@Test
public void testGetImplementationForSequenceNumber() {
    Reference seqNumberRef = new Reference(new ReferenceIdent(name, "_seq_no"), RowGranularity.DOC, DataTypes.LONG, 0, null);
    assertThat(luceneReferenceResolver.getImplementation(seqNumberRef), instanceOf(SeqNoCollectorExpression.class));
}
Also used : DynamicReference(io.crate.expression.symbol.DynamicReference) Reference(io.crate.metadata.Reference) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test)

Example 19 with ReferenceIdent

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

the class LuceneReferenceResolverTest method test_ignored_dynamic_references_are_resolved_using_sourcelookup.

@Test
public void test_ignored_dynamic_references_are_resolved_using_sourcelookup() {
    Reference ignored = new DynamicReference(new ReferenceIdent(name, "a", List.of("b")), RowGranularity.DOC, ColumnPolicy.IGNORED, 0);
    assertThat(luceneReferenceResolver.getImplementation(ignored), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
}
Also used : DynamicReference(io.crate.expression.symbol.DynamicReference) Reference(io.crate.metadata.Reference) DynamicReference(io.crate.expression.symbol.DynamicReference) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test)

Example 20 with ReferenceIdent

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

the class EvaluatingNormalizerTest method prepare.

@Before
public void prepare() throws Exception {
    Map<ColumnIdent, NestableInput> referenceImplementationMap = new HashMap<>(1, 1);
    ReferenceIdent dummyLoadIdent = new ReferenceIdent(new RelationName("test", "dummy"), "load");
    dummyLoadInfo = new Reference(dummyLoadIdent, RowGranularity.NODE, DataTypes.DOUBLE, 0, null);
    referenceImplementationMap.put(dummyLoadIdent.columnIdent(), constant(0.08d));
    nodeCtx = createNodeContext();
    referenceResolver = new MapBackedRefResolver(referenceImplementationMap);
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) NestableInput(io.crate.expression.NestableInput) MapBackedRefResolver(io.crate.metadata.MapBackedRefResolver) HashMap(java.util.HashMap) Reference(io.crate.metadata.Reference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) Before(org.junit.Before)

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