-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Minor: Encapsulate type check in GroupValuesColumn, avoid panic #12620
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from 1 commit
70da69f
7a93013
569a6ee
515c9a4
6ce9c51
0dd53fc
707a8b1
fc51090
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 |
---|---|---|
|
@@ -27,9 +27,9 @@ use arrow::datatypes::{ | |
}; | ||
use arrow::record_batch::RecordBatch; | ||
use arrow_array::{Array, ArrayRef}; | ||
use arrow_schema::{DataType, SchemaRef}; | ||
use arrow_schema::{DataType, Schema, SchemaRef}; | ||
use datafusion_common::hash_utils::create_hashes; | ||
use datafusion_common::{DataFusionError, Result}; | ||
use datafusion_common::{internal_err, DataFusionError, Result}; | ||
use datafusion_execution::memory_pool::proxy::{RawTableAllocExt, VecAllocExt}; | ||
use datafusion_expr::EmitTo; | ||
use datafusion_physical_expr::binary_map::OutputType; | ||
|
@@ -67,6 +67,7 @@ pub struct GroupValuesColumn { | |
} | ||
|
||
impl GroupValuesColumn { | ||
/// Create a new instance of GroupValuesColumn if supported for the specified schema | ||
pub fn try_new(schema: SchemaRef) -> Result<Self> { | ||
let map = RawTable::with_capacity(0); | ||
Ok(Self { | ||
|
@@ -78,6 +79,38 @@ impl GroupValuesColumn { | |
random_state: Default::default(), | ||
}) | ||
} | ||
|
||
/// Returns true if [`GroupValuesColumn`] supports for the specified schema | ||
pub fn supported_schema(schema: &Schema) -> bool { | ||
schema | ||
.fields() | ||
.iter() | ||
.map(|f| f.data_type()) | ||
.all(Self::supported_type) | ||
} | ||
|
||
/// Returns true if the specified data type is supported by [`GroupValuesColumn`] | ||
fn supported_type(data_type: &DataType) -> bool { | ||
matches!( | ||
*data_type, | ||
DataType::Int8 | ||
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. should we use we can also use 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 list needs to be kept in sync with what special implementations are available in |
||
| DataType::Int16 | ||
| DataType::Int32 | ||
| DataType::Int64 | ||
| DataType::UInt8 | ||
| DataType::UInt16 | ||
| DataType::UInt32 | ||
| DataType::UInt64 | ||
| DataType::Float32 | ||
| DataType::Float64 | ||
| DataType::Utf8 | ||
| DataType::LargeUtf8 | ||
| DataType::Binary | ||
| DataType::LargeBinary | ||
| DataType::Date32 | ||
| DataType::Date64 | ||
) | ||
} | ||
} | ||
|
||
impl GroupValues for GroupValuesColumn { | ||
|
@@ -154,7 +187,9 @@ impl GroupValues for GroupValuesColumn { | |
let b = ByteGroupValueBuilder::<i64>::new(OutputType::Binary); | ||
v.push(Box::new(b) as _) | ||
} | ||
dt => todo!("{dt} not impl"), | ||
dt => { | ||
return internal_err!("{dt} not supported in GroupValuesColumn") | ||
alamb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
self.group_values = v; | ||
|
Uh oh!
There was an error while loading. Please reload this page.