@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }
@Test public void testDelete() throws Exception { Connection conn = DriverManager.getConnection(getUrl()); conn.createStatement().execute("CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)"); conn.createStatement().execute("CREATE INDEX idx ON t(v1,v2)"); conn.setAutoCommit(true); PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class); SQLParser parser = new SQLParser("DELETE FROM t"); DeleteStatement delete = (DeleteStatement) parser.parseStatement(); DeleteCompiler compiler = new DeleteCompiler(stmt, null); MutationPlan plan = compiler.compile(delete); assertEquals("T", plan.getQueryPlan().getTableRef().getTable().getTableName().getString()); assertTrue(plan.getClass().getName().contains("ServerSelectDeleteMutationPlan")); parser = new SQLParser("DELETE FROM t WHERE v1 = 'foo'"); delete = (DeleteStatement) parser.parseStatement(); plan = compiler.compile(delete); assertEquals("IDX", plan.getQueryPlan().getTableRef().getTable().getTableName().getString()); assertTrue(plan.getClass().getName().contains("ClientSelectDeleteMutationPlan")); }
@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }
@SuppressWarnings("unchecked") @Override public MutationPlan compilePlan(PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException { if(!getUdfParseNodes().isEmpty()) { stmt.throwIfUnallowedUserDefinedFunctions(getUdfParseNodes()); } DeleteCompiler compiler = new DeleteCompiler(stmt, this.getOperation()); MutationPlan plan = compiler.compile(this); plan.getContext().getSequenceManager().validateSequences(seqAction); return plan; } }