Skip to content

Commit b81f0bb

Browse files
committed
refactor: allow all types of statements
1 parent 1266fe5 commit b81f0bb

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

datafusion-postgres/src/handlers.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use pgwire::api::results::{DescribePortalResponse, DescribeStatementResponse, Re
1212
use pgwire::api::stmt::QueryParser;
1313
use pgwire::api::stmt::StoredStatement;
1414
use pgwire::api::{ClientInfo, PgWireHandlerFactory, Type};
15-
use pgwire::error::{ErrorInfo, PgWireError, PgWireResult};
15+
use pgwire::error::{PgWireError, PgWireResult};
1616

1717
use crate::datatypes::{self, into_pg_type};
1818

@@ -69,22 +69,14 @@ impl SimpleQueryHandler for DfSessionService {
6969
where
7070
C: ClientInfo + Unpin + Send + Sync,
7171
{
72-
if query.to_uppercase().starts_with("SELECT") {
73-
let ctx = &self.session_context;
74-
let df = ctx
75-
.sql(query)
76-
.await
77-
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
78-
79-
let resp = datatypes::encode_dataframe(df, &Format::UnifiedText).await?;
80-
Ok(vec![Response::Query(resp)])
81-
} else {
82-
Ok(vec![Response::Error(Box::new(ErrorInfo::new(
83-
"ERROR".to_owned(),
84-
"XX000".to_owned(),
85-
"Only select statements is supported by this tool.".to_owned(),
86-
)))])
87-
}
72+
let ctx = &self.session_context;
73+
let df = ctx
74+
.sql(query)
75+
.await
76+
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
77+
78+
let resp = datatypes::encode_dataframe(df, &Format::UnifiedText).await?;
79+
Ok(vec![Response::Query(resp)])
8880
}
8981
}
9082

@@ -138,7 +130,6 @@ impl ExtendedQueryHandler for DfSessionService {
138130
.get_parameter_types()
139131
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
140132

141-
dbg!(&params);
142133
let mut param_types = Vec::with_capacity(params.len());
143134
for param_type in params.into_values() {
144135
if let Some(datatype) = param_type {

0 commit comments

Comments
 (0)