From e14c47bb82dbfb528ad51326f8d3c60999e8e72c Mon Sep 17 00:00:00 2001 From: Matthew Turner Date: Mon, 14 Oct 2024 20:05:51 -0400 Subject: [PATCH] Test working --- Cargo.toml | 1 + tests/extension_cases/hudi.rs | 24 ++++++++++++++++++------ tests/extension_cases/mod.rs | 5 ++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e9d6f3b..7a8070b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ assert_cmd = "2.0.16" insta = { version = "1.40.0", features = ["yaml"] } predicates = "3.1.2" tempfile = "3.2.0" +url = "2.5.2" # When addding a new feature, also add it to the features tested list in CI (`.github/workflows/rust.yml`) [features] diff --git a/tests/extension_cases/hudi.rs b/tests/extension_cases/hudi.rs index bb48a1b..93b2b86 100644 --- a/tests/extension_cases/hudi.rs +++ b/tests/extension_cases/hudi.rs @@ -15,17 +15,29 @@ // specific language governing permissions and limitations // under the License. +use url::Url; + use crate::extension_cases::TestExecution; #[tokio::test] async fn test_hudi() { let test_exec = TestExecution::new(); - test_exec.with_setup( - "CREATE EXTERNAL TABLE h STORED AS HUDI LOCATION './data/hudi/v6_simplekeygen_nonhivestyle';", - ) - .await; + let cwd = std::env::current_dir().unwrap(); + let path = Url::from_file_path(cwd.join("data/hudi/v6_simplekeygen_nonhivestyle")).unwrap(); + + let test_exec = test_exec + .with_setup(&format!( + "CREATE EXTERNAL TABLE h STORED AS HUDI LOCATION '{}';", + path + )) + .await; - let output = test_exec.run_and_format("SELECT * FROM h").await; - assert_eq!(output, vec![""]); + let output = test_exec + .run_and_format("SELECT id FROM h ORDER BY id") + .await; + assert_eq!( + output, + vec!["+----+", "| id |", "+----+", "| 1 |", "| 2 |", "| 3 |", "| 4 |", "+----+"] + ); } diff --git a/tests/extension_cases/mod.rs b/tests/extension_cases/mod.rs index 5015e5e..fdc5c1c 100644 --- a/tests/extension_cases/mod.rs +++ b/tests/extension_cases/mod.rs @@ -76,8 +76,7 @@ impl TestExecution { } /// run the specified SQL query, returning the result as a Vec of [`RecordBatch`] - #[allow(dead_code)] - pub async fn run(&mut self, sql: &str) -> Result> { + pub async fn run(&self, sql: &str) -> Result> { debug!("Running query: {sql}"); self.execution .execute_sql(sql) @@ -89,7 +88,7 @@ impl TestExecution { /// Runs the specified SQL query, returning the result as a Vec /// suitable for comparison with insta - pub async fn run_and_format(&mut self, sql: &str) -> Vec { + pub async fn run_and_format(&self, sql: &str) -> Vec { format_results(&self.run(sql).await.expect("Error running query")) } }