diff --git a/common/datablocks/Cargo.toml b/common/datablocks/Cargo.toml index 31dea99702d11..8e5f78ec800ee 100644 --- a/common/datablocks/Cargo.toml +++ b/common/datablocks/Cargo.toml @@ -6,6 +6,10 @@ license = "Apache-2.0" publish = false edition = "2021" +[lib] +doctest = false +test = false + [dependencies] # In alphabetical order # Workspace dependencies common-arrow = {path = "../arrow"} diff --git a/common/datablocks/src/kernels/mod.rs b/common/datablocks/src/kernels/mod.rs index 1ba5e3a870056..7a069970537e7 100644 --- a/common/datablocks/src/kernels/mod.rs +++ b/common/datablocks/src/kernels/mod.rs @@ -12,23 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(test)] -mod data_block_concat_test; -#[cfg(test)] -mod data_block_filter_test; -#[cfg(test)] -mod data_block_group_by_hash_test; -#[cfg(test)] -mod data_block_group_by_test; -#[cfg(test)] -mod data_block_scatter_test; -#[cfg(test)] -mod data_block_slice_test; -#[cfg(test)] -mod data_block_sort_test; -#[cfg(test)] -mod data_block_take_test; - mod data_block_concat; mod data_block_filter; mod data_block_group_by; diff --git a/common/datablocks/src/lib.rs b/common/datablocks/src/lib.rs index e1757ee4d72d7..8f675b5b6ff2c 100644 --- a/common/datablocks/src/lib.rs +++ b/common/datablocks/src/lib.rs @@ -14,9 +14,6 @@ #![feature(hash_raw_entry)] -#[cfg(test)] -mod data_block_test; - mod data_block; mod data_block_debug; mod kernels; diff --git a/common/datablocks/src/data_block_test.rs b/common/datablocks/tests/it/data_block.rs similarity index 97% rename from common/datablocks/src/data_block_test.rs rename to common/datablocks/tests/it/data_block.rs index f95fbaf818e52..4cc64c3d7dc21 100644 --- a/common/datablocks/src/data_block_test.rs +++ b/common/datablocks/tests/it/data_block.rs @@ -12,12 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::DataBlock; use common_datavalues::prelude::*; use common_exception::Result; use pretty_assertions::assert_eq; -use crate::DataBlock; - #[test] fn test_data_block() -> Result<()> { let schema = DataSchemaRefExt::create(vec![DataField::new("a", DataType::Int64, false)]); diff --git a/common/datablocks/src/kernels/data_block_concat_test.rs b/common/datablocks/tests/it/kernels/data_block_concat.rs similarity index 95% rename from common/datablocks/src/kernels/data_block_concat_test.rs rename to common/datablocks/tests/it/kernels/data_block_concat.rs index 0d0d29d215c3b..24d69b3a1fd4a 100644 --- a/common/datablocks/src/kernels/data_block_concat_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_concat.rs @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_datavalues::series::Series; use common_datavalues::series::SeriesFrom; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_concat() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -59,6 +58,6 @@ fn test_data_block_concat() -> Result<()> { "| 9 | b3 |", "+---+----+", ]; - crate::assert_blocks_eq(expected, &[results]); + common_datablocks::assert_blocks_eq(expected, &[results]); Ok(()) } diff --git a/common/datablocks/src/kernels/data_block_filter_test.rs b/common/datablocks/tests/it/kernels/data_block_filter.rs similarity index 93% rename from common/datablocks/src/kernels/data_block_filter_test.rs rename to common/datablocks/tests/it/kernels/data_block_filter.rs index b183df21a81c4..128efada29ac4 100644 --- a/common/datablocks/src/kernels/data_block_filter_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_filter.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::DataBlock; use common_datavalues::columns::DataColumn; use common_datavalues::prelude::SeriesFrom; use common_datavalues::series::Series; @@ -21,8 +22,6 @@ use common_datavalues::DataType; use common_datavalues::DataValue; use common_exception::Result; -use crate::DataBlock; - #[test] fn test_filter_non_const_data_block() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -38,7 +37,7 @@ fn test_filter_non_const_data_block() -> Result<()> { let predicate = Series::new(vec![true, false, true, true, false, false]); let block = DataBlock::filter_block(&block, predicate)?; - crate::assert_blocks_eq( + common_datablocks::assert_blocks_eq( vec![ "+---+----+", "| a | b |", @@ -69,9 +68,10 @@ fn test_filter_all_false_data_block() -> Result<()> { let predicate = Series::new(vec![false, false, false, false, false, false]); let block = DataBlock::filter_block(&block, predicate)?; - crate::assert_blocks_eq(vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"], &[ - block, - ]); + common_datablocks::assert_blocks_eq( + vec!["+---+---+", "| a | b |", "+---+---+", "+---+---+"], + &[block], + ); Ok(()) } @@ -91,7 +91,7 @@ fn test_filter_const_data_block() -> Result<()> { let predicate = Series::new(vec![true, false, true, true, false, false]); let block = DataBlock::filter_block(&block, predicate)?; - crate::assert_blocks_eq( + common_datablocks::assert_blocks_eq( vec![ "+---+----+", "| a | b |", @@ -122,7 +122,7 @@ fn test_filter_all_const_data_block() -> Result<()> { let predicate = Series::new(vec![true, false, true, true, false, false]); let block = DataBlock::filter_block(&block, predicate)?; - crate::assert_blocks_eq( + common_datablocks::assert_blocks_eq( vec![ "+---+----+", "| a | b |", diff --git a/common/datablocks/src/kernels/data_block_group_by_test.rs b/common/datablocks/tests/it/kernels/data_block_group_by.rs similarity index 89% rename from common/datablocks/src/kernels/data_block_group_by_test.rs rename to common/datablocks/tests/it/kernels/data_block_group_by.rs index bee744f421df7..66c020e440f7b 100644 --- a/common/datablocks/src/kernels/data_block_group_by_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_group_by.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_group_by() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -41,7 +40,7 @@ fn test_data_block_group_by() -> Result<()> { "| 3 | x3 |", "+---+----+", ]; - crate::assert_blocks_sorted_eq(expected, &[block]); + common_datablocks::assert_blocks_sorted_eq(expected, &[block]); } 2 => { let expected = vec![ @@ -52,7 +51,7 @@ fn test_data_block_group_by() -> Result<()> { "| 2 | x2 |", "+---+----+", ]; - crate::assert_blocks_sorted_eq(expected, &[block]); + common_datablocks::assert_blocks_sorted_eq(expected, &[block]); } 3 => { let expected = vec![ @@ -64,7 +63,7 @@ fn test_data_block_group_by() -> Result<()> { "| 1 | x1 |", "+---+----+", ]; - crate::assert_blocks_sorted_eq(expected, &[block]); + common_datablocks::assert_blocks_sorted_eq(expected, &[block]); } _ => unreachable!(), } diff --git a/common/datablocks/src/kernels/data_block_group_by_hash_test.rs b/common/datablocks/tests/it/kernels/data_block_group_by_hash.rs similarity index 98% rename from common/datablocks/src/kernels/data_block_group_by_hash_test.rs rename to common/datablocks/tests/it/kernels/data_block_group_by_hash.rs index e7f3d42600f96..526feedfadb96 100644 --- a/common/datablocks/src/kernels/data_block_group_by_hash_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_group_by_hash.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_group_by_hash() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ diff --git a/common/datablocks/src/kernels/data_block_scatter_test.rs b/common/datablocks/tests/it/kernels/data_block_scatter.rs similarity index 94% rename from common/datablocks/src/kernels/data_block_scatter_test.rs rename to common/datablocks/tests/it/kernels/data_block_scatter.rs index 73686a3faedbb..4ea6a315653db 100644 --- a/common/datablocks/src/kernels/data_block_scatter_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_scatter.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_scatter() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -46,7 +45,7 @@ fn test_data_block_scatter() -> Result<()> { "| 2 | 2 |", "+---+---+", ]; - crate::assert_blocks_eq(expected, &scattered); + common_datablocks::assert_blocks_eq(expected, &scattered); Ok(()) } diff --git a/common/datablocks/src/kernels/data_block_slice_test.rs b/common/datablocks/tests/it/kernels/data_block_slice.rs similarity index 94% rename from common/datablocks/src/kernels/data_block_slice_test.rs rename to common/datablocks/tests/it/kernels/data_block_slice.rs index e3f48bc7170be..93e2248aa693b 100644 --- a/common/datablocks/src/kernels/data_block_slice_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_slice.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_slice() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -43,6 +42,6 @@ fn test_data_block_slice() -> Result<()> { "| 5 | 5 |", "+---+---+", ]; - crate::assert_blocks_eq(expected, &sliced); + common_datablocks::assert_blocks_eq(expected, &sliced); Ok(()) } diff --git a/common/datablocks/src/kernels/data_block_sort_test.rs b/common/datablocks/tests/it/kernels/data_block_sort.rs similarity index 93% rename from common/datablocks/src/kernels/data_block_sort_test.rs rename to common/datablocks/tests/it/kernels/data_block_sort.rs index 818420d22683e..de4e42eaa5dbb 100644 --- a/common/datablocks/src/kernels/data_block_sort_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_sort.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_sort() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -47,7 +46,7 @@ fn test_data_block_sort() -> Result<()> { "| 3 | b3 |", "+---+----+", ]; - crate::assert_blocks_eq(expected, &[results]); + common_datablocks::assert_blocks_eq(expected, &[results]); } { @@ -68,7 +67,7 @@ fn test_data_block_sort() -> Result<()> { "| 4 | b2 |", "+---+----+", ]; - crate::assert_blocks_eq(expected, &[results]); + common_datablocks::assert_blocks_eq(expected, &[results]); } Ok(()) } @@ -112,7 +111,7 @@ fn test_data_block_merge_sort() -> Result<()> { "| 7 | b3 |", "+---+----+", ]; - crate::assert_blocks_eq(expected, &[results]); + common_datablocks::assert_blocks_eq(expected, &[results]); } Ok(()) diff --git a/common/datablocks/src/kernels/data_block_take_test.rs b/common/datablocks/tests/it/kernels/data_block_take.rs similarity index 93% rename from common/datablocks/src/kernels/data_block_take_test.rs rename to common/datablocks/tests/it/kernels/data_block_take.rs index 2d9d059ecbf08..23a7514f4a217 100644 --- a/common/datablocks/src/kernels/data_block_take_test.rs +++ b/common/datablocks/tests/it/kernels/data_block_take.rs @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use common_datablocks::*; use common_datavalues::prelude::*; use common_exception::Result; -use crate::*; - #[test] fn test_data_block_take() -> Result<()> { let schema = DataSchemaRefExt::create(vec![ @@ -40,7 +39,7 @@ fn test_data_block_take() -> Result<()> { "| 3 | b3 |", "+---+----+", ]; - crate::assert_blocks_eq(expected, &[take]); + common_datablocks::assert_blocks_eq(expected, &[take]); Ok(()) } diff --git a/common/datablocks/tests/it/kernels/mod.rs b/common/datablocks/tests/it/kernels/mod.rs new file mode 100644 index 0000000000000..0e132642376a3 --- /dev/null +++ b/common/datablocks/tests/it/kernels/mod.rs @@ -0,0 +1,22 @@ +// Copyright 2020 Datafuse Labs. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod data_block_concat; +mod data_block_filter; +mod data_block_group_by; +mod data_block_group_by_hash; +mod data_block_scatter; +mod data_block_slice; +mod data_block_sort; +mod data_block_take; diff --git a/common/datablocks/tests/it/main.rs b/common/datablocks/tests/it/main.rs new file mode 100644 index 0000000000000..2ede246f6e1e7 --- /dev/null +++ b/common/datablocks/tests/it/main.rs @@ -0,0 +1,16 @@ +// Copyright 2020 Datafuse Labs. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod data_block; +mod kernels;