use of org.teiid.language.DerivedColumn in project teiid by teiid.
the class HsqlExecutionFactory method translateCommand.
@Override
public List<?> translateCommand(Command command, ExecutionContext context) {
if (command instanceof Select) {
Select select = (Select) command;
if (select.getFrom() == null || select.getFrom().isEmpty()) {
List<Object> result = new ArrayList<Object>();
// $NON-NLS-1$
result.add("VALUES(");
for (int i = 0; i < select.getDerivedColumns().size(); i++) {
DerivedColumn dc = select.getDerivedColumns().get(i);
if (i != 0) {
// $NON-NLS-1$
result.add(", ");
}
result.add(dc.getExpression());
}
// $NON-NLS-1$
result.add(")");
return result;
}
}
return super.translateCommand(command, context);
}
use of org.teiid.language.DerivedColumn in project teiid by teiid.
the class TestQueryImpl method testGetSelectSymbols.
public void testGetSelectSymbols() throws Exception {
List symbols = example(false).getDerivedColumns();
assertNotNull(symbols);
assertEquals(4, symbols.size());
for (Iterator i = symbols.iterator(); i.hasNext(); ) {
assertTrue(i.next() instanceof DerivedColumn);
}
}
use of org.teiid.language.DerivedColumn in project teiid by teiid.
the class TestSelectSymbolImpl method testGetColumnDataTypes.
public void testGetColumnDataTypes() {
Class<?>[] expectedResults = new Class[2];
List<DerivedColumn> symbols = new ArrayList<DerivedColumn>();
// $NON-NLS-1$//$NON-NLS-2$
symbols.add(new DerivedColumn("c1", new Literal("3", DataTypeManager.DefaultDataClasses.STRING)));
expectedResults[0] = DataTypeManager.DefaultDataClasses.STRING;
// $NON-NLS-1$
symbols.add(new DerivedColumn("c2", new Literal(new Integer(5), DataTypeManager.DefaultDataClasses.INTEGER)));
expectedResults[1] = DataTypeManager.DefaultDataClasses.INTEGER;
Select query = new Select(symbols, false, null, null, null, null, null);
Class<?>[] results = query.getColumnTypes();
assertEquals(results[0], expectedResults[0]);
assertEquals(results[1], expectedResults[1]);
}
use of org.teiid.language.DerivedColumn in project teiid by teiid.
the class TestMetadataObject method getElementID.
// ################ TEST ELEMENT METADATAID ######################
public Column getElementID(String groupName, String elementName, TranslationUtility transUtil) {
// $NON-NLS-1$ //$NON-NLS-2$
Select query = (Select) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName);
DerivedColumn symbol = query.getDerivedColumns().get(0);
ColumnReference element = (ColumnReference) symbol.getExpression();
return element.getMetadataObject();
}
Aggregations