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
2 changes: 2 additions & 0 deletions cpp/src/arrow/util/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ struct MakeConverterImpl {
DICTIONARY_CASE(FloatType);
DICTIONARY_CASE(DoubleType);
DICTIONARY_CASE(BinaryType);
DICTIONARY_CASE(LargeBinaryType);
DICTIONARY_CASE(StringType);
DICTIONARY_CASE(LargeStringType);
DICTIONARY_CASE(FixedSizeBinaryType);
#undef DICTIONARY_CASE
default:
Expand Down
3 changes: 2 additions & 1 deletion python/pyarrow/src/arrow/python/python_to_arrow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <limits>
#include <sstream>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -826,7 +827,7 @@ class PyDictionaryConverter<U, enable_if_has_string_view<U>>
} else {
ARROW_RETURN_NOT_OK(
PyValue::Convert(this->value_type_, this->options_, value, view_));
return this->value_builder_->Append(view_.bytes, static_cast<int32_t>(view_.size));
return this->value_builder_->Append(std::string_view(view_.bytes, view_.size));
}
}

Expand Down
16 changes: 16 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4468,3 +4468,19 @@ def test_dunders_checked_overflow():
arr ** pa.scalar(2, type=pa.int8())
with pytest.raises(pa.ArrowInvalid, match=error_match):
arr / (-arr)


def test_dictionary_large_string_and_binary():
# Test dictionary with large_string values
arr_str = pa.array(
["a", "b", "a"], type=pa.dictionary(pa.int32(), pa.large_string())
)
assert arr_str.type.value_type == pa.large_string()
assert arr_str.to_pylist() == ["a", "b", "a"]

# Test dictionary with large_binary values
arr_bin = pa.array(
[b"x", b"y", b"x"], type=pa.dictionary(pa.int32(), pa.large_binary())
)
assert arr_bin.type.value_type == pa.large_binary()
assert arr_bin.to_pylist() == [b"x", b"y", b"x"]