use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestOrderByRewrite method helpCheckElements.
private void helpCheckElements(OrderBy langObj, String[] elementNames, String[] elementIDs) {
List<ElementSymbol> elements = new ArrayList<ElementSymbol>();
for (Iterator<Expression> i = langObj.getSortKeys().iterator(); i.hasNext(); ) {
ElementCollectorVisitor.getElements(i.next(), elements);
}
// $NON-NLS-1$
assertEquals("Wrong number of elements: ", elementNames.length, elements.size());
for (int i = 0; i < elements.size(); i++) {
ElementSymbol symbol = elements.get(i);
// $NON-NLS-1$
assertEquals("Element name does not match: ", elementNames[i].toUpperCase(), symbol.getName().toUpperCase());
Column elementID = (Column) symbol.getMetadataID();
// $NON-NLS-1$ //$NON-NLS-2$
assertNotNull("ElementSymbol " + symbol + " was not resolved and has no metadataID", elementID);
// $NON-NLS-1$
assertEquals("ElementID name does not match: ", elementIDs[i].toUpperCase(), elementID.getFullName().toUpperCase());
}
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestProcedureResolving method testVarArgs2.
@Test
public void testVarArgs2() throws Exception {
String ddl = "create foreign procedure proc (VARIADIC z object) returns (x string);\n";
TransformationMetadata tm = createMetadata(ddl);
// $NON-NLS-1$
String sql = "call proc ()";
StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals("EXEC proc()", sp.toString());
assertEquals(new Array(DataTypeManager.DefaultDataClasses.OBJECT, new ArrayList<Expression>(0)), sp.getParameter(1).getExpression());
// $NON-NLS-1$
sql = "call proc (1, (2, 3))";
sp = (StoredProcedure) TestResolver.helpResolve(sql, tm);
assertEquals("EXEC proc(1, (2, 3))", sp.toString());
ArrayList<Expression> expressions = new ArrayList<Expression>();
expressions.add(new Constant(1));
expressions.add(new Array(DataTypeManager.DefaultDataClasses.INTEGER, Arrays.asList((Expression) new Constant(2), new Constant(3))));
assertEquals(new Array(DataTypeManager.DefaultDataClasses.OBJECT, expressions), sp.getParameter(1).getExpression());
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class SetQuery method getTypedProjectedSymbols.
public static List<Expression> getTypedProjectedSymbols(List<? extends Expression> acutal, List<Class<?>> projectedTypes, QueryMetadataInterface metadata) {
List<Expression> newProject = new ArrayList<Expression>();
for (int i = 0; i < acutal.size(); i++) {
Expression originalSymbol = acutal.get(i);
Expression symbol = originalSymbol;
Class<?> type = projectedTypes.get(i);
if (symbol.getType() != type) {
symbol = SymbolMap.getExpression(originalSymbol);
try {
symbol = ResolverUtil.convertExpression(symbol, DataTypeManager.getDataTypeName(type), metadata);
} catch (QueryResolverException err) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30447, err);
}
if (originalSymbol instanceof Symbol) {
symbol = new AliasSymbol(Symbol.getShortName(originalSymbol), symbol);
}
}
newProject.add(symbol);
}
return newProject;
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class SubqueryCompareCriteria method clone.
/**
* Deep copy of object. The values Iterator of this object
* will not be cloned - it will be null in the new object
* (see #setValueIterator setValueIterator}).
* @return Deep copy of object
* @see java.lang.Object#clone()
*/
public Object clone() {
Expression leftCopy = null;
if (getLeftExpression() != null) {
leftCopy = (Expression) getLeftExpression().clone();
}
QueryCommand copyCommand = null;
if (getCommand() != null) {
copyCommand = (QueryCommand) getCommand().clone();
}
SubqueryCompareCriteria copy = new SubqueryCompareCriteria(leftCopy, copyCommand, this.getOperator(), this.getPredicateQuantifier());
if (this.subqueryHint != null) {
copy.subqueryHint = this.subqueryHint.clone();
}
if (this.arrayExpression != null) {
copy.arrayExpression = (Expression) this.arrayExpression.clone();
}
return copy;
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class Command method getUpdateCommandSymbol.
public static List<Expression> getUpdateCommandSymbol() {
if (updateCommandSymbol == null) {
// $NON-NLS-1$
ElementSymbol symbol = new ElementSymbol("Count");
symbol.setType(DataTypeManager.DefaultDataClasses.INTEGER);
updateCommandSymbol = Arrays.asList((Expression) symbol);
}
return updateCommandSymbol;
}
Aggregations