Skip to content

Commit 822d624

Browse files
committed
update trait to accept sqlparser::ast::Statement instead, so we don't need to wrap in a datafusion::Statement
1 parent 3bd7513 commit 822d624

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

datafusion-postgres/src/handlers.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ use tokio::sync::Mutex;
2727
use crate::auth::AuthManager;
2828
use arrow_pg::datatypes::df;
2929
use arrow_pg::datatypes::{arrow_schema_to_pg_fields, into_pg_type};
30+
use datafusion::sql::sqlparser;
3031
use datafusion_pg_catalog::pg_catalog::context::{Permission, ResourceType};
3132
use datafusion_pg_catalog::sql::PostgresCompatibilityParser;
3233

3334
#[async_trait]
3435
pub trait QueryHook: Send + Sync {
3536
async fn handle_query(
3637
&self,
37-
statement: &Statement,
38+
statement: &sqlparser::ast::Statement,
3839
session_context: &SessionContext,
3940
client: &dyn ClientInfo,
4041
) -> Option<PgWireResult<Vec<Response>>>;
@@ -490,9 +491,8 @@ impl SimpleQueryHandler for DfSessionService {
490491

491492
// Call query hooks with the parsed statement
492493
for hook in &self.query_hooks {
493-
let wrapped_statement = Statement::Statement(Box::new(statement.clone()));
494494
if let Some(result) = hook
495-
.handle_query(&wrapped_statement, &self.session_context, client)
495+
.handle_query(&statement, &self.session_context, client)
496496
.await
497497
{
498498
return result;
@@ -652,9 +652,8 @@ impl ExtendedQueryHandler for DfSessionService {
652652
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
653653

654654
if let Some(statement) = statements.into_iter().next() {
655-
let wrapped_statement = Statement::Statement(Box::new(statement));
656655
if let Some(result) = hook
657-
.handle_query(&wrapped_statement, &self.session_context, client)
656+
.handle_query(&statement, &self.session_context, client)
658657
.await
659658
{
660659
// Convert Vec<Response> to single Response

0 commit comments

Comments
 (0)