You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/28 16:17:06 UTC
[GitHub] [arrow] lidavidm commented on a diff in pull request #13737: Add scalar casts to string types for list based types
lidavidm commented on code in PR #13737:
URL: https://github.com/apache/arrow/pull/13737#discussion_r932436063
##########
cpp/src/arrow/scalar.cc:
##########
@@ -1041,6 +1041,24 @@ Status CastImpl(const StructScalar& from, StringScalar* to) {
return Status::OK();
}
+// list based types (list, large list and map (fixed sized list too)) to string
+Status CastImpl(const BaseListScalar& from, StringScalar* to) {
+ std::stringstream ss;
+ ss << from.type->ToString() << "{";
+ for (int64_t i = 0; i < from.value->length(); i++) {
+ if (i > 0) ss << ", ";
+ auto result = from.value->GetScalar(i);
+ if (!result.ok()) {
+ return(result.status());
+ } else {
+ ss << result.ValueOrDie()->ToString();
+ }
Review Comment:
```suggestion
ARROW_ASSIGN_OR_RAISE(auto value, from.value->GetScalar(i));
ss << value->ToString();
```
##########
cpp/src/arrow/scalar.cc:
##########
@@ -1041,6 +1041,24 @@ Status CastImpl(const StructScalar& from, StringScalar* to) {
return Status::OK();
}
+// list based types (list, large list and map (fixed sized list too)) to string
+Status CastImpl(const BaseListScalar& from, StringScalar* to) {
+ std::stringstream ss;
+ ss << from.type->ToString() << "{";
Review Comment:
kind of a nit, but maybe square brackets are preferable here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org