Package org.teiid.language

Examples of org.teiid.language.Function


       
        helpGetString1(func,  "cast('123' AS real)")//$NON-NLS-1$
    }
   
    @Test public void testBooleanToFloata() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
            new Expression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                LANG_FACTORY.createLiteral("float", Float.class)}, //$NON-NLS-1$
            Float.class);

        helpGetString1(func, "cast(1 AS real)"); //$NON-NLS-1$
View Full Code Here


        helpGetString1(func, "cast(1 AS real)"); //$NON-NLS-1$
    }

    @Test public void testBooleanToFloatb() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
            new Expression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
                LANG_FACTORY.createLiteral("float", Float.class)}, //$NON-NLS-1$
            Float.class);

        helpGetString1(func, "cast(0 AS real)"); //$NON-NLS-1$
View Full Code Here

   
    /***************** End of cast(float AS input)******************/
   
    /***************** Beginning of cast(double AS input) ************/
    @Test public void testStringToDouble() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral("123", String.class)//$NON-NLS-1$
                LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
            Double.class);
       
View Full Code Here

       
        helpGetString1(func,  "cast('123' AS double precision)")//$NON-NLS-1$
    }
   
    @Test public void testBooleanToDoublea() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
            new Expression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
            Double.class);

        helpGetString1(func, "cast(1 AS double precision)"); //$NON-NLS-1$
View Full Code Here

        helpGetString1(func, "cast(1 AS double precision)"); //$NON-NLS-1$
    }

    @Test public void testBooleanToDoubleb() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
            new Expression[] { LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class),
                LANG_FACTORY.createLiteral("double", Double.class)}, //$NON-NLS-1$
            Double.class);

        helpGetString1(func, "cast(0 AS double precision)"); //$NON-NLS-1$
View Full Code Here

   
    /***************** End of cast(double AS input)******************/
   
    /***************** Beginning of cast(bigdecimal AS input) ************/
    @Test public void testStringToBigDecimal() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert"//$NON-NLS-1$
            new Expression[] {
                LANG_FACTORY.createLiteral("123", String.class)//$NON-NLS-1$
                LANG_FACTORY.createLiteral("bigdecimal", java.math.BigDecimal.class)}, //$NON-NLS-1$
            java.math.BigDecimal.class);
       
View Full Code Here

       
        helpGetString1(func,  "cast('123' AS numeric(38, 19))")//$NON-NLS-1$
    }

    @Test public void testBooleanToBigDecimala() throws Exception {
        Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
            new Expression[] { LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class),
                LANG_FACTORY.createLiteral("bigdecimal", java.math.BigDecimal.class)}, //$NON-NLS-1$
            java.math.BigDecimal.class);

        helpGetString1(func, "cast(1 AS numeric(38, 19))"); //$NON-NLS-1$
View Full Code Here

    public TestLeftOrRightFunctionModifier(String name) {
        super(name);
    }

    public void helpTestMod(Literal c, Literal d, String target, String expectedStr) throws Exception {
        Function func = LANG_FACTORY.createFunction(target,
            Arrays.asList( c, d ),
            String.class);
       
        OracleExecutionFactory trans = new OracleExecutionFactory();
        trans.start();
View Full Code Here

    this.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
      @Override
      public List<?> translate(Function function) {
        Expression booleanValue = function.getParameters().get(0);
        if (booleanValue instanceof Function) {
          Function nested = (Function)booleanValue;
          if (nested.getName().equalsIgnoreCase("convert") && Number.class.isAssignableFrom(nested.getParameters().get(0).getType())) { //$NON-NLS-1$
            booleanValue = nested.getParameters().get(0);
          }
        }
        if (!booleanNullable) {
          return Arrays.asList("CASE WHEN ", booleanValue, " = 0 THEN 'false' ELSE 'true' END"); //$NON-NLS-1$ //$NON-NLS-2$         
        }
View Full Code Here

        super(name);
    }

    public void testModifier() {
        Literal arg = LANG_FACTORY.createLiteral(new Double(5.2), Double.class);
        Function func = LANG_FACTORY.createFunction("log10", Arrays.asList(arg), Double.class); //$NON-NLS-1$
       
        Log10FunctionModifier modifier = new Log10FunctionModifier(LANG_FACTORY);
        modifier.translate(func);
       
        assertEquals("log", func.getName()); //$NON-NLS-1$
        assertEquals(Double.class, func.getType());
       
        List<Expression> outArgs = func.getParameters();
        assertEquals(2, outArgs.size());
        assertEquals(arg, outArgs.get(1));
       
        assertTrue(outArgs.get(1) instanceof Literal);
        Literal newArg = (Literal) outArgs.get(0);
View Full Code Here

TOP

Related Classes of org.teiid.language.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.