Search in sources :

Example 86 with Symbol

use of io.crate.analyze.symbol.Symbol in project crate by crate.

the class SymbolToTrueVisitorTest method testFalseAndMatchFunction.

@Test
public void testFalseAndMatchFunction() throws Exception {
    Symbol symbol = convertFromSQL("false and match (table_name, 'jalla')");
    assertThat(symbol, isLiteral(false));
}
Also used : Symbol(io.crate.analyze.symbol.Symbol) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 87 with Symbol

use of io.crate.analyze.symbol.Symbol in project crate by crate.

the class SymbolToTrueVisitorTest method testNullAndMatchFunction.

@Test
public void testNullAndMatchFunction() throws Exception {
    Symbol symbol = convertFromSQL("null and match (table_name, 'jalla')");
    assertThat(symbol, isLiteral(null, DataTypes.BOOLEAN));
}
Also used : Symbol(io.crate.analyze.symbol.Symbol) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 88 with Symbol

use of io.crate.analyze.symbol.Symbol in project crate by crate.

the class GroupProjectionTest method testStreaming2.

@Test
public void testStreaming2() throws Exception {
    Reference nameRef = createReference("name", DataTypes.STRING);
    List<Symbol> keys = Collections.singletonList(nameRef);
    List<Aggregation> aggregations = Collections.singletonList(Aggregation.finalAggregation(new FunctionInfo(new FunctionIdent(CountAggregation.NAME, ImmutableList.of()), DataTypes.LONG), ImmutableList.of(), Aggregation.Step.PARTIAL));
    GroupProjection groupProjection = new GroupProjection(keys, aggregations, RowGranularity.CLUSTER);
    BytesStreamOutput out = new BytesStreamOutput();
    Projection.toStream(groupProjection, out);
    StreamInput in = StreamInput.wrap(out.bytes());
    GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
    assertThat(p2.keys().size(), is(1));
    assertThat(p2.values().size(), is(1));
}
Also used : CountAggregation(io.crate.operation.aggregation.impl.CountAggregation) Aggregation(io.crate.analyze.symbol.Aggregation) FunctionIdent(io.crate.metadata.FunctionIdent) TestingHelpers.createReference(io.crate.testing.TestingHelpers.createReference) Reference(io.crate.metadata.Reference) Symbol(io.crate.analyze.symbol.Symbol) StreamInput(org.elasticsearch.common.io.stream.StreamInput) FunctionInfo(io.crate.metadata.FunctionInfo) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 89 with Symbol

use of io.crate.analyze.symbol.Symbol in project crate by crate.

the class GroupProjectionTest method testStreaming.

@Test
public void testStreaming() throws Exception {
    ImmutableList<Symbol> keys = ImmutableList.of(createReference("foo", DataTypes.STRING), createReference("bar", DataTypes.SHORT));
    ImmutableList<Aggregation> aggregations = ImmutableList.of();
    GroupProjection p = new GroupProjection(keys, aggregations, RowGranularity.CLUSTER);
    BytesStreamOutput out = new BytesStreamOutput();
    Projection.toStream(p, out);
    StreamInput in = StreamInput.wrap(out.bytes());
    GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
    assertEquals(p, p2);
}
Also used : CountAggregation(io.crate.operation.aggregation.impl.CountAggregation) Aggregation(io.crate.analyze.symbol.Aggregation) Symbol(io.crate.analyze.symbol.Symbol) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 90 with Symbol

use of io.crate.analyze.symbol.Symbol in project crate by crate.

the class GroupProjectionTest method testStreamingGranularity.

@Test
public void testStreamingGranularity() throws Exception {
    ImmutableList<Symbol> keys = ImmutableList.of(createReference("foo", DataTypes.STRING), createReference("bar", DataTypes.SHORT));
    ImmutableList<Aggregation> aggregations = ImmutableList.of();
    GroupProjection p = new GroupProjection(keys, aggregations, RowGranularity.SHARD);
    BytesStreamOutput out = new BytesStreamOutput();
    Projection.toStream(p, out);
    StreamInput in = StreamInput.wrap(out.bytes());
    GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
    assertEquals(p, p2);
}
Also used : CountAggregation(io.crate.operation.aggregation.impl.CountAggregation) Aggregation(io.crate.analyze.symbol.Aggregation) Symbol(io.crate.analyze.symbol.Symbol) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

Symbol (io.crate.analyze.symbol.Symbol)109 Test (org.junit.Test)51 CrateUnitTest (io.crate.test.integration.CrateUnitTest)40 Function (io.crate.analyze.symbol.Function)14 Input (io.crate.data.Input)14 Reference (io.crate.metadata.Reference)11 WhereClause (io.crate.analyze.WhereClause)10 InputColumn (io.crate.analyze.symbol.InputColumn)8 InputFactory (io.crate.operation.InputFactory)8 OrderBy (io.crate.analyze.OrderBy)7 ExpressionAnalysisContext (io.crate.analyze.expressions.ExpressionAnalysisContext)6 ExpressionAnalyzer (io.crate.analyze.expressions.ExpressionAnalyzer)6 AbstractScalarFunctionsTest (io.crate.operation.scalar.AbstractScalarFunctionsTest)6 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)6 StreamInput (org.elasticsearch.common.io.stream.StreamInput)6 ImmutableList (com.google.common.collect.ImmutableList)5 DocTableInfo (io.crate.metadata.doc.DocTableInfo)5 TableInfo (io.crate.metadata.table.TableInfo)5 QuerySpec (io.crate.analyze.QuerySpec)4 Literal (io.crate.analyze.symbol.Literal)4