public void close() throws IOException { try { dqp.closeLobChunkStream(streamRequestId, requestId, streamable.getReferenceStreamId()); } catch (TeiidException e) { IOException ex = new IOException(e.getMessage()); ex.initCause(e); throw ex; } } }
public void close() throws IOException { try { dqp.closeLobChunkStream(streamRequestId, requestId, streamable.getReferenceStreamId()); } catch (TeiidException e) { IOException ex = new IOException(e.getMessage()); ex.initCause(e); throw ex; } } }
private Throwable addCancelCode(Throwable exception) { String reason = null; synchronized (this) { reason = this.cancelReason; } if (exception instanceof TeiidException) { TeiidException te = (TeiidException)exception; if (SQLStates.QUERY_CANCELED.equals(te.getCode()) && EquivalenceUtil.areEqual(reason, te.getMessage())) { return exception; } } TeiidProcessingException tpe = new TeiidProcessingException(reason); tpe.initCause(exception); tpe.setCode(SQLStates.QUERY_CANCELED); return tpe; }
private Throwable addCancelCode(Throwable exception) { String reason = null; synchronized (this) { reason = this.cancelReason; } if (exception instanceof TeiidException) { TeiidException te = (TeiidException)exception; if (SQLStates.QUERY_CANCELED.equals(te.getCode()) && EquivalenceUtil.areEqual(reason, te.getMessage())) { return exception; } } TeiidProcessingException tpe = new TeiidProcessingException(reason); tpe.initCause(exception); tpe.setCode(SQLStates.QUERY_CANCELED); return tpe; }
private void helpTestProcessFailure(ProcessorPlan procPlan, FakeDataManager dataMgr, String failMessage, QueryMetadataInterface metadata) throws Exception { try { helpTestProcess(procPlan, null, dataMgr, metadata); } catch(TeiidException ex) { assertEquals(failMessage, ex.getMessage()); } }
@Test public void testSetCriteriaCastFromExpression_9657() { // parse Criteria actual = null; try { actual = QueryParser.getQueryParser().parseCriteria("bqt1.smalla.shortvalue IN (1, 2)"); //$NON-NLS-1$ } catch(TeiidException e) { fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } // resolve try { QueryResolver.resolveCriteria(actual, RealMetadataFactory.exampleBQTCached()); } catch(TeiidException e) { fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } assertEquals("Did not match expected criteria", ((SetCriteria)actual).getExpression().getType(), DataTypeManager.DefaultDataClasses.SHORT); //$NON-NLS-1$ }
private Criteria helpResolveCriteria(String sql) { Criteria criteria = null; // parse try { criteria = QueryParser.getQueryParser().parseCriteria(sql); } catch(TeiidException e) { fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } // resolve try { QueryResolver.resolveCriteria(criteria, metadata); } catch(TeiidException e) { e.printStackTrace(); fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } CheckSymbolsAreResolvedVisitor vis = new CheckSymbolsAreResolvedVisitor(); DeepPreOrderNavigator.doVisit(criteria, vis); Collection<LanguageObject> unresolvedSymbols = vis.getUnresolvedSymbols(); assertTrue("Found unresolved symbols: " + unresolvedSymbols, unresolvedSymbols.isEmpty()); //$NON-NLS-1$ return criteria; }
static void helpException(String sql, String expected){ try { QueryParser.getQueryParser().parseCommand(sql); fail("Expected exception for parsing " + sql); //$NON-NLS-1$ } catch(TeiidException e) { if (expected != null) { assertEquals(expected, e.getMessage()); } } }
@Override protected void afterCompletion(boolean success) throws TeiidComponentException { if (!success && upsertUndoLog != null) { upsertUndoLog.setFinal(true); TupleBufferTupleSource undoTs = upsertUndoLog.createIndexedTupleSource(); undoTs.setReverse(true); List<?> tuple = null; try { while ((tuple = undoTs.nextTuple()) != null) { try { updateTuple(tuple); } catch (TeiidException e) { LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage()); } } } catch (TeiidProcessingException e) { //shouldn't happen throw new TeiidComponentException(e); } } tree.setBatchInsert(false); }
@Test public void testEmptyAndNullInputsGiveSameErrorMessage() throws Exception { String emptyMessage = null; try { QueryParser.getQueryParser().parseCommand(""); //$NON-NLS-1$ fail("Expected exception for parsing empty string"); //$NON-NLS-1$ } catch(TeiidException e) { emptyMessage = e.getMessage(); } String nullMessage = null; try { QueryParser.getQueryParser().parseCommand(null); fail("Expected exception for parsing null string"); //$NON-NLS-1$ } catch(TeiidException e) { nullMessage = e.getMessage(); } assertTrue("Expected same message for empty and null cases", emptyMessage.equals(nullMessage)); //$NON-NLS-1$ }
@Override protected void afterCompletion(boolean success) throws TeiidComponentException { if (!success && upsertUndoLog != null) { upsertUndoLog.setFinal(true); TupleBufferTupleSource undoTs = upsertUndoLog.createIndexedTupleSource(); undoTs.setReverse(true); List<?> tuple = null; try { while ((tuple = undoTs.nextTuple()) != null) { try { updateTuple(tuple); } catch (TeiidException e) { LogManager.logError(LogConstants.CTX_DQP, e, e.getMessage()); } } } catch (TeiidProcessingException e) { //shouldn't happen throw new TeiidComponentException(e); } } tree.setBatchInsert(false); }
@Test public void testMetaMatrixExceptionWithMessage() { final TeiidException err = new TeiidException("Test"); //$NON-NLS-1$ assertNull(err.getCode()); assertEquals("Test", err.getMessage()); //$NON-NLS-1$ } public static enum Event implements BundleUtil.Event {
@Test public void testMetaMatrixExceptionWithCodeAndMessage() { final TeiidException err = new TeiidException(Event.Code, "Test"); //$NON-NLS-1$ assertEquals("Code", err.getCode()); //$NON-NLS-1$ assertEquals("Code Test", err.getMessage()); //$NON-NLS-1$ }
@Test public void testMetaMatrixExceptionWithNullThrowable() { final TeiidException err = new TeiidException((Throwable)null); assertNull(err.getCode()); assertNull(err.getMessage()); }
@Test public void testMetaMatrixExceptionWithExceptionAndMessage() { final TeiidException child = new TeiidException(Event.propertyValuePhrase, "Child"); //$NON-NLS-1$ final TeiidException err = new TeiidException(child, "Test"); //$NON-NLS-1$ assertEquals("propertyValuePhrase", err.getCode()); //$NON-NLS-1$ assertEquals("propertyValuePhrase Test", err.getMessage()); //$NON-NLS-1$ }
@Test public void testMetaMatrixExceptionWithExceptionAndCodeAndMessage() { final TeiidException child = new TeiidException(Event.propertyValuePhrase, "Child"); //$NON-NLS-1$ final TeiidException err = new TeiidException(Event.Code,child, "Test"); //$NON-NLS-1$ assertEquals("Code", err.getCode()); //$NON-NLS-1$ assertEquals("Code Test", err.getMessage()); //$NON-NLS-1$ } }
@Test public void testRewriteFunctionThrowsEvaluationError() { QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); Criteria origCrit = parseCriteria("5 / 0 = 5", metadata); //$NON-NLS-1$ // rewrite try { QueryRewriter.rewriteCriteria(origCrit, null, metadata); fail("Expected QueryValidatorException due to divide by 0"); //$NON-NLS-1$ } catch(TeiidException e) { // looks like message is being wrapped with another exception with same message assertEquals("TEIID30328 Unable to evaluate (5 / 0): TEIID30384 Error while evaluating function /", e.getMessage()); //$NON-NLS-1$ } }
@Test public void testRewriteConvertThrowsEvaluationError() { QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); Criteria origCrit = parseCriteria("convert('x', integer) = 0", metadata); //$NON-NLS-1$ // rewrite try { QueryRewriter.rewriteCriteria(origCrit, null, metadata); fail("Expected QueryValidatorException due to invalid string"); //$NON-NLS-1$ } catch(TeiidException e) { assertEquals("TEIID30328 Unable to evaluate convert('x', integer): TEIID30384 Error while evaluating function convert", e.getMessage()); //$NON-NLS-1$ } }
@Ignore(value="Should be moved to the validator") @Test public void testRewriteCrit_invalidParseDate() { QueryMetadataInterface metadata = RealMetadataFactory.example1Cached(); Criteria origCrit = parseCriteria("PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", metadata); //$NON-NLS-1$ try { QueryRewriter.rewriteCriteria(origCrit, null, null); fail("Expected failure"); //$NON-NLS-1$ } catch(TeiidException e) { assertEquals("Error Code:ERR.015.001.0003 Message:Error simplifying criteria: PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", e.getMessage()); //$NON-NLS-1$ } }
@Test public void testServerTimeout() throws Exception { RequestMessage reqMsg = exampleRequestMessage("select to_bytes(stringkey, 'utf-8') FROM BQT1.SmallA"); reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF); agds.setSleep(100); this.config.setQueryTimeout(1); ResultsMessage rm = execute("A", 1, reqMsg); assertNotNull(rm.getException()); assertEquals("57014 TEIID30563 The request 1.0 has been cancelled: TEIID31096 Query has exceeded the VDB/engine timeout of 1 milliseconds.", rm.getException().getMessage()); }