datafusion_postgres/hooks/
mod.rs

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