Class PreparedStatement

java.lang.Object
org.apache.druid.sql.AbstractStatement
org.apache.druid.sql.PreparedStatement
All Implemented Interfaces:
Closeable, AutoCloseable

public class PreparedStatement extends AbstractStatement
Statement for the JDBC prepare-once, execute many model.
  • Constructor Details

  • Method Details

    • prepare

      public PrepareResult prepare()
      Prepare the query lifecycle for execution, without completely planning into something that is executable, but including some initial parsing and validation, to support prepared statements via JDBC.

      Note that, per JDBC convention, the prepare step does not provide parameter values: those are provided later during execution and will generally vary from one execution to the next.

      • Create the planner.
      • Parse the statement.
      • JDBC does not provide parameter values at prepare time. They are provided during execution later, where we'll replan the query to use the "query optimized" structure.
      • Validate the query against the Druid catalog.
      • Authorize access to the resources which the query needs.
      • Return a PrepareResult which describes the query.
    • execute

      public DirectStatement execute(List<org.apache.calcite.avatica.remote.TypedValue> parameters)
      Execute a prepared JDBC query. Druid uses "query optimized" parameters, which means we do not reuse the statement prepared above, but rather plan anew with the actual parameter values. The same statement can be execute many times, including concurrently. Each execution repeats the parse, validate, authorize and plan steps since data, permissions, views and other dependencies may have changed.
    • getPlanner

      protected DruidPlanner getPlanner()