Package org.apache.druid.sql
Class PreparedStatement
java.lang.Object
org.apache.druid.sql.AbstractStatement
org.apache.druid.sql.PreparedStatement
- All Implemented Interfaces:
Closeable,AutoCloseable
Statement for the JDBC prepare-once, execute many model.
-
Field Summary
Fields inherited from class org.apache.druid.sql.AbstractStatement
authContextKeys, authResult, hook, plannerContext, queryContext, queryPlus, reporter, sqlToolbox -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecute a prepared JDBC query.protected DruidPlannerprepare()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.Methods inherited from class org.apache.druid.sql.AbstractStatement
allResources, authorize, authorizer, close, closeQuietly, closeWithError, context, query, reporter, resources, setHook, sqlQueryId, validate
-
Constructor Details
-
PreparedStatement
-
-
Method Details
-
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
PrepareResultwhich describes the query.
-
execute
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
-