use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class MaterializationManager method executeQuery.
public List<Map<String, String>> executeQuery(VDBMetaData vdb, String command) throws SQLException {
final List<Map<String, String>> rows = new ArrayList<Map<String, String>>();
try {
Future<?> f = DQPCore.executeQuery(command, vdb, "embedded-async", "internal", -1, getDQP(), new // $NON-NLS-1$ //$NON-NLS-2$
DQPCore.ResultsListener() {
@Override
public void onResults(List<String> columns, List<? extends List<?>> results) throws Exception {
for (List<?> row : results) {
TreeMap<String, String> rowResult = new TreeMap<String, String>();
for (int colNum = 0; colNum < columns.size(); colNum++) {
Object value = row.get(colNum);
if (value != null) {
if (value instanceof Timestamp) {
value = ((Timestamp) value).getTime();
}
}
rowResult.put(columns.get(colNum), value == null ? null : value.toString());
}
rows.add(rowResult);
}
}
});
f.get();
} catch (InterruptedException e) {
// break
throw new TeiidRuntimeException(e);
} catch (ExecutionException e) {
if (e.getCause() != null) {
throw new SQLException(e.getCause());
}
throw new SQLException(e);
} catch (Throwable e) {
throw new SQLException(e);
}
return rows;
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class SocketListener method stop.
/**
* Stops the {@link SocketListener}
* @return a Future if the transport was started successfully
* that can notify of successfully killing all clients
*/
public Future<?> stop() {
ChannelFuture future = this.serverChannel.closeFuture();
Future<?> shutdown = null;
if (this.bootstrap != null) {
shutdown = bootstrap.group().shutdownGracefully(0, 0, TimeUnit.SECONDS);
bootstrap = null;
}
try {
future.await();
} catch (InterruptedException e) {
throw new TeiidRuntimeException(e);
}
return shutdown;
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class PISQLConversionVisitor method visit.
@Override
public void visit(Join obj) {
TableReference leftItem = obj.getLeftItem();
TableReference rightItem = obj.getRightItem();
JoinType joinType = obj.getJoinType();
boolean ignoreOnClause = false;
Condition condition = obj.getCondition();
if (useParensForJoins() && leftItem instanceof Join) {
buffer.append(Tokens.LPAREN);
append(leftItem);
buffer.append(Tokens.RPAREN);
} else {
append(leftItem);
}
buffer.append(Tokens.SPACE);
switch(joinType) {
case CROSS_JOIN:
if (hasLateralJoin(rightItem)) {
if (!isTVF(rightItem)) {
throw new TeiidRuntimeException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11025, rightItem));
}
buffer.append(CROSS).append(Tokens.SPACE).append(APPLY).append(Tokens.SPACE);
ignoreOnClause = true;
} else {
// "a cross join b" is the same as "a inner join b on (1 = 1)"
buffer.append(INNER).append(Tokens.SPACE).append(JOIN).append(Tokens.SPACE);
Literal e1 = LanguageFactory.INSTANCE.createLiteral(new Integer(1), Integer.class);
Comparison criteria = new Comparison(e1, e1, Operator.EQ);
condition = criteria;
}
break;
case FULL_OUTER_JOIN:
// should not get here as capabilities are turned off.
throw new TeiidRuntimeException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11024, "FULL OUTER"));
case INNER_JOIN:
buffer.append(INNER).append(Tokens.SPACE).append(JOIN).append(Tokens.SPACE);
break;
case LEFT_OUTER_JOIN:
if (!hasLateralJoin(leftItem) && !hasLateralJoin(rightItem)) {
buffer.append(LEFT).append(Tokens.SPACE).append(OUTER).append(Tokens.SPACE).append(JOIN).append(Tokens.SPACE);
} else if (hasLateralJoin(leftItem)) {
throw new TeiidRuntimeException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11024, "RIGHT OUTER APPLY"));
} else if (hasLateralJoin(rightItem)) {
if (!isTVF(rightItem)) {
throw new TeiidRuntimeException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11025, rightItem));
}
buffer.append(OUTER).append(Tokens.SPACE).append(APPLY).append(Tokens.SPACE);
ignoreOnClause = true;
}
break;
case RIGHT_OUTER_JOIN:
// right outer is never pushed, so we should probably never get here.
throw new TeiidRuntimeException(JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11024, "RIGHT OUTER"));
default:
buffer.append(UNDEFINED);
}
if (rightItem instanceof Join && (useParensForJoins() || obj.getJoinType() == Join.JoinType.CROSS_JOIN)) {
buffer.append(Tokens.LPAREN);
append(hasLateralJoin(rightItem) ? unwrap(rightItem) : rightItem);
buffer.append(Tokens.RPAREN);
} else {
append(hasLateralJoin(rightItem) ? unwrap(rightItem) : rightItem);
}
if (condition != null && !ignoreOnClause) {
buffer.append(Tokens.SPACE).append(ON).append(Tokens.SPACE);
append(condition);
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class TranslationHelper method loadUDFs.
public static void loadUDFs(String udf, TranslationUtility util) {
try {
Collection<FunctionMethod> methods = FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
// $NON-NLS-1$
util.addUDF("foo", methods);
} catch (IOException e) {
// $NON-NLS-1$
throw new TeiidRuntimeException("failed to load UDF");
} catch (XMLStreamException e) {
// $NON-NLS-1$
throw new TeiidRuntimeException("failed to load UDF");
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class ODataEntitySchemaBuilder method buildMetadata.
static EdmDataServices buildMetadata(MetadataStore metadataStore) {
try {
List<EdmSchema.Builder> edmSchemas = new ArrayList<EdmSchema.Builder>();
for (Schema schema : metadataStore.getSchemaList()) {
buildEntityTypes(schema, edmSchemas, true);
buildFunctionImports(schema, edmSchemas, true);
buildAssosiationSets(schema, edmSchemas, true);
}
return EdmDataServices.newBuilder().addSchemas(edmSchemas).build();
} catch (Exception e) {
throw new TeiidRuntimeException(e);
}
}
Aggregations