You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jonathanc-n (via GitHub)" <gi...@apache.org> on 2024/11/06 20:45:45 UTC
[PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
jonathanc-n opened a new pull request, #13280:
URL: https://github.com/apache/datafusion/pull/13280
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #13279.
## What changes are included in this PR?
Added timestamp, binary, and float for the fuzz testing
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1833585363
##########
test-utils/src/array_gen/binary.rs:
##########
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+use arrow::array::{
+ ArrayRef, BinaryViewArray, GenericBinaryArray, OffsetSizeTrait, UInt32Array,
+};
+use arrow::compute;
+use rand::rngs::StdRng;
+use rand::Rng;
+
+/// Randomly generate binary arrays
+pub struct BinaryArrayGenerator {
+ /// The maximum length of each binary element
+ pub max_len: usize,
+ /// The total number of binaries in the output
+ pub num_binaries: usize,
+ /// The number of distinct binary values in the columns
+ pub num_distinct_binaries: usize,
+ /// The percentage of nulls in the columns
+ pub null_pct: f64,
+ /// Random number generator
+ pub rng: StdRng,
+}
+
+impl BinaryArrayGenerator {
Review Comment:
Love it, thinking of if we should tests for this generator?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "LeslieKid (via GitHub)" <gi...@apache.org>.
LeslieKid commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1832163669
##########
datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs:
##########
@@ -171,6 +172,25 @@ fn baseline_config() -> DatasetGeneratorConfig {
ColumnDescr::new("time32_ms", DataType::Time32(TimeUnit::Millisecond)),
ColumnDescr::new("time64_us", DataType::Time64(TimeUnit::Microsecond)),
ColumnDescr::new("time64_ns", DataType::Time64(TimeUnit::Nanosecond)),
+ // TODO: randomize timezones for timestamp types
+ ColumnDescr::new("timestamp_s", DataType::Timestamp(TimeUnit::Second, None)),
+ ColumnDescr::new(
+ "timestamp_ms",
+ DataType::Timestamp(TimeUnit::Millisecond, None),
+ ),
+ ColumnDescr::new(
+ "timestamp_us",
+ DataType::Timestamp(TimeUnit::Microsecond, None),
+ ),
+ ColumnDescr::new(
+ "timestamp_ns",
+ DataType::Timestamp(TimeUnit::Nanosecond, None),
+ ),
+ ColumnDescr::new("binary", DataType::Binary),
+ ColumnDescr::new("large_binary", DataType::LargeBinary),
+ ColumnDescr::new("binaryview", DataType::BinaryView),
Review Comment:
I think we can put `binary` types near `string` instead of placing it in the middle of some fixed-size primitive types.
##########
test-utils/src/array_gen/binary.rs:
##########
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+use arrow::array::{
+ ArrayRef, BinaryViewArray, GenericBinaryArray, OffsetSizeTrait, UInt32Array,
+};
+use arrow::compute;
+use rand::rngs::StdRng;
+use rand::Rng;
+
+/// Randomly generate binary arrays
+pub struct BinaryArrayGenerator {
Review Comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1835627476
##########
test-utils/src/array_gen/binary.rs:
##########
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+use arrow::array::{
+ ArrayRef, BinaryViewArray, GenericBinaryArray, OffsetSizeTrait, UInt32Array,
+};
+use arrow::compute;
+use rand::rngs::StdRng;
+use rand::Rng;
+
+/// Randomly generate binary arrays
+pub struct BinaryArrayGenerator {
+ /// The maximum length of each binary element
+ pub max_len: usize,
+ /// The total number of binaries in the output
+ pub num_binaries: usize,
+ /// The number of distinct binary values in the columns
+ pub num_distinct_binaries: usize,
+ /// The percentage of nulls in the columns
+ pub null_pct: f64,
+ /// Random number generator
+ pub rng: StdRng,
+}
+
+impl BinaryArrayGenerator {
+ /// Creates a BinaryArray or LargeBinaryArray with random binary data.
+ pub fn gen_data<O: OffsetSizeTrait>(&mut self) -> ArrayRef {
+ let distinct_binaries: GenericBinaryArray<O> = (0..self.num_distinct_binaries)
+ .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
+ .collect();
+
+ // Pick num_binaries randomly from the distinct binary table
+ let indices: UInt32Array = (0..self.num_binaries)
+ .map(|_| {
+ if self.rng.gen::<f64>() < self.null_pct {
+ None
+ } else if self.num_distinct_binaries > 1 {
+ let range = 0..(self.num_distinct_binaries as u32);
+ Some(self.rng.gen_range(range))
+ } else {
+ Some(0)
+ }
+ })
+ .collect();
+
+ compute::take(&distinct_binaries, &indices, None).unwrap()
+ }
+
+ /// Creates a BinaryViewArray with random binary data.
+ pub fn gen_binary_view(&mut self) -> ArrayRef {
+ let distinct_binary_views: BinaryViewArray = (0..self.num_distinct_binaries)
+ .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
+ .collect();
+
+ let indices: UInt32Array = (0..self.num_binaries)
+ .map(|_| {
+ if self.rng.gen::<f64>() < self.null_pct {
+ None
+ } else if self.num_distinct_binaries > 1 {
+ let range = 0..(self.num_distinct_binaries as u32);
+ Some(self.rng.gen_range(range))
+ } else {
+ Some(0)
+ }
+ })
+ .collect();
+
+ compute::take(&distinct_binary_views, &indices, None).unwrap()
+ }
+}
+
+/// Return a binary vector of random bytes of length 1..=max_len
+fn random_binary(rng: &mut StdRng, max_len: usize) -> Vec<u8> {
+ if max_len == 0 {
+ Vec::new()
+ } else {
+ let len = rng.gen_range(1..=max_len);
+ (0..len).map(|_| rng.gen()).collect()
Review Comment:
It seems that `len` is the actual length of the value, which is drawn between `1..max_len`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1833584521
##########
test-utils/src/array_gen/binary.rs:
##########
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+use arrow::array::{
+ ArrayRef, BinaryViewArray, GenericBinaryArray, OffsetSizeTrait, UInt32Array,
+};
+use arrow::compute;
+use rand::rngs::StdRng;
+use rand::Rng;
+
+/// Randomly generate binary arrays
+pub struct BinaryArrayGenerator {
+ /// The maximum length of each binary element
+ pub max_len: usize,
+ /// The total number of binaries in the output
+ pub num_binaries: usize,
+ /// The number of distinct binary values in the columns
+ pub num_distinct_binaries: usize,
+ /// The percentage of nulls in the columns
+ pub null_pct: f64,
+ /// Random number generator
+ pub rng: StdRng,
+}
+
+impl BinaryArrayGenerator {
+ /// Creates a BinaryArray or LargeBinaryArray with random binary data.
+ pub fn gen_data<O: OffsetSizeTrait>(&mut self) -> ArrayRef {
+ let distinct_binaries: GenericBinaryArray<O> = (0..self.num_distinct_binaries)
+ .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
+ .collect();
+
+ // Pick num_binaries randomly from the distinct binary table
+ let indices: UInt32Array = (0..self.num_binaries)
+ .map(|_| {
+ if self.rng.gen::<f64>() < self.null_pct {
+ None
+ } else if self.num_distinct_binaries > 1 {
+ let range = 0..(self.num_distinct_binaries as u32);
+ Some(self.rng.gen_range(range))
+ } else {
+ Some(0)
+ }
+ })
+ .collect();
+
+ compute::take(&distinct_binaries, &indices, None).unwrap()
+ }
+
+ /// Creates a BinaryViewArray with random binary data.
+ pub fn gen_binary_view(&mut self) -> ArrayRef {
+ let distinct_binary_views: BinaryViewArray = (0..self.num_distinct_binaries)
+ .map(|_| Some(random_binary(&mut self.rng, self.max_len)))
+ .collect();
+
+ let indices: UInt32Array = (0..self.num_binaries)
+ .map(|_| {
+ if self.rng.gen::<f64>() < self.null_pct {
+ None
+ } else if self.num_distinct_binaries > 1 {
+ let range = 0..(self.num_distinct_binaries as u32);
+ Some(self.rng.gen_range(range))
+ } else {
+ Some(0)
+ }
+ })
+ .collect();
+
+ compute::take(&distinct_binary_views, &indices, None).unwrap()
+ }
+}
+
+/// Return a binary vector of random bytes of length 1..=max_len
+fn random_binary(rng: &mut StdRng, max_len: usize) -> Vec<u8> {
+ if max_len == 0 {
+ Vec::new()
+ } else {
+ let len = rng.gen_range(1..=max_len);
+ (0..len).map(|_| rng.gen()).collect()
Review Comment:
wondering if `len` differs from `max_len`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1835134347
##########
test-utils/src/array_gen/binary.rs:
##########
@@ -0,0 +1,94 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+use arrow::array::{
+ ArrayRef, BinaryViewArray, GenericBinaryArray, OffsetSizeTrait, UInt32Array,
+};
+use arrow::compute;
+use rand::rngs::StdRng;
+use rand::Rng;
+
+/// Randomly generate binary arrays
+pub struct BinaryArrayGenerator {
+ /// The maximum length of each binary element
+ pub max_len: usize,
+ /// The total number of binaries in the output
+ pub num_binaries: usize,
+ /// The number of distinct binary values in the columns
+ pub num_distinct_binaries: usize,
+ /// The percentage of nulls in the columns
+ pub null_pct: f64,
+ /// Random number generator
+ pub rng: StdRng,
+}
+
+impl BinaryArrayGenerator {
Review Comment:
the generator itself is part of a test 🤔 What would we test? Maybe that the distinct values are as specified?
##########
datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs:
##########
@@ -210,6 +226,9 @@ fn baseline_config() -> DatasetGeneratorConfig {
// low cardinality columns
ColumnDescr::new("u8_low", DataType::UInt8).with_max_num_distinct(10),
ColumnDescr::new("utf8_low", DataType::Utf8).with_max_num_distinct(10),
+ ColumnDescr::new("binary", DataType::Binary),
Review Comment:
we could potentially remove the `todo binary` a few lines above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "LeslieKid (via GitHub)" <gi...@apache.org>.
LeslieKid commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1832163669
##########
datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs:
##########
@@ -171,6 +172,25 @@ fn baseline_config() -> DatasetGeneratorConfig {
ColumnDescr::new("time32_ms", DataType::Time32(TimeUnit::Millisecond)),
ColumnDescr::new("time64_us", DataType::Time64(TimeUnit::Microsecond)),
ColumnDescr::new("time64_ns", DataType::Time64(TimeUnit::Nanosecond)),
+ // TODO: randomize timezones for timestamp types
+ ColumnDescr::new("timestamp_s", DataType::Timestamp(TimeUnit::Second, None)),
+ ColumnDescr::new(
+ "timestamp_ms",
+ DataType::Timestamp(TimeUnit::Millisecond, None),
+ ),
+ ColumnDescr::new(
+ "timestamp_us",
+ DataType::Timestamp(TimeUnit::Microsecond, None),
+ ),
+ ColumnDescr::new(
+ "timestamp_ns",
+ DataType::Timestamp(TimeUnit::Nanosecond, None),
+ ),
+ ColumnDescr::new("binary", DataType::Binary),
+ ColumnDescr::new("large_binary", DataType::LargeBinary),
+ ColumnDescr::new("binaryview", DataType::BinaryView),
Review Comment:
I think we can put `binary` near `string` types instead of placing it in the middle of some fixed-size primitive types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#discussion_r1833583245
##########
datafusion/core/tests/fuzz_cases/aggregate_fuzz.rs:
##########
@@ -171,6 +172,22 @@ fn baseline_config() -> DatasetGeneratorConfig {
ColumnDescr::new("time32_ms", DataType::Time32(TimeUnit::Millisecond)),
ColumnDescr::new("time64_us", DataType::Time64(TimeUnit::Microsecond)),
ColumnDescr::new("time64_ns", DataType::Time64(TimeUnit::Nanosecond)),
+ // TODO: randomize timezones for timestamp types
Review Comment:
lets create a ticket instead of todo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #13280:
URL: https://github.com/apache/datafusion/pull/13280#issuecomment-2466648050
Thanks again @jonathanc-n -- and thanks to @comphead @LeslieKid for the reviews
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] feat: Added Timestamp/Binary/Float to fuzz [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #13280:
URL: https://github.com/apache/datafusion/pull/13280
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org