Search in sources :

Example 11 with AggregateSymbol

use of org.teiid.query.sql.symbol.AggregateSymbol in project teiid by teiid.

the class TestAggregateSymbol method testEquivalenceCaseInsens.

public void testEquivalenceCaseInsens() {
    // $NON-NLS-1$
    AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement());
    // $NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement());
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
Also used : AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol)

Example 12 with AggregateSymbol

use of org.teiid.query.sql.symbol.AggregateSymbol in project teiid by teiid.

the class TestAggregateSymbol method testNonEquivalenceUsingDiffElements.

public void testNonEquivalenceUsingDiffElements() {
    // $NON-NLS-1$
    AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement());
    // $NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2());
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
Also used : AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol)

Example 13 with AggregateSymbol

use of org.teiid.query.sql.symbol.AggregateSymbol in project teiid by teiid.

the class TestAggregateSymbol method testNonEquivalence1.

public void testNonEquivalence1() {
    // $NON-NLS-1$
    AggregateSymbol test1 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement());
    // $NON-NLS-1$
    AggregateSymbol test2 = new AggregateSymbol(NonReserved.COUNT, true, sampleElement2());
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, test1, test2);
}
Also used : AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol)

Example 14 with AggregateSymbol

use of org.teiid.query.sql.symbol.AggregateSymbol in project teiid by teiid.

the class TestAggregateSymbol method testSelfEquivalence.

public void testSelfEquivalence() {
    // $NON-NLS-1$
    AggregateSymbol test = new AggregateSymbol(NonReserved.COUNT, true, sampleElement());
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, test, test);
}
Also used : AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol)

Example 15 with AggregateSymbol

use of org.teiid.query.sql.symbol.AggregateSymbol in project teiid by teiid.

the class TestGroupingNode method testDefect5769.

@Test
public void testDefect5769() throws Exception {
    BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
    // $NON-NLS-1$
    ElementSymbol bigDecimal = new ElementSymbol("value");
    bigDecimal.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
    // Set up
    GroupingNode node = new GroupingNode(1);
    List outputElements = new ArrayList();
    // $NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("SUM", false, bigDecimal));
    // $NON-NLS-1$ //$NON-NLS-2$
    outputElements.add(new AggregateSymbol("AVG", false, bigDecimal));
    node.setElements(outputElements);
    // $NON-NLS-1$ //$NON-NLS-2$
    CommandContext context = new CommandContext("pid", "test", null, null, 1);
    List[] data = new List[] { // $NON-NLS-1$
    Arrays.asList(new Object[] { new BigDecimal("0.0") }), // $NON-NLS-1$
    Arrays.asList(new Object[] { new BigDecimal("1.0") }), // $NON-NLS-1$
    Arrays.asList(new Object[] { new BigDecimal("2.0") }), // $NON-NLS-1$
    Arrays.asList(new Object[] { new BigDecimal("3.0") }), // $NON-NLS-1$
    Arrays.asList(new Object[] { new BigDecimal("4.0") }) };
    List[] expected = new List[] { // $NON-NLS-1$ //$NON-NLS-2$
    Arrays.asList(new Object[] { new BigDecimal("10.0"), new BigDecimal("2.0") }) };
    List symbols = new ArrayList();
    symbols.add(bigDecimal);
    FakeTupleSource dataSource = new FakeTupleSource(symbols, data);
    helpProcess(mgr, node, context, expected, dataSource, null);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol) CommandContext(org.teiid.query.util.CommandContext) ArrayList(java.util.ArrayList) FakeTupleSource(org.teiid.query.processor.FakeTupleSource) ArrayList(java.util.ArrayList) List(java.util.List) BufferManager(org.teiid.common.buffer.BufferManager) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)53 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)27 Test (org.junit.Test)21 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)16 ArrayList (java.util.ArrayList)12 List (java.util.List)11 Expression (org.teiid.query.sql.symbol.Expression)9 OrderBy (org.teiid.query.sql.lang.OrderBy)8 CommandContext (org.teiid.query.util.CommandContext)6 BufferManager (org.teiid.common.buffer.BufferManager)5 SymbolMap (org.teiid.query.sql.util.SymbolMap)5 BigDecimal (java.math.BigDecimal)4 FakeTupleSource (org.teiid.query.processor.FakeTupleSource)4 Constant (org.teiid.query.sql.symbol.Constant)4 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)3 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)3 AliasSymbol (org.teiid.query.sql.symbol.AliasSymbol)3 ExpressionSymbol (org.teiid.query.sql.symbol.ExpressionSymbol)3 Map (java.util.Map)2 AggregateFunction (org.teiid.query.function.aggregate.AggregateFunction)2