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 2020/06/16 14:15:17 UTC

[GitHub] [arrow] bkietz opened a new pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

bkietz opened a new pull request #7451:
URL: https://github.com/apache/arrow/pull/7451


   No changes to python since neither StructScalar nor minmax are exposed there


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on pull request #7451:
URL: https://github.com/apache/arrow/pull/7451#issuecomment-644966570


   Rtools build failure is ARROW-9151. I'll merge.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson closed pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

Posted by GitBox <gi...@apache.org>.
nealrichardson closed pull request #7451:
URL: https://github.com/apache/arrow/pull/7451


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] fsaintjacques commented on a change in pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

Posted by GitBox <gi...@apache.org>.
fsaintjacques commented on a change in pull request #7451:
URL: https://github.com/apache/arrow/pull/7451#discussion_r441071413



##########
File path: cpp/src/arrow/scalar_test.cc
##########
@@ -433,4 +433,24 @@ TYPED_TEST(TestNumericScalar, Cast) {
   }
 }
 
+TEST(TestStructScalar, FieldAccess) {
+  StructScalar abc({MakeScalar(true), MakeNullScalar(int32()), MakeScalar("hello")},
+                   struct_({
+                       field("a", boolean()),
+                       field("b", int32()),
+                       field("b", utf8()),
+                   }));
+
+  ASSERT_OK_AND_ASSIGN(auto a, abc.field("a"));
+  AssertScalarsEqual(*a, *abc.value[0]);
+
+  ASSERT_RAISES(Invalid, abc.field("b").status());
+
+  ASSERT_OK_AND_ASSIGN(auto b, abc.field(1));
+  AssertScalarsEqual(*b, *abc.value[1]);
+
+  ASSERT_RAISES(Invalid, abc.field(5).status());
+  ASSERT_RAISES(Invalid, abc.field("c").status());

Review comment:
       Add a nested failure (not implemented).




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #7451:
URL: https://github.com/apache/arrow/pull/7451#issuecomment-644804946


   https://issues.apache.org/jira/browse/ARROW-8769


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] nealrichardson commented on a change in pull request #7451: ARROW-8769: [C++][R] Add convenience accessor for StructScalar fields

Posted by GitBox <gi...@apache.org>.
nealrichardson commented on a change in pull request #7451:
URL: https://github.com/apache/arrow/pull/7451#discussion_r440971906



##########
File path: r/R/compute.R
##########
@@ -42,26 +42,32 @@ mean.ChunkedArray <- mean.Array
 #' @export
 mean.Scalar <- mean.Array
 
+#' @export
 min.Array <- function(..., na.rm = FALSE) {
-  extrema <- scalar_aggregate("minmax", ..., na.rm = na.rm)
-  # TODO: StructScalar needs field accessor methods in C++: ARROW-9070
-  Scalar$create(as.vector(extrema)$min)
+  scalar_aggregate("minmax", ..., na.rm = na.rm)$GetFieldByName("min")
+}
+
+#' @export
+max.Array <- function(..., na.rm = FALSE) {
+  scalar_aggregate("minmax", ..., na.rm = na.rm)$GetFieldByName("max")
 }
 
 scalar_aggregate <- function(FUN, ..., na.rm = FALSE) {
   a <- collect_arrays_from_dots(list(...))
   if (!na.rm && a$null_count > 0) {
-    # Arrow sum/mean function always drops NAs so handle that here
-    # https://issues.apache.org/jira/browse/ARROW-9054
-    Scalar$create(NA_integer_, type = a$type)
-  } else {
-    if (inherits(a$type, "Boolean")) {
-      # Bool sum/mean not implemented so cast to int
-      # https://issues.apache.org/jira/browse/ARROW-9055
-      a <- a$cast(int8())
+    if (FUN == 'mean' || FUN == 'sum') {

Review comment:
       ```suggestion
       if (FUN %in% c("mean", "sum")) {
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org