Search in sources :

Example 31 with Expression

use of org.teiid.language.Expression in project teiid by teiid.

the class TestModFunctionModifier method testOneIntElemOneIntConst5.

/**
 * Test {@link ModFunctionModifier#modify(Function)} to validate a call to
 * e1 % y using a {@link Integer} element and a {@link Integer} constant for
 * parameters returns (e1 % y).  {@link ModFunctionModifier} will be
 * constructed with a function name of "%" and no supported type list.
 *
 * @throws Exception
 */
public void testOneIntElemOneIntConst5() throws Exception {
    Expression[] args = new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createColumnReference("e1", null, null, Integer.class), LANG_FACTORY.createLiteral(new Integer(6), Integer.class) };
    // % / default
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTestMod("%", args, "(e1 % 6)");
}
Also used : BigInteger(java.math.BigInteger) Expression(org.teiid.language.Expression)

Example 32 with Expression

use of org.teiid.language.Expression in project teiid by teiid.

the class TestModFunctionModifier method testTwoBigDecConst.

/**
 * Test {@link ModFunctionModifier#modify(Function)} to validate a call to
 * MOD(x,y) using {@link BigDecimal} constants for both parameters returns
 * (x - (TRUNC((x / y), 0) * y)).  {@link ModFunctionModifier} will be
 * constructed without specifying a function name or a supported type list.
 *
 * @throws Exception
 */
public void testTwoBigDecConst() throws Exception {
    Expression[] args = new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createLiteral(new BigDecimal("10"), BigDecimal.class), // $NON-NLS-1$
    LANG_FACTORY.createLiteral(new BigDecimal("6"), BigDecimal.class) };
    // $NON-NLS-1$
    helpTestMod(args, "(10 - (sign(10) * floor(abs((10 / 6))) * abs(6)))");
}
Also used : Expression(org.teiid.language.Expression) BigDecimal(java.math.BigDecimal)

Example 33 with Expression

use of org.teiid.language.Expression in project teiid by teiid.

the class TestModFunctionModifier method testTwoIntConst.

/**
 * Test {@link ModFunctionModifier#modify(Function)} to validate a call to
 * MOD(x,y) using {@link Integer} constants for both parameters returns
 * MOD(x,y).  {@link ModFunctionModifier} will be constructed without
 * specifying a function name or a supported type list.
 *
 * @throws Exception
 */
public void testTwoIntConst() throws Exception {
    Expression[] args = new Expression[] { LANG_FACTORY.createLiteral(new Integer(10), Integer.class), LANG_FACTORY.createLiteral(new Integer(6), Integer.class) };
    // default / default
    // $NON-NLS-1$
    helpTestMod(args, "MOD(10, 6)");
}
Also used : BigInteger(java.math.BigInteger) Expression(org.teiid.language.Expression)

Example 34 with Expression

use of org.teiid.language.Expression in project teiid by teiid.

the class TestModFunctionModifier method testOneIntElemOneIntConst.

/**
 * Test {@link ModFunctionModifier#modify(Function)} to validate a call to
 * MOD(e1,y) using a {@link Integer} element and a {@link Integer} constant
 * for parameters returns MOD(e1,y).  {@link ModFunctionModifier} will be
 * constructed without specifying a function name or a supported type list.
 *
 * @throws Exception
 */
public void testOneIntElemOneIntConst() throws Exception {
    Expression[] args = new Expression[] { // $NON-NLS-1$
    LANG_FACTORY.createColumnReference("e1", null, null, Integer.class), LANG_FACTORY.createLiteral(new Integer(6), Integer.class) };
    // $NON-NLS-1$
    helpTestMod(args, "MOD(e1, 6)");
}
Also used : BigInteger(java.math.BigInteger) Expression(org.teiid.language.Expression)

Example 35 with Expression

use of org.teiid.language.Expression in project teiid by teiid.

the class TestModFunctionModifier method testTwoIntConst5.

/**
 * Test {@link ModFunctionModifier#modify(Function)} to validate a call to
 * x % y using {@link Integer} constants for both parameters returns (x % y).
 * {@link ModFunctionModifier} will be constructed with a function name of
 * "%" and no supported type list.
 *
 * @throws Exception
 */
public void testTwoIntConst5() throws Exception {
    Expression[] args = new Expression[] { LANG_FACTORY.createLiteral(new Integer(10), Integer.class), LANG_FACTORY.createLiteral(new Integer(6), Integer.class) };
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTestMod("%", args, "(10 % 6)");
}
Also used : BigInteger(java.math.BigInteger) Expression(org.teiid.language.Expression)

Aggregations

Expression (org.teiid.language.Expression)61 ArrayList (java.util.ArrayList)18 ExpressionValueSource (org.teiid.language.ExpressionValueSource)18 Literal (org.teiid.language.Literal)17 TranslatorException (org.teiid.translator.TranslatorException)16 ColumnReference (org.teiid.language.ColumnReference)14 Function (org.teiid.language.Function)13 Column (org.teiid.metadata.Column)12 Insert (org.teiid.language.Insert)11 List (java.util.List)10 Table (org.teiid.metadata.Table)9 BigInteger (java.math.BigInteger)7 Test (org.junit.Test)7 Parameter (org.teiid.language.Parameter)7 Iterator (java.util.Iterator)5 Comparison (org.teiid.language.Comparison)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 FakeExecutionContextImpl (org.teiid.dqp.internal.datamgr.FakeExecutionContextImpl)4 NamedTable (org.teiid.language.NamedTable)4