datafusion_postgres/hooks/
mod.rs

1pub mod set_show;
2
3use async_trait::async_trait;
4
5use datafusion::common::ParamValues;
6use datafusion::logical_expr::LogicalPlan;
7use datafusion::prelude::SessionContext;
8use datafusion::sql::sqlparser::ast::Statement;
9use pgwire::api::results::Response;
10use pgwire::api::ClientInfo;
11use pgwire::error::PgWireResult;
12
13#[async_trait]
14pub trait QueryHook: Send + Sync {
15    /// called in simple query handler to return response directly
16    async fn handle_simple_query(
17        &self,
18        statement: &Statement,
19        session_context: &SessionContext,
20        client: &mut (dyn ClientInfo + Send + Sync),
21    ) -> Option<PgWireResult<Response>>;
22
23    /// called at extended query parse phase, for generating `LogicalPlan`from statement
24    async fn handle_extended_parse_query(
25        &self,
26        sql: &Statement,
27        session_context: &SessionContext,
28        client: &(dyn ClientInfo + Send + Sync),
29    ) -> Option<PgWireResult<LogicalPlan>>;
30
31    /// called at extended query execute phase, for query execution
32    async fn handle_extended_query(
33        &self,
34        statement: &Statement,
35        logical_plan: &LogicalPlan,
36        params: &ParamValues,
37        session_context: &SessionContext,
38        client: &mut (dyn ClientInfo + Send + Sync),
39    ) -> Option<PgWireResult<Response>>;
40}