Skip to content
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
3 changes: 1 addition & 2 deletions src/bin/orc/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ fn run_export<R: ChunkReader>(
output: Box<dyn io::Write>,
) -> Result<()> {
// Build projection mask if columns are specified
let projection = if args.columns.is_some() {
let projection = if let Some(selected) = &args.columns {
// Need to read metadata to build projection
let metadata = read_metadata(&mut source)?;

let selected = args.columns.as_ref().unwrap();
let root_children = metadata.root_data_type().children();
let mut missing: Vec<&str> = selected
.iter()
Expand Down
5 changes: 4 additions & 1 deletion src/encoding/integer/rle_v2/patched_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ pub fn read_patched_base<N: NInt, R: Read, S: EncodingSign>(

let patch_list_length = (fourth_byte & 0x1f) as usize;

let base = N::read_big_endian(reader, base_byte_width)?;
// Read base value as i64 directly
// This matches Java ORC's implementation which always uses long for base values
let base = i64::read_big_endian(reader, base_byte_width)?;
let base = S::decode_signed_msb(base, base_byte_width);
let base = N::from_i64(base);

// Get data values
// TODO: this should read into Vec<i64>
Expand Down
Binary file added tests/basic/data/patched_int.orc
Binary file not shown.
20 changes: 20 additions & 0 deletions tests/basic/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,26 @@ pub fn basic_test_bigint() {
assert_batches_eq(&[last_3_rows], &expected);
}

#[test]
pub fn basic_test_patched_int() {
let path = basic_path("patched_int.orc");
let reader = new_arrow_reader(&path, &["c1"]);
let batch = reader.collect::<Result<Vec<_>, _>>().unwrap();

let total_rows: usize = batch.iter().map(|b| b.num_rows()).sum();
assert_eq!(999596, total_rows);

let last_batch_idx = batch.len() - 1;
let total_rows = batch[last_batch_idx].num_rows();
let last_3_rows = batch[last_batch_idx].slice(total_rows - 3, 3);

let expected = [
"+----+", "| c1 |", "+----+", "| 1 |", "| 1 |", "| 1 |", "+----+",
];

assert_batches_eq(&[last_3_rows], &expected);
}

#[test]
pub fn basic_test_nested_struct() {
let path = basic_path("nested_struct.orc");
Expand Down