use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestQueryRewriter method helpTestRewriteCriteria.
private Criteria helpTestRewriteCriteria(String original, Criteria expectedCrit, QueryMetadataInterface metadata) {
Criteria origCrit = parseCriteria(original, metadata);
Criteria actual = null;
// rewrite
try {
ArrayList<Boolean> booleanVals = new ArrayList<Boolean>(tuples.size());
for (List<?> tuple : tuples) {
booleanVals.add(new Evaluator(elements, null, null).evaluate(origCrit, tuple));
}
actual = QueryRewriter.rewriteCriteria(origCrit, null, metadata);
// $NON-NLS-1$
assertEquals("Did not rewrite correctly: ", expectedCrit, actual);
for (int i = 0; i < tuples.size(); i++) {
assertEquals(tuples.get(i).toString(), booleanVals.get(i), new Evaluator(elements, null, null).evaluate(actual, tuples.get(i)));
}
} catch (TeiidException e) {
throw new RuntimeException(e);
}
return actual;
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestQueryRewriter method testRewriteCrit_invalidParseDate.
@Ignore(value = "Should be moved to the validator")
@Test
public void testRewriteCrit_invalidParseDate() {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
// $NON-NLS-1$
Criteria origCrit = parseCriteria("PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", metadata);
try {
QueryRewriter.rewriteCriteria(origCrit, null, null);
// $NON-NLS-1$
fail("Expected failure");
} catch (TeiidException e) {
// $NON-NLS-1$
assertEquals("Error Code:ERR.015.001.0003 Message:Error simplifying criteria: PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", e.getMessage());
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class DataTierManagerImpl method getColumns.
private List<ElementSymbol> getColumns(TransformationMetadata tm, String name) {
GroupSymbol gs = new GroupSymbol(name);
try {
ResolverUtil.resolveGroup(gs, tm);
List<ElementSymbol> columns = ResolverUtil.resolveElementsInGroup(gs, tm);
return columns;
} catch (TeiidException e) {
throw new TeiidRuntimeException(e);
}
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class CachedFinder method findCapabilities.
/**
* Find capabilities used the cache if possible, otherwise do the lookup.
*/
public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
SourceCapabilities caps = userCache.get(modelName);
if (caps != null) {
return caps;
}
ModelMetaData model = vdb.getModel(modelName);
List<String> sourceNames = model.getSourceNames();
if (sourceNames.isEmpty()) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30499, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30499, modelName));
}
TeiidException cause = null;
for (String sourceName : sourceNames) {
// TOOD: in multi-source mode it may be necessary to compute minimal capabilities across the sources
ConnectorManager mgr = this.connectorRepo.getConnectorManager(sourceName);
if (mgr == null) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30497, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30497, sourceName, modelName, sourceName));
}
try {
caps = mgr.getCapabilities();
break;
} catch (TeiidException e) {
cause = e;
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_DQP, e, "Could not obtain capabilities for" + sourceName);
}
}
if (caps == null) {
InvalidCaps ic = new InvalidCaps();
ic.setSourceProperty(Capability.INVALID_EXCEPTION, cause);
caps = ic;
}
userCache.put(modelName, caps);
return caps;
}
use of org.teiid.core.TeiidException in project teiid by teiid.
the class TestProcessor method sampleDataBQT1.
private void sampleDataBQT1(FakeDataManager dataMgr) {
QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
try {
// Group bqt1.smalla
List[] tuples = new List[20];
for (int i = 0; i < tuples.length; i++) {
tuples[i] = new ArrayList(17);
tuples[i].add(new Integer(i));
for (int j = 0; j < 16; j++) {
tuples[i].add(null);
}
}
// $NON-NLS-1$
dataMgr.registerTuples(metadata, "bqt1.smalla", tuples);
// Group bqt2.mediumb
tuples = new List[20];
for (int i = 0; i < tuples.length; i++) {
tuples[i] = new ArrayList(17);
tuples[i].add(new Integer(i));
for (int j = 0; j < 16; j++) {
tuples[i].add(null);
}
}
// $NON-NLS-1$
dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples);
} catch (TeiidException e) {
throw new RuntimeException(e);
}
}
Aggregations