Skip to content

ARROW-1491: [C++] Add casting from strings to numbers and booleans - #2362

Closed
pitrou wants to merge 3 commits into
apache:masterfrom
pitrou:ARROW-1491-cast-string-to-number
Closed

ARROW-1491: [C++] Add casting from strings to numbers and booleans#2362
pitrou wants to merge 3 commits into
apache:masterfrom
pitrou:ARROW-1491-cast-string-to-number

Conversation

@pitrou

@pitroupitrou commented Aug 2, 2018

Copy link
Copy Markdown
Member

The implementation for numbers uses C++ istringstream. This makes casting a bit lenient (it will probably accept whitespace).

This is a rewrite of #1387

@codecov-io

codecov-io commented Aug 2, 2018

Copy link
Copy Markdown

Codecov Report

Merging #2362 into master will increase coverage by 2.21%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@## master #2362 +/- ##
==========================================
+ Coverage 84.66% 86.87% +2.21% 
==========================================
Files 293 237 -56 Lines 45324 42705 -2619 ==========================================
- Hits 38372 37099 -1273 + Misses 6911 5606 -1305 + Partials 41 0 -41
Impacted FilesCoverage Δ
cpp/src/arrow/compute/kernels/cast.cc91.54% <100%> (+1.67%)⬆️
cpp/src/arrow/compute/compute-test.cc99.54% <100%> (+0.05%)⬆️
rust/src/buffer.rs
rust/src/memory_pool.rs
go/arrow/type_traits_boolean.go
go/arrow/math/int64_sse4_amd64.go
go/arrow/array/boolean.go
go/arrow/math/int64_avx2_amd64.go
go/arrow/math/int64.go
rust/src/error.rs
... and 48 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edfbf84...c7db1b0. Read the comment docs.

@pitrou
pitrouforce-pushed the ARROW-1491-cast-string-to-number branch from 433f513 to 79cc17aCompareAugust 2, 2018 13:59

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.

I sometimes wonder what the meeting was like that decided names like this.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I had the same thought :-)

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.

Can we make this a little more readable by use tolower?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

tolower is locale-dependent.

@wesmwesm 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 this. Made a small comment about reusing type traits but otherwise OK by me

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.

You could use enable_if_number<O> here from arrow/type_traits.h

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Done.

@pitrou
pitrouforce-pushed the ARROW-1491-cast-string-to-number branch from 79cc17a to 4ce3000CompareAugust 6, 2018 09:36
@pitrou

Copy link
Copy Markdown
MemberAuthor

Some weird failure occurred on the AppVeyor build that didn't occur on my AppVeyor account:
https://ci.appveyor.com/project/pitrou/arrow/build/1.0.570

@pitrou
pitrouforce-pushed the ARROW-1491-cast-string-to-number branch from 4ce3000 to 3297aa1CompareAugust 6, 2018 12:04
@pitrou

Copy link
Copy Markdown
MemberAuthor

I want to make sure the AppVeyor failure was sporadic so I've triggered another build by pushing again.

The implementation for numbers uses the C standard strto* functions.
This makes casting a bit lenient (it will accept whitespace).
@wesm
wesmforce-pushed the ARROW-1491-cast-string-to-number branch from 3297aa1 to c7db1b0CompareAugust 6, 2018 19:44
@wesm

wesm commented Aug 6, 2018

Copy link
Copy Markdown
Member

rebased

wesm
wesm approved these changes Aug 6, 2018

@wesmwesm 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.

+1

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@pitrou@codecov-io@wesm@cpcloud