Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-04-25 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-4320112532

   Oh no, I don't know how this was closed. I will pick it back up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-03-15 Thread via GitHub


vegarsti closed pull request #8069: Support writing RunEndEncoded as Parquet
URL: https://github.com/apache/arrow-rs/pull/8069


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-02-04 Thread via GitHub


Jefffrey commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3847818909

   I'm not too sure myself; I can try take a look some time later, though it 
might be easier once this is merged up with main so we have the latest changes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-02-03 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3839931552

   Thank you @Jefffrey! I will add your suggestions, and thanks for the PR 
link. Do you have any clue about the Decimal types that I commented on above? 
It kinda looks like I'm not doing the right thing there... 
https://github.com/apache/arrow-rs/pull/8069/files/87f068a4a818a626de37d4833fe3b187a627d010#diff-dbb6b7806a48ce2b6fb40ce4a429599808a87671274ee6b2dc7c1f87429320b3


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-01-12 Thread via GitHub


Jefffrey commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3738562060

   FYI looks like
   
   - https://github.com/apache/arrow-rs/pull/9077
   
   Has refactored some stuff in relation to dictionary handling


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2026-01-10 Thread via GitHub


Jefffrey commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2678607159


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -1122,6 +1122,17 @@ impl ArrowColumnWriterFactory {
 ArrowDataType::FixedSizeBinary(_) => 
out.push(bytes(leaves.next().unwrap())?),
 _ => out.push(col(leaves.next().unwrap())?),
 },
