Reranko05 opened a new pull request, #49798:
URL: https://github.com/apache/arrow/pull/49798
### Rationale for this change
`RecordBatch::MakeEmpty() `creates arrays using `MakeEmptyArray()`, which
relies on `ArrayBuilder::Finish()`. For dictionary-encoded types,
`DictionaryBuilder` reconstructs the `DictionaryType` without preserving the
ordered flag (defaulting it to false). As a result, the resulting array type
does not match the input schema.
This change ensures that the original `DictionaryType` (including the
ordered flag) is preserved.
### What changes are included in this PR?
Update `MakeEmptyArray()` to restore the original `DataType` for
**dictionary types only** after `builder->Finish()`, ensuring the ordered flag
is preserved.
Add a unit test to verify:
- The ordered flag is preserved.
- The resulting array type matches the schema.
- The created batch is empty and structurally correct.
### Are these changes tested?
Yes. A unit test has been added that:
- Constructs a dictionary-encoded schema with `ordered = true`.
- Calls `RecordBatch::MakeEmpty()`.
- Verifies that:
- The batch is empty (`num_rows == 0`, `num_columns == 1`).
- Both schema and array types preserve the ordered flag.
- The array type matches the schema type.
### Are there any user-facing changes?
No.
Closes #49674
--
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]