Apache DataFusion SQL Query Engine
ARROW-5053: [Rust] [DataFusion] Use ARROW_TEST_DATA env var
Andy Grove456c4be98fc7
diff --git a/ci/cpp-msvc-build-main.bat b/ci/cpp-msvc-build-main.batindex da28d88917..13dab24800 100644--- a/ci/cpp-msvc-build-main.bat+++ b/ci/cpp-msvc-build-main.bat@@ -35,6 +35,7 @@ if "%JOB%" == "Toolchain" (@rem Retrieve git submodules, configure env var for Parquet unit testsgit submodule update --init || exit /B+set ARROW_TEST_DATA=%CD%\testing\dataset PARQUET_TEST_DATA=%CD%\cpp\submodules\parquet-testing\data@rem Enable warnings-as-errorsdiff --git a/ci/rust-build-main.bat b/ci/rust-build-main.batindex b36a97acf5..5bf1c84392 100644--- a/ci/rust-build-main.bat+++ b/ci/rust-build-main.bat@@ -19,6 +19,7 @@@rem Retrieve git submodules, configure env var for Parquet unit testsgit submodule update --init || exit /B+set ARROW_TEST_DATA=%CD%\testing\dataset PARQUET_TEST_DATA=%CD%\cpp\submodules\parquet-testing\datapushd rustdiff --git a/ci/travis_env_common.sh b/ci/travis_env_common.shindex a1cc125c76..d0cc415e11 100755--- a/ci/travis_env_common.sh+++ b/ci/travis_env_common.sh@@ -73,6 +73,7 @@ if [ $TRAVIS_OS_NAME == "osx" ]; thenexport GOPATH=$TRAVIS_BUILD_DIR/gopathfi+export ARROW_TEST_DATA=$TRAVIS_BUILD_DIR/testing/dataexport PARQUET_TEST_DATA=$TRAVIS_BUILD_DIR/cpp/submodules/parquet-testing/data# e.g. "trusty" or "xenial"diff --git a/dev/release/verify-release-candidate.bat b/dev/release/verify-release-candidate.batindex 5072112ded..3f6d95c17c 100644--- a/dev/release/verify-release-candidate.bat+++ b/dev/release/verify-release-candidate.bat@@ -84,6 +84,9 @@ cmake --build . --target INSTALL --config %CONFIGURATION% || exit /Bgit clone https://github.com/apache/parquet-testing.git %_VERIFICATION_DIR%\parquet-testingset PARQUET_TEST_DATA=%_VERIFICATION_DIR%\parquet-testing\data+git clone https://github.com/apache/arrow-testing.git %_VERIFICATION_DIR%\arrow-testing+set ARROW_TEST_DATA=%_VERIFICATION_DIR%\arrow-testing\data+@rem Needed so python-test.exe worksset PYTHONPATH=%CONDA_PREFIX%\Lib;%CONDA_PREFIX%\Lib\site-packages;%CONDA_PREFIX%\python35.zip;%CONDA_PREFIX%\DLLs;%CONDA_PREFIX%;%PYTHONPATH%diff --git a/dev/release/verify-release-candidate.sh b/dev/release/verify-release-candidate.shindex c8c631c480..3b558d0a2c 100755--- a/dev/release/verify-release-candidate.sh+++ b/dev/release/verify-release-candidate.sh@@ -403,6 +403,9 @@ if [ "$ARTIFACT" == "source" ]; thenTEST_JAVA=$((${TEST_JAVA} + ${TEST_INTEGRATION}))TEST_JS=$((${TEST_JS} + ${TEST_INTEGRATION}))+ git clone https://github.com/apache/arrow-testing.git+ export ARROW_TEST_DATA=$PWD/arrow-testing/data+git clone https://github.com/apache/parquet-testing.gitexport PARQUET_TEST_DATA=$PWD/parquet-testing/data@@ -410,9 +413,6 @@ if [ "$ARTIFACT" == "source" ]; thentar xvzf ${DIST_NAME}.tar.gzcd ${DIST_NAME}- rm -r testing- git clone https://github.com/apache/arrow-testing.git testing-if [ ${TEST_JAVA} -gt 0 ]; thentest_package_javafidiff --git a/rust/README.md b/rust/README.mdindex a968052f30..377cf6c6fe 100644--- a/rust/README.md+++ b/rust/README.md@@ -46,8 +46,14 @@ This populates data in two git submodules:- `cpp/submodules/parquet_testing/data` (sourced from https://github.com/apache/parquet-testing.git)- `testing` (sourced from https://github.com/apache/arrow-testing)-Create a new environment variable called `PARQUET_TEST_DATA` to point-to `cpp/submodules/parquet-testing/data` and then `cargo test` as usual.+Create two new environment variables to point to these directories as follows:++```bash+export PARQUET_TEST_DATA=/path/to/arrow/cpp/submodules/parquet-testing/data+export ARROW_TEST_DATA=/path/to/arrow/testing/data/+```++It is now possible to run `cargo test` as usual.## Code Formattingdiff --git a/rust/datafusion/benches/aggregate_query_sql.rs b/rust/datafusion/benches/aggregate_query_sql.rsindex bde8787920..d0c1b0f649 100644--- a/rust/datafusion/benches/aggregate_query_sql.rs+++ b/rust/datafusion/benches/aggregate_query_sql.rs@@ -20,6 +20,7 @@ extern crate criterion;use criterion::Criterion;use std::cell::RefCell;+use std::env;use std::rc::Rc;use std::sync::Arc;@@ -60,9 +61,11 @@ fn create_context() -> Rc<RefCell<ExecutionContext>> {Field::new("c13", DataType::Utf8, false),]));+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");+// create CSV data sourcelet csv = CsvFile::new(- "../../testing/data/csv/aggregate_test_100.csv",+ &format!("{}/csv/aggregate_test_100.csv", testdata),&schema,true,);diff --git a/rust/datafusion/src/datasource/parquet.rs b/rust/datafusion/src/datasource/parquet.rsindex 79e84ce8df..b645bcecd8 100644--- a/rust/datafusion/src/datasource/parquet.rs+++ b/rust/datafusion/src/datasource/parquet.rs@@ -678,7 +678,8 @@ mod tests {}fn load_table(name: &str) -> Box<TableProvider> {- let testdata = env::var("PARQUET_TEST_DATA").unwrap();+ let testdata =+ env::var("PARQUET_TEST_DATA").expect("PARQUET_TEST_DATA not defined");let filename = format!("{}/{}", testdata, name);let table = ParquetTable::try_new(&filename).unwrap();Box::new(table)diff --git a/rust/datafusion/src/execution/aggregate.rs b/rust/datafusion/src/execution/aggregate.rsindex 4417d13bc5..84fe925086 100644--- a/rust/datafusion/src/execution/aggregate.rs+++ b/rust/datafusion/src/execution/aggregate.rs@@ -1030,12 +1030,15 @@ mod tests {use crate::execution::relation::DataSourceRelation;use crate::logicalplan::Expr;use arrow::datatypes::{DataType, Field, Schema};+ use std::env;use std::sync::Mutex;#[test]fn min_f64_group_by_string() {let schema = aggr_test_schema();- let relation = load_csv("../../testing/data/csv/aggregate_test_100.csv", &schema);+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");+ let relation =+ load_csv(&format!("{}/csv/aggregate_test_100.csv", testdata), &schema);let context = ExecutionContext::new();let aggr_expr = vec![expression::compile_aggregate_expr(@@ -1070,7 +1073,9 @@ mod tests {#[test]fn max_f64_group_by_string() {let schema = aggr_test_schema();- let relation = load_csv("../../testing/data/csv/aggregate_test_100.csv", &schema);+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");+ let relation =+ load_csv(&format!("{}/csv/aggregate_test_100.csv", testdata), &schema);let context = ExecutionContext::new();let aggr_expr = vec![expression::compile_aggregate_expr(@@ -1105,7 +1110,9 @@ mod tests {#[test]fn test_min_max_sum_f64_group_by_uint32() {let schema = aggr_test_schema();- let relation = load_csv("../../testing/data/csv/aggregate_test_100.csv", &schema);+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");+ let relation =+ load_csv(&format!("{}/csv/aggregate_test_100.csv", testdata), &schema);let context = ExecutionContext::new();diff --git a/rust/datafusion/src/execution/projection.rs b/rust/datafusion/src/execution/projection.rsindex cf91409dc8..6f458cd08d 100644--- a/rust/datafusion/src/execution/projection.rs+++ b/rust/datafusion/src/execution/projection.rs@@ -93,6 +93,7 @@ mod tests {use crate::execution::relation::DataSourceRelation;use crate::logicalplan::Expr;use arrow::datatypes::{DataType, Field, Schema};+ use std::env;use std::sync::Mutex;#[test]@@ -113,8 +114,10 @@ mod tests {Field::new("c12", DataType::Utf8, false),]));+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");+let ds = CsvBatchIterator::new(- "../../testing/data/csv/aggregate_test_100.csv",+ &format!("{}/csv/aggregate_test_100.csv", testdata),schema.clone(),true,&None,diff --git a/rust/datafusion/src/table.rs b/rust/datafusion/src/table.rsindex b1421c6ff0..a7720f21e5 100644--- a/rust/datafusion/src/table.rs+++ b/rust/datafusion/src/table.rs@@ -39,6 +39,7 @@ mod tests {use super::*;use crate::execution::context::ExecutionContext;use arrow::datatypes::*;+ use std::env;#[test]fn demonstrate_api_usage() {@@ -60,9 +61,10 @@ mod tests {fn register_aggregate_csv(ctx: &mut ExecutionContext) {let schema = aggr_test_schema();+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");ctx.register_csv("aggregate_test_100",- "../../testing/data/csv/aggregate_test_100.csv",+ &format!("{}/csv/aggregate_test_100.csv", testdata),&schema,true,);diff --git a/rust/datafusion/tests/sql.rs b/rust/datafusion/tests/sql.rsindex 6a61eb5d7e..7b046096fd 100644--- a/rust/datafusion/tests/sql.rs+++ b/rust/datafusion/tests/sql.rs@@ -171,11 +171,12 @@ fn aggr_test_schema() -> Arc<Schema> {}fn register_aggregate_csv(ctx: &mut ExecutionContext) {+ let testdata = env::var("ARROW_TEST_DATA").expect("ARROW_TEST_DATA not defined");let schema = aggr_test_schema();register_csv(ctx,"aggregate_test_100",- "../../testing/data/csv/aggregate_test_100.csv",+ &format!("{}/csv/aggregate_test_100.csv", testdata),&schema,);}@@ -190,7 +191,7 @@ fn register_csv(}fn load_parquet_table(name: &str) -> Rc<TableProvider> {- let testdata = env::var("PARQUET_TEST_DATA").unwrap();+ let testdata = env::var("PARQUET_TEST_DATA").expect("PARQUET_TEST_DATA not defined");let filename = format!("{}/{}", testdata, name);let table = ParquetTable::try_new(&filename).unwrap();Rc::new(table)