-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement comparisons on nested data types such that distinct/except would work #11117
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,13 +52,15 @@ use arrow::array::{ | |
| Array, ArrayRef, BooleanArray, BooleanBufferBuilder, PrimitiveArray, UInt32Array, | ||
| UInt64Array, | ||
| }; | ||
| use arrow::buffer::NullBuffer; | ||
| use arrow::compute::kernels::cmp::{eq, not_distinct}; | ||
| use arrow::compute::{and, concat_batches, take, FilterBuilder}; | ||
| use arrow::datatypes::{Schema, SchemaRef}; | ||
| use arrow::record_batch::RecordBatch; | ||
| use arrow::util::bit_util; | ||
| use arrow_array::cast::downcast_array; | ||
| use arrow_schema::ArrowError; | ||
| use arrow_ord::ord::make_comparator; | ||
| use arrow_schema::{ArrowError, SortOptions}; | ||
| use datafusion_common::utils::memory::estimate_memory_size; | ||
| use datafusion_common::{ | ||
| internal_datafusion_err, internal_err, plan_err, project_schema, DataFusionError, | ||
|
|
@@ -1210,6 +1212,16 @@ fn eq_dyn_null( | |
| right: &dyn Array, | ||
| null_equals_null: bool, | ||
| ) -> Result<BooleanArray, ArrowError> { | ||
| // Nested datatypes cannot use the underlying not_distinct function and must use a special | ||
| // implementation | ||
| // <https://github.com/apache/datafusion/issues/10749> | ||
| if left.data_type().is_nested() && null_equals_null { | ||
| let cmp = make_comparator(left, right, SortOptions::default())?; | ||
| let len = left.len().min(right.len()); | ||
| let values = (0..len).map(|i| cmp(i, i).is_eq()).collect(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is likely quite slow as it will be doing dynamic dispatch per row. However, slow is better than not working at first. Could you please: update the name of the function to reflect it isn't just for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think other than the potential rename the PR is ready to go -- however I also think we could do the rename as a follow on PR Note @jayzhan211 added similiar code to handle nested comparisons in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do the comparison with datum function, I move it to physical-common in #11091
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in #11149 |
||
| let nulls = NullBuffer::union(left.nulls(), right.nulls()); | ||
| return Ok(BooleanArray::new(values, nulls)); | ||
| } | ||
| match (left.data_type(), right.data_type()) { | ||
| _ if null_equals_null => not_distinct(&left, &right), | ||
| _ => eq(&left, &right), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.