use of org.teiid.language.Insert in project teiid by teiid.
the class TestInsertImpl method testExpressionsInInsert.
public void testExpressionsInInsert() throws Exception {
// $NON-NLS-1$
Insert insert = example2("a.b");
assertNotNull(insert.getColumns());
assertEquals(1, insert.getColumns().size());
for (Iterator i = insert.getColumns().iterator(); i.hasNext(); ) {
assertTrue(i.next() instanceof ColumnReference);
}
assertNotNull(insert.getValueSource());
assertEquals(1, ((ExpressionValueSource) insert.getValueSource()).getValues().size());
for (Iterator i = ((ExpressionValueSource) insert.getValueSource()).getValues().iterator(); i.hasNext(); ) {
assertTrue(i.next() instanceof Expression);
}
}
use of org.teiid.language.Insert in project teiid by teiid.
the class TestInsertImpl method testGetElements.
public void testGetElements() throws Exception {
// $NON-NLS-1$
Insert insert = example("a.b");
assertNotNull(insert.getColumns());
assertEquals(4, insert.getColumns().size());
// verify that elements are not qualified by group
String sInsertSQL = insert.toString();
assertTrue(sInsertSQL.substring(sInsertSQL.indexOf('(')).indexOf('.') == -1);
}
use of org.teiid.language.Insert in project teiid by teiid.
the class AccumuloUpdateExecution method execute.
@Override
public void execute() throws TranslatorException {
try {
if (this.command instanceof Insert) {
Insert insert = (Insert) this.command;
performInsert(insert);
} else if (this.command instanceof Update) {
Update update = (Update) this.command;
performUpdate(update);
} else if (this.command instanceof Delete) {
Delete delete = (Delete) this.command;
performDelete(delete);
}
} catch (MutationsRejectedException e) {
throw new TranslatorException(e);
} catch (TableNotFoundException e) {
throw new TranslatorException(e);
}
}
use of org.teiid.language.Insert in project teiid by teiid.
the class TestSQLtoSpreadsheetQuery method testInsertExecution.
@Test
public void testInsertExecution() throws Exception {
String sql = "insert into PeopleList(A,B,C) values ('String,String', 'val', 15.5)";
Insert insert = (Insert) getCommand(sql);
GoogleSpreadsheetConnection gsc = Mockito.mock(GoogleSpreadsheetConnection.class);
Mockito.stub(gsc.getSpreadsheetInfo()).toReturn(people);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
SpreadsheetUpdateExecution sue = new SpreadsheetUpdateExecution(insert, gsc, ec, rm);
sue.execute();
LinkedHashMap<String, Object> vals = new LinkedHashMap<String, Object>();
vals.put("A", "String,String");
vals.put("B", "val");
vals.put("C", 15.5);
Mockito.verify(gsc).executeRowInsert("PeopleList", vals);
}
use of org.teiid.language.Insert in project teiid by teiid.
the class TestN1QLUpdateVisitor method testInsertBulk.
@Test
public void testInsertBulk() {
String sql = "INSERT INTO Customer (documentID) VALUES ('customer-1')";
Insert insert = (Insert) translationUtility.parseCommand(sql);
Parameter p = new Parameter();
p.setType(String.class);
p.setValueIndex(0);
((ExpressionValueSource) insert.getValueSource()).getValues().set(0, p);
insert.setParameterValues(Arrays.asList(Arrays.asList("customer-1"), Arrays.asList("customer-2")).iterator());
N1QLUpdateVisitor visitor = TRANSLATOR.getN1QLUpdateVisitor();
visitor.append(insert);
String actual = visitor.getBulkCommands()[0];
assertEquals("INSERT INTO `test` (KEY, VALUE) VALUES ('customer-1', {\"type\":\"Customer\"}), VALUES ('customer-2', {\"type\":\"Customer\"}) RETURNING META(`test`).id AS PK", actual);
}
Aggregations