Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions datafusion-postgres/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pgwire::api::results::{DescribePortalResponse, DescribeStatementResponse, Re
use pgwire::api::stmt::QueryParser;
use pgwire::api::stmt::StoredStatement;
use pgwire::api::{ClientInfo, PgWireHandlerFactory, Type};
use pgwire::error::{ErrorInfo, PgWireError, PgWireResult};
use pgwire::error::{PgWireError, PgWireResult};

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

Expand Down Expand Up @@ -69,22 +69,14 @@ impl SimpleQueryHandler for DfSessionService {
where
C: ClientInfo + Unpin + Send + Sync,
{
if query.to_uppercase().starts_with("SELECT") {
let ctx = &self.session_context;
let df = ctx
.sql(query)
.await
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;

let resp = datatypes::encode_dataframe(df, &Format::UnifiedText).await?;
Ok(vec![Response::Query(resp)])
} else {
Ok(vec![Response::Error(Box::new(ErrorInfo::new(
"ERROR".to_owned(),
"XX000".to_owned(),
"Only select statements is supported by this tool.".to_owned(),
)))])
}
let ctx = &self.session_context;
let df = ctx
.sql(query)
.await
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;

let resp = datatypes::encode_dataframe(df, &Format::UnifiedText).await?;
Ok(vec![Response::Query(resp)])
}
}

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

dbg!(&params);
let mut param_types = Vec::with_capacity(params.len());
for param_type in params.into_values() {
if let Some(datatype) = param_type {
Expand Down