use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestSelectNode method testEmptyBatchIndexing.
/**
* Ensures that a final empty batch is reindexed so that the batch iterator works correctly
*/
@Test
public void testEmptyBatchIndexing() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
List elements = new ArrayList();
elements.add(es1);
CompareCriteria crit = new CompareCriteria(new Constant(0), CompareCriteria.EQ, new Constant(new Integer(1)));
List childElements = new ArrayList();
childElements.add(es1);
RelationalNode child = new RelationalNode(0) {
int i = 0;
@Override
public Object clone() {
return null;
}
@Override
protected TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (i++ == 0) {
return new TupleBatch(1, new List[] { Arrays.asList(1), Arrays.asList(1) });
}
TupleBatch batch = new TupleBatch(3, new List[0]);
batch.setTerminationFlag(true);
return batch;
}
};
helpTestSelect(elements, crit, childElements, null, new List[0], child);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestSelectNode method testSelectWithLookup.
@Test
public void testSelectWithLookup() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// $NON-NLS-1$
ElementSymbol es2 = new ElementSymbol("e2");
es2.setType(DataTypeManager.DefaultDataClasses.STRING);
List elements = new ArrayList();
elements.add(es1);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Function func = new Function("lookup", new Expression[] { new Constant("pm1.g1"), new Constant("e2"), new Constant("e1"), es1 });
// $NON-NLS-1$
FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new Class[] { String.class, String.class, String.class, Integer.class });
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria crit = new CompareCriteria(func, CompareCriteria.EQ, new Constant(new Integer(1)));
List[] data = new List[20];
for (int i = 0; i < 20; i++) {
data[i] = new ArrayList();
data[i].add(new Integer((i * 51) % 11));
// $NON-NLS-1$
String str = "" + (i * 3);
str = str.substring(0, 1);
data[i].add(str);
}
List childElements = new ArrayList();
childElements.add(es1);
childElements.add(es2);
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(0) }), Arrays.asList(new Object[] { new Integer(0) }) };
FakeDataManager dataMgr = new FakeDataManager();
dataMgr.setThrowBlocked(true);
Map valueMap = new HashMap();
valueMap.put(new Integer(0), new Integer(1));
valueMap.put(new Integer(1), new Integer(2));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
dataMgr.defineCodeTable("pm1.g1", "e1", "e2", valueMap);
helpTestSelect(elements, crit, data, childElements, dataMgr, expected);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestSelectNode method testSimpleSelect.
@Test
public void testSimpleSelect() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// $NON-NLS-1$
ElementSymbol es2 = new ElementSymbol("e2");
es2.setType(DataTypeManager.DefaultDataClasses.STRING);
List elements = new ArrayList();
elements.add(es1);
CompareCriteria crit = new CompareCriteria(es1, CompareCriteria.EQ, new Constant(new Integer(1)));
List[] data = new List[20];
for (int i = 0; i < 20; i++) {
data[i] = new ArrayList();
data[i].add(new Integer((i * 51) % 11));
// $NON-NLS-1$
String str = "" + (i * 3);
str = str.substring(0, 1);
data[i].add(str);
}
List childElements = new ArrayList();
childElements.add(es1);
childElements.add(es2);
List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1) }), Arrays.asList(new Object[] { new Integer(1) }) };
helpTestSelect(elements, crit, data, childElements, null, expected);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestSelectNode method testNoRows.
@Test
public void testNoRows() throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// $NON-NLS-1$
ElementSymbol es2 = new ElementSymbol("e2");
es2.setType(DataTypeManager.DefaultDataClasses.STRING);
List elements = new ArrayList();
elements.add(es1);
List[] data = new List[0];
CompareCriteria crit = new CompareCriteria(es1, CompareCriteria.EQ, new Constant(new Integer(1)));
List childElements = new ArrayList();
childElements.add(es1);
childElements.add(es2);
helpTestSelect(elements, crit, data, childElements, null, data);
}
use of org.teiid.query.sql.lang.CompareCriteria in project teiid by teiid.
the class TestCompoundCriteria method testClone1.
public void testClone1() {
// $NON-NLS-1$
ElementSymbol e1 = new ElementSymbol("e1");
// $NON-NLS-1$
CompareCriteria ccrit1 = new CompareCriteria(e1, CompareCriteria.EQ, new Constant("abc"));
// $NON-NLS-1$
ElementSymbol e2 = new ElementSymbol("e2");
// $NON-NLS-1$
CompareCriteria ccrit2 = new CompareCriteria(e2, CompareCriteria.EQ, new Constant("xyz"));
CompoundCriteria comp = new CompoundCriteria(CompoundCriteria.AND, ccrit1, ccrit2);
UnitTestUtil.helpTestEquivalence(0, comp, comp.clone());
}
Aggregations