use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcErrors method testNestedBeginAtomicException.
@Test
public void testNestedBeginAtomicException() throws Exception {
TransformationMetadata tm = RealMetadataFactory.example1Cached();
String query = "BEGIN atomic\n" + " declare string VARIABLES.RESULT;\n" + " begin atomic select 1/0; exception e end end";
ProcessorPlan plan = getProcedurePlan(query, tm);
// Create expected results
List<?>[] expected = new List[0];
// $NON-NLS-1$
CommandContext context = new CommandContext("pID", null, null, null, 1);
QueryMetadataInterface metadata = new TempMetadataAdapter(tm, new TempMetadataStore());
context.setMetadata(metadata);
TransactionContext tc = new TransactionContext();
Transaction txn = Mockito.mock(Transaction.class);
tc.setTransaction(txn);
tc.setTransactionType(Scope.REQUEST);
TransactionService ts = Mockito.mock(TransactionService.class);
context.setTransactionService(ts);
context.setTransactionContext(tc);
TestProcessor.helpProcess(plan, context, new HardcodedDataManager(), expected);
Mockito.verify(txn, Mockito.times(3)).setRollbackOnly();
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestProcErrors method testExceptionHandlingWithDynamic.
@Test
public void testExceptionHandlingWithDynamic() throws Exception {
String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "raise sqlexception 'hello world' sqlstate 'abc', 5;" + "exception e " + "execute immediate 'select \"ERRORCODE\"' as x integer into #temp; " + "\"return\" = (select x from #temp);" + "end;";
TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl);
// $NON-NLS-1$
String sql = "call vproc(1)";
ProcessorPlan plan = getProcedurePlan(sql, tm);
HardcodedDataManager dataManager = new HardcodedDataManager(tm);
helpTestProcess(plan, new List[] { Arrays.asList(5) }, dataManager, tm);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinNode method testDupRemoveUnderJoin.
@Test
public void testDupRemoveUnderJoin() throws Exception {
// $NON-NLS-1$
String sql = "select a.e1, b.e2 from pm1.g1 as a, (select distinct e1, e2 from pm2.g2) as b";
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
HardcodedDataManager hdm = new HardcodedDataManager() {
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
final TupleSource source = super.registerRequest(context, command, modelName, parameterObject);
return new TupleSource() {
private int block;
@Override
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
if (block++ % 2 == 0) {
throw BlockedException.INSTANCE;
}
return source.nextTuple();
}
@Override
public void closeSource() {
source.closeSource();
}
};
}
};
List<?>[] rows = new List<?>[1];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i));
}
hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
rows = new List<?>[1025];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
mgr.setTargetBytesPerRow(100);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
List<?>[] results = new List<?>[1025];
for (int i = 0; i < results.length; i++) {
results[i] = Arrays.asList("0", i);
}
TestProcessor.helpProcess(plan, context, hdm, results);
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestJoinNode method testPrefetchDistinct.
@Test
public void testPrefetchDistinct() throws Exception {
// $NON-NLS-1$
String sql = "select a.e1, b.e2 from pm1.g1 as a, (select e1, e2 from pm2.g2 union select e1, e2 from pm2.g2) as b";
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, RealMetadataFactory.example1Cached());
HardcodedDataManager hdm = new HardcodedDataManager() {
public TupleSource registerRequest(CommandContext context, Command command, String modelName, RegisterRequestParameter parameterObject) throws TeiidComponentException {
final TupleSource source = super.registerRequest(context, command, modelName, parameterObject);
return new TupleSource() {
private int block;
@Override
public List<?> nextTuple() throws TeiidComponentException, TeiidProcessingException {
if (block++ % 2 == 0) {
throw BlockedException.INSTANCE;
}
return source.nextTuple();
}
@Override
public void closeSource() {
source.closeSource();
}
};
}
};
List<?>[] rows = new List<?>[2];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i));
}
hdm.addData("SELECT pm1.g1.e1 FROM pm1.g1", rows);
rows = new List<?>[2];
for (int i = 0; i < rows.length; i++) {
rows[i] = Arrays.asList(String.valueOf(i), i);
}
hdm.addData("SELECT pm2.g2.e1, pm2.g2.e2 FROM pm2.g2", rows);
BufferManagerImpl mgr = BufferManagerFactory.getTestBufferManager(1, 2);
mgr.setTargetBytesPerRow(100);
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
context.setBufferManager(mgr);
TestProcessor.helpProcess(plan, context, hdm, new List<?>[] { Arrays.asList("0", 0), Arrays.asList("0", 1), Arrays.asList("1", 0), Arrays.asList("1", 1) });
}
use of org.teiid.query.processor.HardcodedDataManager in project teiid by teiid.
the class TestPreparedStatement method testInsertWithSimpleSelect.
@Test
public void testInsertWithSimpleSelect() throws Exception {
// $NON-NLS-1$
String preparedSql = "insert into pm1.g1 (e1, e2) select ?, ?";
List<?>[] expected = new List<?>[] { Arrays.asList(1) };
// $NON-NLS-1$
List<?> values = Arrays.asList("a", "1");
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
HardcodedDataManager dataManager = new HardcodedDataManager(metadata);
dataManager.addData("INSERT INTO g1 (e1, e2) VALUES ('a', 1)", new List<?>[] { Arrays.asList(1) });
BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
helpTestProcessing(preparedSql, values, expected, dataManager, new DefaultCapabilitiesFinder(caps), metadata, null, false, false, false, RealMetadataFactory.example1VDB());
}
Aggregations