use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testCacheMultipleComments.
@Test
public void testCacheMultipleComments() {
// $NON-NLS-1$
String sql = "/* hello */ /*+ cache */ /* world */ SELECT * FROM t1";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
UnaryFromClause ufc = new UnaryFromClause();
from.addClause(ufc);
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t1"));
query.setFrom(from);
query.setCacheHint(new CacheHint());
// $NON-NLS-1$
TestParser.helpTest(sql, "/*+ cache */ SELECT * FROM t1", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause1_3.
@Test
public void testOptionalFromClause1_3() {
// $NON-NLS-1$
String sql = "SELECT * FROM /*+ optional */ t1, t2";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
UnaryFromClause ufc = new UnaryFromClause();
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t1"));
ufc.setOptional(true);
from.addClause(ufc);
// $NON-NLS-1$
from.addGroup(new GroupSymbol("t2"));
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT * FROM /*+ optional */ t1, t2", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause2.
@Test
public void testOptionalFromClause2() {
// $NON-NLS-1$
String sql = "SELECT * FROM t1, /*+ optional */ t2";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
// $NON-NLS-1$
from.addGroup(new GroupSymbol("t1"));
UnaryFromClause ufc = new UnaryFromClause();
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t2"));
ufc.setOptional(true);
from.addClause(ufc);
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT * FROM t1, /*+ optional */ t2", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestSetQueryParsing method createTestQuery.
private Query createTestQuery(String group) {
GroupSymbol g = new GroupSymbol(group);
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
Query query1 = new Query();
query1.setSelect(select);
query1.setFrom(from);
return query1;
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class CommandBuilder method expandAllSymbol.
/**
* Convert the "*" in "select * from..." to the list of column names for the data source.
*/
protected void expandAllSymbol(Command command) {
if (command instanceof Query) {
Query query = (Query) command;
Select select = query.getSelect();
List<Expression> originalSymbols = select.getSymbols();
List<Expression> expandedSymbols = new ArrayList<Expression>();
for (Iterator<Expression> i = originalSymbols.iterator(); i.hasNext(); ) {
Expression next = i.next();
if (next instanceof MultipleElementSymbol) {
MultipleElementSymbol allSymbol = (MultipleElementSymbol) next;
expandedSymbols.addAll(allSymbol.getElementSymbols());
} else {
expandedSymbols.add(next);
}
}
select.setSymbols(expandedSymbols);
}
}
Aggregations