本文整理汇总了Java中com.taobao.tddl.optimizer.core.ast.query.TableNode.insert方法的典型用法代码示例。如果您正苦于以下问题:Java TableNode.insert方法的具体用法?Java TableNode.insert怎么用?Java TableNode.insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.optimizer.core.ast.query.TableNode
的用法示例。
在下文中一共展示了TableNode.insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPreparedInsertSql
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testPreparedInsertSql() throws SqlParserException {
String sql = "INSERT INTO TABLE1(ID,NAME,SCHOOL) VALUES (?, ?, ?)";
InsertNode in = insert(sql);
Map<Integer, ParameterContext> currentParameter = new HashMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 2 });
ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "sun" });
ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, "sysu" });
currentParameter.put(1, p1);
currentParameter.put(2, p2);
currentParameter.put(3, p3);
Parameters parameterSettings = new Parameters(currentParameter, false);
in.build();
in.assignment(parameterSettings);
TableNode table1 = new TableNode("TABLE1");
InsertNode inExpected = table1.insert("ID NAME SCHOOL", new Comparable[] { 2, "sun", "sysu" });
inExpected.build();
assertEquals(in, inExpected);
}
示例2: visit
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
public void visit(DMLInsertStatement node) {
TableNode table = getTableNode(node);
String insertColumns = this.getInsertColumnsStr(node);
List<RowExpression> exprList = node.getRowList();
if (exprList != null && exprList.size() == 1) {
RowExpression expr = exprList.get(0);
Comparable[] iv = getRowValue(expr);
this.insertNode = table.insert(insertColumns, iv);
} else {
throw new NotSupportException("could not support multi row values.");
}
// 暂时不支持子表的查询
QueryExpression subQuery = node.getSelect();
if (subQuery != null) {
throw new NotSupportException("could not support insert into select");
}
}
示例3: testPreparedInsertSql
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testPreparedInsertSql() throws SqlParserException, QueryException {
String sql = "INSERT INTO TABLE1(ID,NAME,SCHOOL) VALUES (?, ?, ?)";
InsertNode in = insert(sql);
Map<Integer, ParameterContext> parameterSettings = null;
parameterSettings = new TreeMap<Integer, ParameterContext>();
ParameterContext p1 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 0, 2 });
ParameterContext p2 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 1, "sun" });
ParameterContext p3 = new ParameterContext(ParameterMethod.setObject1, new Object[] { 2, "sysu" });
parameterSettings.put(1, p1);
parameterSettings.put(2, p2);
parameterSettings.put(3, p3);
in.assignment(parameterSettings);
in.build();
TableNode table1 = new TableNode("TABLE1");
InsertNode inExpected = table1.insert("ID NAME SCHOOL", new Comparable[] { 2, "sun", "sysu" });
inExpected.build();
assertEquals(in, inExpected);
}
示例4: visit
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Override
public void visit(CreateSequence node) {
TableNode table = getTableNode();
String insertColumns = this.getInsertColumnsStr();
Object[] iv = getRowValue(node);
this.createSequenceInsert = table.insert(insertColumns, iv);
}
示例5: TABLE1
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_无字段() throws SqlParserException {
String sql = "INSERT INTO TABLE1(ID) VALUES (2)";
InsertNode in = insert(sql);
in.build();
TableNode table1 = new TableNode("TABLE1");
InsertNode inExpected = table1.insert("ID", new Comparable[] { 2 });
inExpected.build();
assertEquals(in, inExpected);
}
示例6: testInsert
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert() {
TableNode table = new TableNode("TABLE1");
Comparable values[] = { 2 };
InsertNode insert = table.insert("ID", values);
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
Assert.assertTrue(plan instanceof IInsert);
String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IInsert);
}
示例7: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_广播表() {
TableNode table = new TableNode("TABLE7");
Comparable values[] = { 2 };
InsertNode insert = table.insert("ID", values);
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());
String sql = "INSERT INTO TABLE7(ID) VALUES(2)";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IMerge);
Assert.assertEquals(4, ((IMerge) plan).getSubNodes().size());
}
示例8: TABLE1
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_无字段() throws SqlParserException, QueryException {
String sql = "INSERT INTO TABLE1(ID) VALUES (2)";
InsertNode in = insert(sql);
in.build();
TableNode table1 = new TableNode("TABLE1");
InsertNode inExpected = table1.insert("ID", new Comparable[] { 2 });
inExpected.build();
assertEquals(in, inExpected);
}
示例9: testInsert
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert() throws QueryException {
TableNode table = new TableNode("TABLE1");
Comparable values[] = { 2 };
InsertNode insert = table.insert("ID", values);
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
Assert.assertTrue(plan instanceof IInsert);
String sql = "INSERT INTO TABLE1(ID) VALUES(2)";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IInsert);
}
示例10: TableNode
import com.taobao.tddl.optimizer.core.ast.query.TableNode; //导入方法依赖的package包/类
@Test
public void testInsert_全字段() throws QueryException {
TableNode table = new TableNode("TABLE1");
Comparable values[] = { 2, "sysu", "sun" };
InsertNode insert = table.insert("ID SCHOOL NAME", values);
IDataNodeExecutor plan = optimizer.optimizeAndAssignment(insert, null, null);
Assert.assertTrue(plan instanceof IInsert);
String sql = "INSERT INTO TABLE1 VALUES(2,'sysu','sun')";
plan = optimizer.optimizeAndAssignment(sql, null, null, false);
Assert.assertTrue(plan instanceof IInsert);
}