-
1. Re: Generating Query Plan from test case
rareddy Feb 21, 2013 10:04 AM (in response to rakeshsagar) -
2. Re: Generating Query Plan from test case
rakeshsagar Feb 21, 2013 10:33 AM (in response to rareddy)Thanks Ramesh.
Does this apply to the Continuous Executions as well? I tried the same thing but looks like the Query Plan is not getting generated.
The following is the code snippet that I am using:
final TeiidDriver td = server.getDriver();
final Connection c = td.connect("jdbc:teiid:Chorus", null);
final Statement stmt = c.createStatement();
stmt.execute("SET SHOWPLAN ON");
final TeiidStatement tstatement = stmt.unwrap(TeiidStatement.class);
tstatement.submitExecute(sql, new StatementCallback()
{
@Override
public void onRow(final Statement s, final ResultSet rs) throws Exception
{
System.out.println("Row returned"
+ rs.getObject(1));
}
@Override
public void onException(final Statement s, final Exception e) throws Exception
{
e.printStackTrace();
}
@Override
public void onComplete(final Statement s) throws Exception
{
System.out.println("Complete");
}
}, new RequestOptions().continuous(true));
final org.teiid.client.plan.PlanNode queryPlan = tstatement.getPlanDescription();
System.out.println("Plan: " + queryPlan);
Please let me know if I am missing anything here.
Thanks
Rakesh
-
3. Re: Generating Query Plan from test case
shawkins Feb 21, 2013 10:48 AM (in response to rakeshsagar)Rakesh,
Continuous executions are asynch wrt the calling thread. So no plan description will be available immediately after you issue a submit. The simpliest approach is just turn execution off "SET NOEXEC ON" and issue the query as a regular statement.
Steve
-
4. Re: Generating Query Plan from test case
rakeshsagar Feb 21, 2013 10:55 AM (in response to shawkins)Thanks Steve.
I tried this and I get the plan description as null.
-
5. Re: Generating Query Plan from test case
shawkins Feb 21, 2013 10:59 AM (in response to rakeshsagar)Can you show me what "this" is?
Steve
-
6. Re: Generating Query Plan from test case
rakeshsagar Feb 21, 2013 1:10 PM (in response to shawkins)Attached the test case to the original post.
Thanks
Rakesh
-
7. Re: Generating Query Plan from test case
shawkins Feb 21, 2013 1:35 PM (in response to rakeshsagar)You need to just follow the link that Ramesh sent. The basic flow is:
stmt.execute("SET SHOWPLAN ON");
stmt.execute("SET NOEXEC ON"); //this is optional, but more than likely you just want the plan
stmt.execute(sql);
PlanNode p = stmt.getPlanDescription(); //or stmt.executeQuery("SHOW PLAN");
...
-
8. Re: Generating Query Plan from test case
rakeshsagar Feb 22, 2013 12:28 AM (in response to shawkins)Thanks Steve.