Search in sources :

Example 1 with Log10FunctionModifier

use of org.teiid.translator.jdbc.hana.Log10FunctionModifier in project teiid by teiid.

the class TestLog10FunctionModifier method testModifier.

public void testModifier() {
    Literal arg = LANG_FACTORY.createLiteral(new Double(5.2), Double.class);
    // $NON-NLS-1$
    Function func = LANG_FACTORY.createFunction("log10", Arrays.asList(arg), Double.class);
    Log10FunctionModifier modifier = new Log10FunctionModifier(LANG_FACTORY);
    modifier.translate(func);
    // $NON-NLS-1$
    assertEquals("log", func.getName());
    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);
    assertEquals(Integer.class, newArg.getType());
    assertEquals(new Integer(10), newArg.getValue());
    // $NON-NLS-1$
    assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(func));
}
Also used : Function(org.teiid.language.Function) Log10FunctionModifier(org.teiid.translator.jdbc.hana.Log10FunctionModifier) Expression(org.teiid.language.Expression) Literal(org.teiid.language.Literal)

Aggregations

Expression (org.teiid.language.Expression)1 Function (org.teiid.language.Function)1 Literal (org.teiid.language.Literal)1 Log10FunctionModifier (org.teiid.translator.jdbc.hana.Log10FunctionModifier)1