Skip to content

Commit

Permalink
Test working
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmturner committed Oct 15, 2024
1 parent 6b1001c commit e14c47b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
24 changes: 18 additions & 6 deletions tests/extension_cases/hudi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |", "+----+"]
);
}
5 changes: 2 additions & 3 deletions tests/extension_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<RecordBatch>> {
pub async fn run(&self, sql: &str) -> Result<Vec<RecordBatch>> {
debug!("Running query: {sql}");
self.execution
.execute_sql(sql)
Expand All @@ -89,7 +88,7 @@ impl TestExecution {

/// Runs the specified SQL query, returning the result as a Vec<String>
/// suitable for comparison with insta
pub async fn run_and_format(&mut self, sql: &str) -> Vec<String> {
pub async fn run_and_format(&self, sql: &str) -> Vec<String> {
format_results(&self.run(sql).await.expect("Error running query"))
}
}
Expand Down

0 comments on commit e14c47b

Please sign in to comment.