Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] Add type category membership checks #32567

Closed
asfimport opened this issue Aug 2, 2022 · 7 comments
Closed

[C++] Add type category membership checks #32567

asfimport opened this issue Aug 2, 2022 · 7 comments

Comments

@asfimport
Copy link
Collaborator

Currently, type categories are only available as vectors, e.g., the category of integer types is available via arrow::IntTypes(). This issue will add type category membership test, e.g. arrow::IsIntType(type).

Following discussions, this issue ended up covering the following:

  • Additional type category predicates
  • Convenience predicates accepting a DataType parameter
  • Documentation and testing of the predicates

Reporter: Yaron Gvili / @rtpsw
Assignee: Yaron Gvili / @rtpsw

PRs and other links:

Note: This issue was originally created as ARROW-17289. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

Antoine Pitrou / @pitrou:
Have you looked at arrow/type_traits.h ?

@asfimport
Copy link
Collaborator Author

David Li / @lidavidm:
@rtpsw have you seen the predicates in type_traits.h? e.g. there is is_integer

static inline bool is_integer(Type::type type_id) {

@asfimport
Copy link
Collaborator Author

David Li / @lidavidm:
Also where did you search for this? We should improve the docs

@asfimport
Copy link
Collaborator Author

Yaron Gvili / @rtpsw:
This is a small improvement proposal for convenience. Given a std::shared_ptr<DataType> type, it's easy for the user to find IsIntegerType(type). IIUC, using type_traits.h the code would be is_integer(type->id()), which has one more function that the user needs to find. Granted, I overlooked that the proposed implementation could be simplified using the type id.

Regarding documentation, when I search for "apache arrow type is integer", the top results are https://arrow.apache.org/docs/r/reference/data-type.html, https://arrow.apache.org/docs/r/reference/data-type.html, followed by PyArrow results. Adding "C++" to the search doesn't change the results much.

@asfimport
Copy link
Collaborator Author

David Li / @lidavidm:
Overloads to the existing functions that take const DataType& might be reasonable for convenience

For docs, we should promote the cookbook more - this could easily be a set of recipes there (that would hopefully get indexed)

@asfimport
Copy link
Collaborator Author

Yaron Gvili / @rtpsw:
I'll adjust my proposed PR.

Regrading docs, a possible way to promote the cookbook is to add a link to it from many Arrow C++ public headers that would show up in generated reference pages.

@asfimport
Copy link
Collaborator Author

Antoine Pitrou / @pitrou:
Issue resolved by pull request 13783
#13783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant