Skip to content

Commit 7dbd7b9

Browse files
committed
test: update duckdb example
1 parent ffba364 commit 7dbd7b9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arrow-pg/examples/duckdb.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use pgwire::api::stmt::{NoopQueryParser, StoredStatement};
1919
use pgwire::api::{ClientInfo, PgWireServerHandlers, Type};
2020
use pgwire::error::{PgWireError, PgWireResult};
2121
use pgwire::tokio::process_socket;
22+
use pgwire::types::format::FormatOptions;
2223
use tokio::net::TcpListener;
2324

2425
pub struct DuckDBBackend {
@@ -45,7 +46,7 @@ impl AuthSource for DummyAuthSource {
4546

4647
#[async_trait]
4748
impl SimpleQueryHandler for DuckDBBackend {
48-
async fn do_query<C>(&self, _client: &mut C, query: &str) -> PgWireResult<Vec<Response>>
49+
async fn do_query<C>(&self, client: &mut C, query: &str) -> PgWireResult<Vec<Response>>
4950
where
5051
C: ClientInfo + Unpin + Send + Sync,
5152
{
@@ -59,9 +60,12 @@ impl SimpleQueryHandler for DuckDBBackend {
5960
.query_arrow(params![])
6061
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
6162
let schema = ret.get_schema();
63+
let format_options = FormatOptions::from_client_metadata(client.metadata());
64+
6265
let header = Arc::new(arrow_schema_to_pg_fields(
6366
schema.as_ref(),
6467
&Format::UnifiedText,
68+
Some(Arc::new(format_options)),
6569
)?);
6670

6771
let header_ref = header.clone();
@@ -155,7 +159,7 @@ impl ExtendedQueryHandler for DuckDBBackend {
155159

156160
async fn do_query<C>(
157161
&self,
158-
_client: &mut C,
162+
client: &mut C,
159163
portal: &Portal<Self::Statement>,
160164
_max_rows: usize,
161165
) -> PgWireResult<Response>
@@ -178,9 +182,11 @@ impl ExtendedQueryHandler for DuckDBBackend {
178182
.query_arrow(params![])
179183
.map_err(|e| PgWireError::ApiError(Box::new(e)))?;
180184
let schema = ret.get_schema();
185+
let format_options = FormatOptions::from_client_metadata(client.metadata());
181186
let header = Arc::new(arrow_schema_to_pg_fields(
182187
schema.as_ref(),
183188
&Format::UnifiedText,
189+
Some(Arc::new(format_options)),
184190
)?);
185191

186192
let header_ref = header.clone();

0 commit comments

Comments
 (0)