Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Function


        DeleteAnalysis.NestedDeleteAnalysis analysis = analyze("delete from users where name='Trillian'");
        assertEquals(TEST_DOC_TABLE_IDENT, analysis.table().ident());

        assertThat(analysis.rowGranularity(), is(RowGranularity.DOC));

        Function whereClause = (Function)analysis.whereClause().query();
        assertEquals(EqOperator.NAME, whereClause.info().ident().name());
        assertFalse(whereClause.info().type() == FunctionInfo.Type.AGGREGATE);

        assertThat(whereClause.arguments().get(0), IsInstanceOf.instanceOf(Reference.class));

        assertLiteralSymbol(whereClause.arguments().get(1), "Trillian");
    }
View Full Code Here


                        "  where name = 'Trillian'" +
                        ")");

        assertThat(analysis.columns().size(), is(analysis.getSubQueryColumns().size()));
        assertThat(analysis.getSubQueryColumns().get(1), instanceOf(Function.class));
        Function castFunction = (Function)analysis.getSubQueryColumns().get(1);
        assertThat(castFunction.info().ident().name(), is(ToStringFunction.NAME));
    }
View Full Code Here


    @Test
    public void testQueryShardRequestSerialization() throws Exception {
        Reference nameRef = createReference("name", DataTypes.STRING);
        Function query = createFunction(EqOperator.NAME, DataTypes.BOOLEAN, nameRef, Literal.newLiteral("Arthur"));
        WhereClause whereClause = new WhereClause(query);
        QueryShardRequest request = new QueryShardRequest(
                "dummyTable",
                1,
                ImmutableList.<Symbol>of(nameRef),
View Full Code Here

        analyzer = injector.getInstance(Analyzer.class);
    }


    protected static Function getFunctionByName(String functionName, Collection c) {
        Function function = null;
        Iterator<Function> it = c.iterator();
        while (function == null && it.hasNext()) {
            Function f = it.next();
            if (f.info().ident().name().equals(functionName)) {
                function = f;
            }

        }
        return function;
View Full Code Here

        final DataType arrayType = new ArrayType(DataTypes.STRING);
        ToIntArrayFunction impl = (ToIntArrayFunction)functions.get(
                new FunctionIdent(ToIntArrayFunction.NAME, ImmutableList.of(arrayType)));

        Reference foo = TestingHelpers.createReference("foo", arrayType);
        Symbol symbol = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(foo)));
        assertThat(symbol, instanceOf(Function.class));
    }
View Full Code Here

            @Override
            public DataType valueType() {
                return arrayType;
            }
        };
        Symbol normalized = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(input)));
        Object[] integers = impl.evaluate(new Input[]{input});

        assertThat(integers, is(((Input) normalized).value()));
        return integers;
    }
View Full Code Here

    }

    @Test
    public void testCollectFunction() throws Exception {
        CollectNode collectNode = new CollectNode("function", testRouting);
        Function twoTimesTruthFunction = new Function(
                TestFunction.info,
                Arrays.<Symbol>asList(testNodeReference)
        );
        collectNode.toCollect(Arrays.<Symbol>asList(twoTimesTruthFunction, testNodeReference));
        collectNode.maxRowGranularity(RowGranularity.NODE);
View Full Code Here

            @Override
            public DataType valueType() {
                return arrayType;
            }
        };
        Symbol normalized = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(input)));
        Object[] integers = impl.evaluate(new Input[]{input});

        assertThat(integers, is(((Input) normalized).value()));
        return integers;
    }
View Full Code Here

        // will be wrapped somewhere above
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("Cannot find implementation for function unknown()");

        CollectNode collectNode = new CollectNode("unknownFunction", testRouting);
        Function unknownFunction = new Function(
                new FunctionInfo(
                        new FunctionIdent("unknown", ImmutableList.<DataType>of()),
                        DataTypes.BOOLEAN
                ),
                ImmutableList.<Symbol>of()
View Full Code Here

    @Test
    public void testCollectWithFalseWhereClause() throws Exception {
        CollectNode collectNode = new CollectNode("whereClause", testRouting);
        collectNode.toCollect(Arrays.<Symbol>asList(testNodeReference));
        collectNode.whereClause(new WhereClause(new Function(
                AndOperator.INFO,
                Arrays.<Symbol>asList(Literal.newLiteral(false), Literal.newLiteral(false))
        )));
        Object[][] result = operation.collect(collectNode).get();
        assertArrayEquals(new Object[0][], result);
View Full Code Here

TOP

Related Classes of io.crate.planner.symbol.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.