Skip to content
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

chore: update delta_kernel to 0.3.0 #2742

Merged
merged 3 commits into from
Aug 8, 2024
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ debug = true
debug = "line-tables-only"

[workspace.dependencies]
delta_kernel = { version = "0.2.0" }
delta_kernel = { version = "0.3.0" }
# delta_kernel = { path = "../delta-kernel-rs/kernel" }

# arrow
Expand Down
40 changes: 33 additions & 7 deletions crates/core/src/kernel/arrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ mod tests {
use std::collections::HashMap;
use std::sync::Arc;

use arrow_array::{MapArray, RecordBatch};
use arrow::array::ArrayData;
use arrow_array::{Array, BinaryArray, MapArray, RecordBatch, StringArray, StructArray};
use arrow_buffer::{Buffer, ToByteSlice};
use delta_kernel::schema::{DataType, MapType, PrimitiveType, StructField, StructType};

use super::*;
Expand Down Expand Up @@ -521,12 +523,36 @@ mod tests {
let entry_offsets = vec![0u32, 1, 1, 4, 5, 5];
let num_rows = keys.len();

let map_array = MapArray::new_from_strings(
keys.into_iter(),
&arrow::array::BinaryArray::from(values),
entry_offsets.as_slice(),
)
.expect("Could not create a map array");
let key_field = Arc::new(ArrowField::new(MAP_KEY_DEFAULT, ArrowDataType::Utf8, false));
let value_field = Arc::new(ArrowField::new(
MAP_VALUE_DEFAULT,
ArrowDataType::Binary,
false,
));
let key_value_field = ArrowField::new_struct(
MAP_ROOT_DEFAULT,
vec![key_field.clone(), value_field.clone()],
false,
);
let key_value_array = StructArray::new(
vec![key_field, value_field].into(),
vec![
Arc::new(StringArray::from(keys)),
Arc::new(BinaryArray::from(values)),
],
None,
);
let entry_offsets_buffer = Buffer::from(entry_offsets.as_slice().to_byte_slice());

let map_data_type = ArrowDataType::Map(Arc::new(key_value_field), false);
let map_data = ArrayData::builder(map_data_type)
.len(entry_offsets.len() - 1)
.add_buffer(entry_offsets_buffer)
.add_child_data(key_value_array.into_data())
.build()
.unwrap();

let map_array = MapArray::from(map_data);

let schema =
<arrow::datatypes::Schema as TryFrom<&StructType>>::try_from(&StructType::new(vec![
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/table/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::time::Duration;
use std::{collections::HashMap, str::FromStr};

use delta_kernel::column_mapping::ColumnMappingMode;
use delta_kernel::features::ColumnMappingMode;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};

Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/table/state_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use arrow_array::{
StringArray, StructArray, TimestampMicrosecondArray, TimestampMillisecondArray,
};
use arrow_schema::{DataType, Field, Fields, TimeUnit};
use delta_kernel::column_mapping::ColumnMappingMode;
use delta_kernel::features::ColumnMappingMode;
use itertools::Itertools;

use super::state::DeltaTableState;
Expand Down
Loading