+ArrowDataType::RunEndEncoded(_, value_type) => match 
value_type.data_type() {
+ArrowDataType::Utf8
+| ArrowDataType::LargeUtf8
+| ArrowDataType::Binary
+| ArrowDataType::LargeBinary => 
out.push(bytes(leaves.next().unwrap())?),
+ArrowDataType::Utf8View | ArrowDataType::BinaryView => {
+out.push(bytes(leaves.next().unwrap())?)
+}
+ArrowDataType::FixedSizeBinary(_) => 
out.push(bytes(leaves.next().unwrap())?),

Review Comment:
   ```suggestion
   | ArrowDataType::LargeBinary
   | ArrowDataType::Utf8View
   | ArrowDataType::BinaryView
   | ArrowDataType::FixedSizeBinary(_) => 
out.push(bytes(leaves.next().unwrap())?),
   ```



##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4624,408 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {

Review Comment:
   These tests have lots of duplicated code, would be nice to pull into a 
helper so it's easier to see where the tests differ



##
parquet/src/arrow/arrow_writer/byte_array.rs:
##
@@ -92,6 +114,26 @@ macro_rules! downcast_op {
 }
 d => unreachable!("cannot downcast {} dictionary value to byte 
array", d),
 },
+DataType::RunEndEncoded(run_end, value) => match value.data_type() 
{
+DataType::Utf8 => downcast_ree_op!(run_end, StringArray, 
$array, $op$(, $arg)*),
+DataType::LargeUtf8 => {
+downcast_ree_op!(run_end, LargeStringArray, $array, $op$(, 
$arg)*)
+}
+DataType::Utf8View => {

Review Comment:
   Probably not for this PR, but I notice the dictionary arms above don't have 
string/binary views 🤔 



##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4624,408 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {
+// Create a run array of strings
+let mut builder = StringRunBuildernew();
+builder.extend(
+vec![Some("alpha"); 10]
+.into_iter()
+.chain(vec![Some("beta"); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Utf8, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, reader.schema());
+
+// Read the data back
+let batches: Vec<_> = reader
+.build()
+.unwrap()
+.collect::>>()
+.unwrap();
+assert_eq!(batches.len(), 196);

Review Comment:
   Personally I'd omit the batches len 

Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-06 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594649992


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4624,408 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {
+// Create a run array of strings
+let mut builder = StringRunBuildernew();
+builder.extend(
+vec![Some("alpha"); 10]
+.into_iter()
+.chain(vec![Some("beta"); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Utf8, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, reader.schema());
+
+// Read the data back
+let batches: Vec<_> = reader
+.build()
+.unwrap()
+.collect::>>()
+.unwrap();
+assert_eq!(batches.len(), 196);
+// Count rows in total
+let total_rows = batches.iter().map(|b| b.num_rows()).sum::();
+assert_eq!(total_rows, 20);
+
+// Ensure dictionary encoding
+assert!(has_dict_encoding, "RunArray should be dictionary encoded");
+assert!(has_dict_page, "RunArray should have dictionary page");
+}
+
+#[test]
+fn arrow_writer_run_end_encoded_int() {
+// Create a run array of strings
+let mut builder = PrimitiveRunBuildernew();
+builder.extend(
+vec![Some(1); 10]
+.into_iter()
+.chain(vec![Some(2); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Int32, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, 

Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-06 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594648608


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4624,408 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {
+// Create a run array of strings
+let mut builder = StringRunBuildernew();
+builder.extend(
+vec![Some("alpha"); 10]
+.into_iter()
+.chain(vec![Some("beta"); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Utf8, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, reader.schema());
+
+// Read the data back
+let batches: Vec<_> = reader
+.build()
+.unwrap()
+.collect::>>()
+.unwrap();
+assert_eq!(batches.len(), 196);
+// Count rows in total
+let total_rows = batches.iter().map(|b| b.num_rows()).sum::();
+assert_eq!(total_rows, 20);
+
+// Ensure dictionary encoding
+assert!(has_dict_encoding, "RunArray should be dictionary encoded");
+assert!(has_dict_page, "RunArray should have dictionary page");
+}
+
+#[test]
+fn arrow_writer_run_end_encoded_int() {
+// Create a run array of strings
+let mut builder = PrimitiveRunBuildernew();
+builder.extend(
+vec![Some(1); 10]
+.into_iter()
+.chain(vec![Some(2); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Int32, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, 

Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-06 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594644493


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -1215,6 +1226,41 @@ fn write_leaf(writer: &mut ColumnWriter<'_>, levels: 
&ArrayLevels) -> Result match 
value_type.data_type() {
+ArrowDataType::Decimal32(_, _) => {
+let array = arrow_cast::cast(column, 
value_type.data_type())?;

Review Comment:
   I'm not sure about these casts... Will this materialize the full values, 
kind of ruining the point of doing REE? cc @martin-g 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-05 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3619705288

   @martin-g Thanks for the comments, and especially about Decimal REE arrays. 
I didn't add Decimal128 and Decimal256 yet: Those types need some more changes 
to the `fixed_len_byte_array_reader`. But I assume we want this as well, so 
will try to get that done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-05 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594634927


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4539,153 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {
+// Create a run array of strings
+let mut builder = StringRunBuildernew();
+builder.extend(
+vec![Some("alpha"); 10]
+.into_iter()
+.chain(vec![Some("beta"); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Utf8, 
true)),
+),
+false,
+)]));
+assert_eq!(&expected_schema, reader.schema());
+
+// Read the data back
+let batches: Vec<_> = reader
+.build()
+.unwrap()
+.collect::>>()
+.unwrap();
+assert_eq!(batches.len(), 196);
+// Count rows in total
+let total_rows = batches.iter().map(|b| b.num_rows()).sum::();
+assert_eq!(total_rows, 20);
+
+// Ensure dictionary encoding
+assert!(has_dict_encoding, "RunArray should be dictionary encoded");
+assert!(has_dict_page, "RunArray should have dictionary page");
+}
+
+#[test]
+fn arrow_writer_run_end_encoded_int() {
+// Create a run array of strings
+let mut builder = PrimitiveRunBuildernew();
+builder.extend(
+vec![Some(1); 10]
+.into_iter()
+.chain(vec![Some(2); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+// let has_dict_encoding = 
col_meta.encodings().contains(&Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", arrow_schema::DataType::Int32, 
true)),
+

Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-05 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594609443


##
parquet/src/arrow/arrow_writer/byte_array.rs:
##
@@ -92,6 +114,20 @@ macro_rules! downcast_op {
 }
 d => unreachable!("cannot downcast {} dictionary value to byte 
array", d),
 },
+DataType::RunEndEncoded(run_end, value) => match value.data_type() 
{
+DataType::Utf8 => downcast_ree_op!(run_end, StringArray, 
$array, $op$(, $arg)*),
+DataType::LargeUtf8 => {
+downcast_ree_op!(run_end, LargeStringArray, $array, $op$(, 
$arg)*)
+}

Review Comment:
   Thank you!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-05 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594608623


##
parquet/src/arrow/schema/primitive.rs:
##
@@ -102,6 +102,18 @@ fn apply_hint(parquet: DataType, hint: DataType) -> 
DataType {
 false => hinted,
 }
 }
+
+// Potentially preserve run end encoded encoding

Review Comment:
   Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-05 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2594609231


##
parquet/src/arrow/arrow_writer/byte_array.rs:
##
@@ -92,6 +114,20 @@ macro_rules! downcast_op {
 }
 d => unreachable!("cannot downcast {} dictionary value to byte 
array", d),
 },
+DataType::RunEndEncoded(run_end, value) => match value.data_type() 
{
+DataType::Utf8 => downcast_ree_op!(run_end, StringArray, 
$array, $op$(, $arg)*),
+DataType::LargeUtf8 => {
+downcast_ree_op!(run_end, LargeStringArray, $array, $op$(, 
$arg)*)
+}
+DataType::Binary => downcast_ree_op!(run_end, BinaryArray, 
$array, $op$(, $arg)*),

Review Comment:
   Thank you!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-01 Thread via GitHub


vegarsti commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2576146754


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -1297,6 +1343,12 @@ fn write_leaf(writer: &mut ColumnWriter<'_>, levels: 
&ArrayLevels) -> Result {
+Err(ParquetError::NYI(
+"Int64ColumnWriter: Attempting to write an Arrow REE 
type that is not yet implemented"

Review Comment:
   Agreed!



##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -1371,6 +1423,12 @@ fn write_leaf(writer: &mut ColumnWriter<'_>, levels: 
&ArrayLevels) -> Result();
 get_float_16_array_slice(array, indices)
 }
+ArrowDataType::RunEndEncoded(_run_ends, _values) => {
+return Err(ParquetError::NYI(
+"FixedLenByteArrayColumnWriter: Attempting to write an 
Arrow REE type that is not yet implemented"

Review Comment:
   Agreed!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-12-01 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3595299022

   Sorry for not addressing this yet @martin-g, I have not forgotten! Should 
get it done this week.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-11-17 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3540640401

   Thank you @martin-g! Will make these changes and add the tests for decimal 
REE you request!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-11-16 Thread via GitHub


martin-g commented on code in PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#discussion_r2532221739


##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -1297,6 +1343,12 @@ fn write_leaf(writer: &mut ColumnWriter<'_>, levels: 
&ArrayLevels) -> Result {
+Err(ParquetError::NYI(
+"Int64ColumnWriter: Attempting to write an Arrow REE 
type that is not yet implemented"

Review Comment:
   ```suggestion
   "Int64ColumnWriter: Attempting to write an Arrow 
RunEndEncoded type that is not yet implemented"
   ```
   nit: IMO it would be easier for the end user to debug/understand the error 
if it does not use acronyms.



##
parquet/src/arrow/arrow_writer/byte_array.rs:
##
@@ -92,6 +114,20 @@ macro_rules! downcast_op {
 }
 d => unreachable!("cannot downcast {} dictionary value to byte 
array", d),
 },
+DataType::RunEndEncoded(run_end, value) => match value.data_type() 
{
+DataType::Utf8 => downcast_ree_op!(run_end, StringArray, 
$array, $op$(, $arg)*),
+DataType::LargeUtf8 => {
+downcast_ree_op!(run_end, LargeStringArray, $array, $op$(, 
$arg)*)
+}

Review Comment:
   ```suggestion
   }
   DataType::Utf8View => {
   +downcast_ree_op!(run_end, StringViewArray, $array, 
$op$(, $arg)*)
   +   }
   ```



##
parquet/src/arrow/arrow_writer/byte_array.rs:
##
@@ -92,6 +114,20 @@ macro_rules! downcast_op {
 }
 d => unreachable!("cannot downcast {} dictionary value to byte 
array", d),
 },
+DataType::RunEndEncoded(run_end, value) => match value.data_type() 
{
+DataType::Utf8 => downcast_ree_op!(run_end, StringArray, 
$array, $op$(, $arg)*),
+DataType::LargeUtf8 => {
+downcast_ree_op!(run_end, LargeStringArray, $array, $op$(, 
$arg)*)
+}
+DataType::Binary => downcast_ree_op!(run_end, BinaryArray, 
$array, $op$(, $arg)*),

Review Comment:
   ```suggestion
   DataType::Binary => downcast_ree_op!(run_end, BinaryArray, 
$array, $op$(, $arg)*),
   DataType::BinaryView => {
   +downcast_ree_op!(run_end, BinaryViewArray, $array, 
$op$(, $arg)*)
   +}
   ```



##
parquet/src/arrow/schema/primitive.rs:
##
@@ -102,6 +102,18 @@ fn apply_hint(parquet: DataType, hint: DataType) -> 
DataType {
 false => hinted,
 }
 }
+
+// Potentially preserve run end encoded encoding

Review Comment:
   ```suggestion
   // Potentially preserve run-end encoding
   ```



##
parquet/src/arrow/arrow_writer/mod.rs:
##
@@ -4481,4 +4539,153 @@ mod tests {
 assert_eq!(get_dict_page_size(col0_meta), 1024 * 1024);
 assert_eq!(get_dict_page_size(col1_meta), 1024 * 1024 * 4);
 }
+
+#[test]
+fn arrow_writer_run_end_encoded_string() {
+// Create a run array of strings
+let mut builder = StringRunBuildernew();
+builder.extend(
+vec![Some("alpha"); 10]
+.into_iter()
+.chain(vec![Some("beta"); 10]),
+);
+let run_array: RunArray = builder.finish();
+let schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+run_array.data_type().clone(),
+run_array.is_nullable(),
+)]));
+
+// Write to parquet
+let mut parquet_bytes: Vec = Vec::new();
+let mut writer = ArrowWriter::try_new(&mut parquet_bytes, 
schema.clone(), None).unwrap();
+let batch = RecordBatch::try_new(schema.clone(), 
vec![Arc::new(run_array)]).unwrap();
+writer.write(&batch).unwrap();
+writer.close().unwrap();
+
+// Read back and verify
+let bytes = Bytes::from(parquet_bytes);
+let reader = ParquetRecordBatchReaderBuilder::try_new(bytes).unwrap();
+
+// Check if dictionary was used by examining the metadata
+let metadata = reader.metadata();
+let row_group = &metadata.row_groups()[0];
+let col_meta = &row_group.columns()[0];
+
+// If dictionary encoding worked, we should see RLE_DICTIONARY encoding
+// and have a dictionary page offset
+let has_dict_encoding = col_meta.encodings().any(|e| e == 
Encoding::RLE_DICTIONARY);
+let has_dict_page = col_meta.dictionary_page_offset().is_some();
+
+// Verify the schema is REE encoded when we read it back
+let expected_schema = Arc::new(Schema::new(vec![Field::new(
+"ree",
+DataType::RunEndEncoded(
+Arc::new(Field::new("run_ends", arrow_schema::DataType::Int32, 
false)),
+Arc::new(Field::new("values", 

Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-10-28 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3458322895

   That's understandable, thanks for letting us know!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-10-28 Thread via GitHub


alamb commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3458315542

   Thanks @vegarsti and @albertlockett  -- I will put this on my list but it 
will likely be a while before I have time to review it througholy


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-10-27 Thread via GitHub


albertlockett commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3452388305

   > @albertlockett I can't think of anything major outstanding here, can you? 😄
   
   No, I think we were just waiting on the casting PR to land. Now that that is 
merged, we can probably consider this ready for review.
   
   @alamb would you mind taking a look as well?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] Support writing RunEndEncoded as Parquet [arrow-rs]

2025-10-27 Thread via GitHub


vegarsti commented on PR #8069:
URL: https://github.com/apache/arrow-rs/pull/8069#issuecomment-3451265703

   @albertlockett I can't think of anything major outstanding here, can you? 😄 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]