Skip to content

GH-50660: [C++][Dev] Add Decimal32 and Decimal64 GDB pretty-printers - #50723

Open
fenfeng9 wants to merge 1 commit into
apache:mainfrom
fenfeng9:gh-50660-decimal32-64-gdb
Open

GH-50660: [C++][Dev] Add Decimal32 and Decimal64 GDB pretty-printers#50723
fenfeng9 wants to merge 1 commit into
apache:mainfrom
fenfeng9:gh-50660-decimal32-64-gdb

Conversation

@fenfeng9

@fenfeng9 fenfeng9 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The Arrow GDB pretty-printers support Decimal128 and Decimal256, but do not support Decimal32 or Decimal64.

What changes are included in this PR?

  • Add GDB pretty-printer support and tests for Decimal32 and Decimal64.
  • Remove the unused max_type_id variable.

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

@fenfeng9
fenfeng9 force-pushed the gh-50660-decimal32-64-gdb branch from 21dc913 to fb4a550 Compare July 29, 2026 18:58
@pitrou

pitrou commented Jul 29, 2026

Copy link
Copy Markdown
Member

@Reranko05 Do you feel like reviewing this?

@fenfeng9

Copy link
Copy Markdown
Contributor Author

Here are some examples from a local GDB session.

// Scalars
Decimal32Scalar decimal32_scalar_pos{
    Decimal32("1234567"), decimal32(9, 4)};
Decimal64Scalar decimal64_scalar_pos{
    Decimal64("12345678901234567"), decimal64(18, 4)};

// Arrays
auto heap_decimal32_array =
    SliceArrayFromJSON(
        decimal32(9, 4),
        R"([null, "-12345.6789", "12345.6789"])");
auto heap_decimal64_array =
    SliceArrayFromJSON(
        decimal64(18, 4),
        R"([null, "-12345678901234.5678", "12345678901234.5678"])");
auto heap_decimal32_array_sliced =
    heap_decimal32_array->Slice(1, 1);
(gdb) p decimal32_scalar_pos
$1 = arrow::Decimal32Scalar of value 123.4567 [precision=9, scale=4]

(gdb) p decimal64_scalar_pos
$2 = arrow::Decimal64Scalar of value 1234567890123.4567 [precision=18, scale=4]

(gdb) p *heap_decimal32_array
$3 = (std::__shared_ptr_access<arrow::Array, (__gnu_cxx::_Lock_policy)2, false, false>::element_type &) @0x43aa50:
     arrow::Decimal32Array of type arrow::decimal32(9, 4),
     length 3, offset 0, null count 1 = {null, -12345.6789, 12345.6789}

(gdb) p *heap_decimal64_array
$4 = (std::__shared_ptr_access<arrow::Array, (__gnu_cxx::_Lock_policy)2, false, false>::element_type &) @0x43aaa0:
     arrow::Decimal64Array of type arrow::decimal64(18, 4),
     length 3, offset 0, null count 1 = {null, -12345678901234.5678, 12345678901234.5678}

(gdb) p *heap_decimal32_array_sliced
$5 = (std::__shared_ptr_access<arrow::Array, (__gnu_cxx::_Lock_policy)2, false, false>::element_type &) @0x43b060:
     arrow::Decimal32Array of type arrow::decimal32(9, 4),
     length 1, offset 1, unknown null count = {-12345.6789}

@Reranko05 Reranko05 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants