Skip to content

ARROW-13067: [C++][Compute] Implement integer to decimal cast - #11045

Closed
cyb70289 wants to merge 2 commits into
apache:masterfrom
cyb70289:13067-int2dec
Closed

ARROW-13067: [C++][Compute] Implement integer to decimal cast#11045
cyb70289 wants to merge 2 commits into
apache:masterfrom
cyb70289:13067-int2dec

Conversation

@cyb70289

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

Copy link
Copy Markdown

Comment threadcpp/src/arrow/compute/kernels/scalar_cast_numeric.cc
Comment threadcpp/src/arrow/compute/kernels/scalar_cast_numeric.cc
Comment threadcpp/src/arrow/compute/kernels/scalar_cast_numeric.cc
Comment threadcpp/src/arrow/compute/kernels/scalar_cast_numeric.cc
@edponce

Copy link
Copy Markdown
Contributor

LGTM. Thanks for resolving this issue.

@lidavidmlidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for doing this.

Comment threadcpp/src/arrow/compute/kernels/scalar_cast_numeric.cc Outdated

options.to_type = decimal256(76, 67);
CheckCastFails(ArrayFromJSON(int32(), "[0]"), options);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we file a follow up issue to allow truncation via an unsafe cast in these cases?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Sure, will do.

CheckDispatchBest(name, {int64(), decimal128(1, 0)},
{decimal128(1, 0), decimal128(1, 0)});
CheckDispatchBest(name, {decimal128(1, 0), int64()},
{decimal128(1, 0), decimal128(1, 0)});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, so an int64 is cast to a 1-digit decimal? Unrelated to this PR surely, but I'm a bit surprised :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is testing that given an integer and a decimal, the integer is cast to a decimal of the same width/precision/scale.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But surely the actual cast from int64 to decimal128(1,0) will fail in the precision check?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, right. Maybe we want the cast logic to be smarter about that, then. As you said, though, that can be tackled separately.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@cyb70289
cyb70289 deleted the 13067-int2dec branch September 2, 2021 10:05
ViniciusSouzaRoque pushed a commit to s1mbi0se/arrow that referenced this pull request Oct 20, 2021
Closesapache#11045 from cyb70289/13067-int2dec
Authored-by: Yibo Cai <yibo.cai@arm.com>
Signed-off-by: Yibo Cai <yibo.cai@arm.com>
Sign up for freeto 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.

4 participants

@cyb70289@edponce@lidavidm@pitrou