Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,735 changes: 463 additions & 1,272 deletions vortex-array/src/aggregate_fn/fns/all_non_distinct/tests.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions vortex-array/src/arrays/constant/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ use crate::array::ArrayView;
use crate::arrays::Constant;
use crate::arrays::ConstantArray;
use crate::dtype::DType;
use crate::scalar::check_struct_cast_added_fields;
use crate::scalar_fn::builtin::cast::CastReduce;

impl CastReduce for Constant {
fn cast(array: ArrayView<'_, Constant>, dtype: &DType) -> VortexResult<Option<ArrayRef>> {
check_struct_cast_added_fields(array.dtype(), dtype)?;
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
match array.scalar().cast(dtype) {
Ok(scalar) => Ok(Some(ConstantArray::new(scalar, array.len()).into_array())),
Err(_) => Ok(None),
Expand Down
8 changes: 6 additions & 2 deletions vortex-array/src/arrays/struct_/compute/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::dtype::StructFields;
use crate::kernel::ExecuteParentKernel;
use crate::optimizer::kernels::ArrayKernelsExt;
use crate::scalar::Scalar;
use crate::scalar::map_struct_cast_fields;
use crate::scalar_fn::ScalarFnVTable;
use crate::scalar_fn::builtin::cast::Cast;

Expand Down Expand Up @@ -96,8 +97,11 @@ pub(crate) fn struct_cast_fields(
cast_fields.push(cast_field);
}
} else {
for (target_name, target_type) in target_type.names().iter().zip_eq(target_type.fields()) {
match source_sdtype.find(target_name) {
for (src_field_idx, target_type) in map_struct_cast_fields(source_sdtype, target_type)
.into_iter()
.zip_eq(target_type.fields())
{
match src_field_idx {
None => {
// No source field with this name => evolve the schema compatibly.
// If the field is nullable, we add a new ConstantArray field with the type.
Expand Down
2 changes: 2 additions & 0 deletions vortex-array/src/scalar/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use vortex_error::vortex_bail;
use vortex_error::vortex_ensure;
use vortex_error::vortex_err;

use super::check_struct_cast_added_fields;
use crate::dtype::DType;
use crate::dtype::Nullability;
use crate::dtype::PType;
Expand Down Expand Up @@ -60,6 +61,7 @@ impl Scalar {

// Cast nulls after checking the extension dtype restrictions.
if self.value().is_none() || matches!(self.dtype(), DType::Null) {
check_struct_cast_added_fields(self.dtype(), target_dtype)?;
vortex_ensure!(
target_dtype.is_nullable(),
"Cannot cast null to {target_dtype}: target type is non-nullable"
Expand Down
2 changes: 1 addition & 1 deletion vortex-array/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ pub struct Scalar {
}

#[cfg(test)]
mod tests;
pub(crate) mod tests;
Loading
Loading