Search in sources :

Example 16 with AliasSymbol

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));
}
Also used : AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) Constant(org.teiid.query.sql.symbol.Constant) ExpressionSymbol(org.teiid.query.sql.symbol.ExpressionSymbol) Test(org.junit.Test)

Example 17 with AliasSymbol

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());
}
Also used : AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol)

Example 18 with AliasSymbol

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());
}
Also used : OrderBy(org.teiid.query.sql.lang.OrderBy) AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol)

Example 19 with AliasSymbol

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;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) Expression(org.teiid.query.sql.symbol.Expression) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AliasSymbol (org.teiid.query.sql.symbol.AliasSymbol)19 Expression (org.teiid.query.sql.symbol.Expression)12 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)9 ArrayList (java.util.ArrayList)7 ExpressionSymbol (org.teiid.query.sql.symbol.ExpressionSymbol)5 List (java.util.List)3 Map (java.util.Map)3 OrderBy (org.teiid.query.sql.lang.OrderBy)3 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)3 Constant (org.teiid.query.sql.symbol.Constant)3 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)3 SymbolMap (org.teiid.query.sql.util.SymbolMap)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Test (org.junit.Test)2 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)2 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)2 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)2 Reference (org.teiid.query.sql.symbol.Reference)2