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

Add datafusion-cli tests to the CI Job #6600

Merged
merged 5 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
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
38 changes: 37 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ jobs:
- name: Verify Working Directory Clean
run: git diff --exit-code

linux-test-datafusion-cli:
name: cargo test datafusion-cli (amd64)
needs: [ linux-build-lib ]
runs-on: ubuntu-latest
container:
image: amd64/rust
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Cache Cargo
uses: actions/cache@v3
with:
path: /github/home/.cargo
# this key equals the ones on `linux-build-lib` for re-use
key: cargo-cache-
- name: Setup Rust toolchain
uses: ./.github/actions/setup-builder
with:
rust-version: stable
- name: Run tests (excluding doctests)
run: |
cd datafusion-cli
cargo test --lib --tests --bins --all-features
- name: Verify Working Directory Clean
run: git diff --exit-code

linux-test-example:
name: cargo examples (amd64)
needs: [ linux-build-lib ]
Expand Down Expand Up @@ -152,7 +179,10 @@ jobs:
rust-version: stable
# Note: this does not include dictionary_expressions to reduce codegen
- name: Run doctests
run: cargo test --doc --features avro,json
run: |
cargo test --doc --features avro,json
cd datafusion-cli
cargo test --doc --all-features
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

- name: Verify Working Directory Clean
run: git diff --exit-code

Expand All @@ -173,6 +203,8 @@ jobs:
run: |
export RUSTDOCFLAGS="-D warnings -A rustdoc::private-intra-doc-links"
cargo doc --document-private-items --no-deps --workspace
cd datafusion-cli
cargo doc --document-private-items --no-deps

# verify that the benchmark queries return the correct results
verify-benchmark-results:
Expand Down Expand Up @@ -271,6 +303,8 @@ jobs:
run: |
export PATH=$PATH:$HOME/d/protoc/bin
cargo test --lib --tests --bins --features avro,json,dictionary_expressions
cd datafusion-cli
cargo test --lib --tests --bins --all-features
env:
# do not produce debug symbols to keep memory usage down
RUSTFLAGS: "-C debuginfo=0"
Expand Down Expand Up @@ -304,6 +338,8 @@ jobs:
shell: bash
run: |
cargo test --lib --tests --bins --features avro,json,dictionary_expressions
cd datafusion-cli
cargo test --lib --tests --bins --all-features
env:
# do not produce debug symbols to keep memory usage down
RUSTFLAGS: "-C debuginfo=0"
Expand Down
2 changes: 2 additions & 0 deletions ci/scripts/rust_clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

set -ex
cargo clippy --all-targets --workspace --features avro,pyarrow -- -D warnings
cd datafusion-cli
cargo clippy --all-targets --all-features -- -D warnings
2 changes: 2 additions & 0 deletions ci/scripts/rust_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
set -ex
export RUSTDOCFLAGS="-D warnings -A rustdoc::private-intra-doc-links"
cargo doc --document-private-items --no-deps --workspace
cd datafusion-cli
cargo doc --document-private-items --no-deps
2 changes: 2 additions & 0 deletions ci/scripts/rust_fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

set -ex
cargo fmt --all -- --check
cd datafusion-cli
cargo fmt --all -- --check
26 changes: 16 additions & 10 deletions datafusion-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,13 @@ mod tests {
let ctx = SessionContext::new();
let plan = ctx.state().create_logical_plan(sql).await?;

match &plan {
LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) => {
create_external_table(&ctx, cmd).await?;
}
_ => unreachable!(),
};
if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &plan {
create_external_table(&ctx, cmd).await?;
} else {
return Err(DataFusionError::Plan(
"LogicalPlan is not a CreateExternalTable".to_string(),
));
}

ctx.runtime_env()
.object_store(ListingTableUrl::parse(location)?)?;
Expand Down Expand Up @@ -312,7 +313,7 @@ mod tests {
let err = create_external_table_test(location, &sql)
.await
.unwrap_err();
assert!(err.to_string().contains("No such file or directory"));
assert!(err.to_string().contains("os error 2"));

// for service_account_key
let sql = format!("CREATE EXTERNAL TABLE test STORED AS PARQUET OPTIONS('service_account_key' '{service_account_key}') LOCATION '{location}'");
Expand All @@ -327,22 +328,27 @@ mod tests {
let err = create_external_table_test(location, &sql)
.await
.unwrap_err();
assert!(err.to_string().contains("No such file or directory"));
assert!(err.to_string().contains("os error 2"));

Ok(())
}

#[tokio::test]
async fn create_external_table_local_file() -> Result<()> {
let location = "/path/to/file.parquet";
let location = "path/to/file.parquet";

// Ensure that local files are also registered
let sql =
format!("CREATE EXTERNAL TABLE test STORED AS PARQUET LOCATION '{location}'");
let err = create_external_table_test(location, &sql)
.await
.unwrap_err();
assert!(err.to_string().contains("No such file or directory"));

if let DataFusionError::IoError(e) = err {
assert_eq!(e.kind(), std::io::ErrorKind::NotFound);
} else {
return Err(err);
}

Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions datafusion-cli/src/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ pub async fn get_s3_object_store_builder(
.ok_or_else(|| {
DataFusionError::ObjectStore(object_store::Error::Generic {
store: "S3",
source: "Failed to get S3 credentials from environment".to_string()
.into(),
source: "Failed to get S3 credentials from environment".into(),
})
})?
.clone();
Expand Down
13 changes: 6 additions & 7 deletions datafusion-cli/src/print_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ mod tests {
use super::*;
use arrow::array::Int32Array;
use arrow::datatypes::{DataType, Field, Schema};
use datafusion::from_slice::FromSlice;
use std::sync::Arc;

#[test]
Expand All @@ -107,9 +106,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema,
vec![
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
Arc::new(Int32Array::from(vec![1, 2, 3])),
Arc::new(Int32Array::from(vec![4, 5, 6])),
Arc::new(Int32Array::from(vec![7, 8, 9])),
],
)
.unwrap();
Expand Down Expand Up @@ -137,9 +136,9 @@ mod tests {
let batch = RecordBatch::try_new(
schema,
vec![
Arc::new(Int32Array::from_slice([1, 2, 3])),
Arc::new(Int32Array::from_slice([4, 5, 6])),
Arc::new(Int32Array::from_slice([7, 8, 9])),
Arc::new(Int32Array::from(vec![1, 2, 3])),
Arc::new(Int32Array::from(vec![4, 5, 6])),
Arc::new(Int32Array::from(vec![7, 8, 9])),
],
)
.unwrap();
Expand Down