use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestProjectNode method testProjectExpressionFunctionFails.
@Test
public void testProjectExpressionFunctionFails() throws Exception {
// $NON-NLS-1$
ElementSymbol es1 = new ElementSymbol("e1");
es1.setType(DataTypeManager.DefaultDataClasses.STRING);
List elements = new ArrayList();
elements.add(es1);
// $NON-NLS-1$ //$NON-NLS-2$
Function func = new Function("convert", new Expression[] { es1, new Constant("integer") });
// $NON-NLS-1$
FunctionDescriptor fd = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("convert", new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
// $NON-NLS-1$
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
List projectElements = new ArrayList();
projectElements.add(expr);
List[] data = new List[] { // $NON-NLS-1$
Arrays.asList(new Object[] { "1" }), // $NON-NLS-1$
Arrays.asList(new Object[] { "2x" }) };
// $NON-NLS-1$
String expectedMessage = "TEIID30328 UNABLE TO EVALUATE CONVERT(E1, INTEGER): TEIID30384 ERROR WHILE EVALUATING FUNCTION CONVERT";
helpTestProjectFails(projectElements, data, elements, expectedMessage);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestSelectNode method testTimeslicing.
@Test
public void testTimeslicing() 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(es1, CompareCriteria.EQ, new Constant(new Integer(1)));
List[] data = new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) };
List childElements = new ArrayList();
childElements.add(es1);
helpTestSelect(elements, crit, childElements, null, data, new FakeRelationalNode(2, data), new SelectNode(3) {
int i = 0;
@Override
protected Evaluator getEvaluator(Map elementMap) {
return new Evaluator(elementMap, getDataManager(), getContext()) {
@Override
public Boolean evaluateTVL(Criteria criteria, List<?> tuple) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
if (i++ == 1) {
throw new QueryProcessor.ExpiredTimeSliceException();
}
return super.evaluateTVL(criteria, tuple);
}
};
}
});
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestFrameUtil method getExamplePlan.
/**
* <pre>
* Join(groups=[3, 2, 1])
* Null(groups=[1])
* Select(groups=[2])
* Join(groups=[3, 2])
* Source(groups=[3])
* Access(groups=[2])
* </pre>
*/
public static PlanNode getExamplePlan() {
PlanNode joinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
joinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS);
joinNode.addGroup(getGroup(1));
joinNode.addGroup(getGroup(2));
joinNode.addGroup(getGroup(3));
PlanNode nullNode = NodeFactory.getNewNode(NodeConstants.Types.NULL);
nullNode.addGroup(getGroup(1));
joinNode.addFirstChild(nullNode);
PlanNode childCriteria = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
childCriteria.setProperty(Info.SELECT_CRITERIA, new IsNullCriteria(new Constant(1)));
childCriteria.addGroup(getGroup(2));
joinNode.addLastChild(childCriteria);
PlanNode childJoinNode = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
childJoinNode.setProperty(NodeConstants.Info.JOIN_TYPE, JoinType.JOIN_CROSS);
childJoinNode.addGroup(getGroup(2));
childJoinNode.addGroup(getGroup(3));
childCriteria.addFirstChild(childJoinNode);
PlanNode accessNode = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
accessNode.addGroup(getGroup(2));
childJoinNode.addFirstChild(accessNode);
PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
sourceNode.addGroup(getGroup(3));
childJoinNode.addFirstChild(sourceNode);
return joinNode;
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithKeyMatchCrit.
/**
* Tests SetCriteria in the atomic criteria
*/
@Test
public void testCardinalityWithKeyMatchCrit() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e2 = getElementSymbol(1, 2, 2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
CompareCriteria crit2 = new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2);
crits.add(crit2);
Criteria atomicCrit1 = null;
// $NON-NLS-1$
Criteria atomicCrit2 = new MatchCriteria(g2e1, new Constant(new String("ab%")));
int expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
use of org.teiid.query.sql.symbol.Constant in project teiid by teiid.
the class TestRuleChooseDependent method testCardinalityWithKeyCompoundCritAND.
/**
* Tests that join side with larger cardinality will still have a lower
* cost computed because it has a criteria including a primary key
*/
@Test
public void testCardinalityWithKeyCompoundCritAND() throws Exception {
// override default metadata
this.metadata = RealMetadataFactory.example4();
GroupSymbol group1 = getPhysicalGroup(1, 2);
ElementSymbol g1e2 = getElementSymbol(1, 2, 2);
GroupSymbol group2 = getPhysicalGroup(3, 3);
ElementSymbol g2e1 = getElementSymbol(3, 3, 1);
ElementSymbol g2e2 = getElementSymbol(3, 3, 2);
// Join criteria
ArrayList crits = new ArrayList(1);
crits.add(new CompareCriteria(g1e2, CompareCriteria.EQ, g2e2));
Criteria atomicCrit1 = null;
Criteria crit1 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(5)));
Criteria crit2 = new CompareCriteria(g2e1, CompareCriteria.EQ, new Constant(new Integer(7)));
CompoundCriteria atomicCrit2 = new CompoundCriteria(CompoundCriteria.AND, crit1, crit2);
int expected = LEFT_SIDE;
helpTestChooseSiblingAndMarkDependent(group1, atomicCrit1, group2, atomicCrit2, crits, expected);
expected = RIGHT_SIDE;
helpTestChooseSiblingAndMarkDependent(group2, atomicCrit2, group1, atomicCrit1, crits, expected);
}
Aggregations