This is an automated email from the ASF dual-hosted git repository.

xudong963 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 0604bbb6e1 chore(deps): bump sqllogictest from 0.26.4 to 0.27.0 
(#14598)
0604bbb6e1 is described below

commit 0604bbb6e15d6546f1bbdd8c5c1a6e1dd7004ecb
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
AuthorDate: Wed Feb 12 17:50:32 2025 +0800

    chore(deps): bump sqllogictest from 0.26.4 to 0.27.0 (#14598)
    
    * chore(deps): bump sqllogictest from 0.26.4 to 0.27.0
    
    Bumps [sqllogictest](https://github.com/risinglightdb/sqllogictest-rs) from 
0.26.4 to 0.27.0.
    - [Release notes](https://github.com/risinglightdb/sqllogictest-rs/releases)
    - 
[Changelog](https://github.com/risinglightdb/sqllogictest-rs/blob/main/CHANGELOG.md)
    - 
[Commits](https://github.com/risinglightdb/sqllogictest-rs/compare/v0.26.4...v0.27.0)
    
    ---
    updated-dependencies:
    - dependency-name: sqllogictest
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    
    * Add shutdown
    
    ---------
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] 
<49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonahgao <[email protected]>
---
 Cargo.lock                                         |  4 +--
 datafusion/sqllogictest/Cargo.toml                 |  2 +-
 .../src/engines/datafusion_engine/runner.rs        |  2 ++
 .../src/engines/postgres_engine/mod.rs             | 32 ++++++++++++++++------
 4 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 79de823cf0..3b1efcf6b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5541,9 +5541,9 @@ checksum = 
"6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
 
 [[package]]
 name = "sqllogictest"
-version = "0.26.4"
+version = "0.27.0"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "3bc65b5525b4674a844eb6e39a5d4ef2385a3a2b96c13ef82bbe73220f24bcad"
+checksum = "df0dc0abbe6af4b4d34dc852bd014e07c16a3ae8c308d72ac45e72ef0fecfbac"
 dependencies = [
  "async-trait",
  "educe",
diff --git a/datafusion/sqllogictest/Cargo.toml 
b/datafusion/sqllogictest/Cargo.toml
index 2f5520c435..f5fc6733bf 100644
--- a/datafusion/sqllogictest/Cargo.toml
+++ b/datafusion/sqllogictest/Cargo.toml
@@ -51,7 +51,7 @@ object_store = { workspace = true }
 postgres-protocol = { version = "0.6.7", optional = true }
 postgres-types = { version = "0.2.8", features = ["derive", 
"with-chrono-0_4"], optional = true }
 rust_decimal = { version = "1.36.0", features = ["tokio-pg"] }
-sqllogictest = "0.26.4"
+sqllogictest = "0.27.0"
 sqlparser = { workspace = true }
 tempfile = { workspace = true }
 testcontainers = { version = "0.23", features = ["default"], optional = true }
diff --git a/datafusion/sqllogictest/src/engines/datafusion_engine/runner.rs 
b/datafusion/sqllogictest/src/engines/datafusion_engine/runner.rs
index e696058484..a3a29eda2e 100644
--- a/datafusion/sqllogictest/src/engines/datafusion_engine/runner.rs
+++ b/datafusion/sqllogictest/src/engines/datafusion_engine/runner.rs
@@ -111,6 +111,8 @@ impl sqllogictest::AsyncDB for DataFusion {
     async fn sleep(dur: Duration) {
         tokio::time::sleep(dur).await;
     }
+
+    async fn shutdown(&mut self) {}
 }
 
 async fn run_query(ctx: &SessionContext, sql: impl Into<String>) -> 
Result<DFOutput> {
diff --git a/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs 
b/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs
index f0e162fe64..68816626bf 100644
--- a/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs
+++ b/datafusion/sqllogictest/src/engines/postgres_engine/mod.rs
@@ -53,8 +53,9 @@ pub enum Error {
 pub type Result<T, E = Error> = std::result::Result<T, E>;
 
 pub struct Postgres {
-    client: tokio_postgres::Client,
-    _spawned_task: SpawnedTask<()>,
+    // None means the connection has been shutdown
+    client: Option<tokio_postgres::Client>,
+    spawned_task: Option<SpawnedTask<()>>,
     /// Relative test file path
     relative_path: PathBuf,
     pb: ProgressBar,
@@ -90,7 +91,7 @@ impl Postgres {
 
         let (client, connection) = res?;
 
-        let _spawned_task = SpawnedTask::spawn(async move {
+        let spawned_task = SpawnedTask::spawn(async move {
             if let Err(e) = connection.await {
                 log::error!("Postgres connection error: {:?}", e);
             }
@@ -113,13 +114,17 @@ impl Postgres {
             .await?;
 
         Ok(Self {
-            client,
-            _spawned_task,
+            client: Some(client),
+            spawned_task: Some(spawned_task),
             relative_path,
             pb,
         })
     }
 
+    fn get_client(&mut self) -> &mut tokio_postgres::Client {
+        self.client.as_mut().expect("client is shutdown")
+    }
+
     /// Special COPY command support. "COPY 'filename'" requires the
     /// server to read the file which may not be possible (maybe it is
     /// remote or running in some other docker container).
@@ -170,7 +175,7 @@ impl Postgres {
         debug!("Copying data from file {filename} using sql: {new_sql}");
 
         // start the COPY command and get location to write data to
-        let tx = self.client.transaction().await?;
+        let tx = self.get_client().transaction().await?;
         let sink = tx.copy_in(&new_sql).await?;
         let mut sink = Box::pin(sink);
 
@@ -257,12 +262,12 @@ impl sqllogictest::AsyncDB for Postgres {
         }
 
         if !is_query_sql {
-            self.client.execute(sql, &[]).await?;
+            self.get_client().execute(sql, &[]).await?;
             self.pb.inc(1);
             return Ok(DBOutput::StatementComplete(0));
         }
         let start = Instant::now();
-        let rows = self.client.query(sql, &[]).await?;
+        let rows = self.get_client().query(sql, &[]).await?;
         let duration = start.elapsed();
 
         if duration.gt(&Duration::from_millis(500)) {
@@ -272,7 +277,7 @@ impl sqllogictest::AsyncDB for Postgres {
         self.pb.inc(1);
 
         let types: Vec<Type> = if rows.is_empty() {
-            self.client
+            self.get_client()
                 .prepare(sql)
                 .await?
                 .columns()
@@ -300,6 +305,15 @@ impl sqllogictest::AsyncDB for Postgres {
     fn engine_name(&self) -> &str {
         "postgres"
     }
+
+    async fn shutdown(&mut self) {
+        if let Some(client) = self.client.take() {
+            drop(client);
+        }
+        if let Some(spawned_task) = self.spawned_task.take() {
+            spawned_task.join().await.ok();
+        }
+    }
 }
 
 fn convert_rows(rows: Vec<Row>) -> Vec<Vec<String>> {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to