Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Add a test for version() function #12441

Merged
merged 1 commit into from
Sep 12, 2024
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
30 changes: 30 additions & 0 deletions datafusion/core/tests/sql/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,33 @@ async fn test_parameter_invalid_types() -> Result<()> {
);
Ok(())
}

#[tokio::test]
async fn test_version_function() {
let expected_version = format!(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best I can come up with was to programatically create the same expected output.

It would be better to make it with something different, but given it changes with architecture and release this is the best I could come up with

"Apache DataFusion {}, {} on {}",
env!("CARGO_PKG_VERSION"),
std::env::consts::ARCH,
std::env::consts::OS,
);

let ctx = SessionContext::new();
let results = ctx
.sql("select version()")
.await
.unwrap()
.collect()
.await
.unwrap();

// since width of columns varies between platforms, we can't compare directly
// so we just check that the version string is present

// expect a single string column with a single row
assert_eq!(results.len(), 1);
assert_eq!(results[0].num_columns(), 1);
let version = results[0].column(0).as_string::<i32>();
assert_eq!(version.len(), 1);

assert_eq!(version.value(0), expected_version);
}