use of org.teiid.query.sql.symbol.AliasSymbol in project teiid by teiid.
the class TestAliasSymbol method testAliasEquals.
@Test
public void testAliasEquals() {
// $NON-NLS-1$ //$NON-NLS-2$
AliasSymbol a1 = new AliasSymbol("X", new ExpressionSymbol("x", new Constant(1)));
// $NON-NLS-1$ //$NON-NLS-2$
AliasSymbol a2 = new AliasSymbol("X", new ExpressionSymbol("x", new Constant(2)));
// $NON-NLS-1$ //$NON-NLS-2$
AliasSymbol a3 = new AliasSymbol("x", new ExpressionSymbol("x", new Constant(1)));
// just a different case for the alias
assertFalse(a1.equals(a3));
// different express
assertFalse(a1.equals(a2));
}
use of org.teiid.query.sql.symbol.AliasSymbol in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitAliasSymbol.
public void testVisitAliasSymbol() {
// $NON-NLS-1$
AliasSymbol as = new AliasSymbol("abc", exampleElement(true, 0));
helpTest(as, getSymbolMap());
}
use of org.teiid.query.sql.symbol.AliasSymbol in project teiid by teiid.
the class TestStaticSymbolMappingVisitor method testVisitOrderBy.
public void testVisitOrderBy() {
OrderBy ob = new OrderBy();
ob.addVariable(exampleElement(true, 0));
ob.addVariable(exampleElement(true, 1));
// $NON-NLS-1$
ob.addVariable(new AliasSymbol("abc", exampleElement(true, 2)));
helpTest(ob, getSymbolMap());
}
use of org.teiid.query.sql.symbol.AliasSymbol in project teiid by teiid.
the class QueryResults method createColumnInfos.
/**
* Convert a list of SingleElementSymbols to a List of ColumnInfo objects.
*
* @param symbols
* List of SingleElementSymbols
* @return List of ColumnInfos
*/
public static List createColumnInfos(List symbols) {
List infos = new ArrayList(symbols.size());
Iterator iter = symbols.iterator();
while (iter.hasNext()) {
Expression symbol = (Expression) iter.next();
String name = Symbol.getName(symbol);
if (symbol instanceof AliasSymbol) {
AliasSymbol alias = (AliasSymbol) symbol;
symbol = alias.getSymbol();
}
if (symbol instanceof ElementSymbol) {
ElementSymbol element = (ElementSymbol) symbol;
GroupSymbol group = element.getGroupSymbol();
Object groupID = null;
if (group != null) {
groupID = group.getMetadataID();
}
infos.add(new ColumnInfo(name, DataTypeManager.getDataTypeName(element.getType()), element.getType(), groupID, element.getMetadataID()));
} else {
// ExpressionSymbol or AggregateSymbol
// Expressions don't map to a single element or group, so don't save that info
infos.add(new ColumnInfo(name, DataTypeManager.getDataTypeName(symbol.getType()), symbol.getType()));
}
}
return infos;
}
Aggregations