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 2021/01/06 23:34:56 UTC

[GitHub] [arrow] nealrichardson commented on a change in pull request #9118: [WIP] Arrow 10623: [R] Version 1.0.1 breaks data.frame attributes when reading file written by 2.0.0

nealrichardson commented on a change in pull request #9118:
URL: https://github.com/apache/arrow/pull/9118#discussion_r553016317



##########
File path: dev/tasks/r/azure.linux.yml
##########
@@ -37,6 +37,7 @@ jobs:
         export R_IMAGE={{ r_image }}
         export R_TAG={{ r_tag }}
         export DEVTOOLSET_VERSION={{ devtoolset_version|default("-1") }}
+        export OLD_ARROW_VERSION={{ old_arrow_version }}

Review comment:
       not needed?

##########
File path: r/tests/testthat/test-parquet-compatibility.R
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# TODO: skip mostly? Or use this for backwards compat?

Review comment:
       resolve this. is this for testing that we can read files written by older versions?

##########
File path: r/extra-tests/write-parquet.R
##########
@@ -0,0 +1,23 @@
+library(arrow)
+
+if (!dir.exists("extra-tests/files")) {
+  dir.create("extra-tests/files")
+}
+

Review comment:
       could this source tests/testthat/helper-data.R instead of copying the object here? just so these don't get out of sync (if we add more attrs or columns)

##########
File path: r/tests/testthat/test-parquet-compatibility.R
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# TODO: skip mostly? Or use this for backwards compat?
+
+pq_file <- test_path("parquets/data-arrow2.parquet")
+
+test_that("reading a known Parquet file to dataframe", {
+  df <- read_parquet(pq_file)
+  expect_data_frame(df, data.frame(col1 = 1:10))
+  expect_identical(dim(df), c(10L, 1L))
+
+  tab <- read_parquet(pq_file, as_data_frame = FALSE)
+  expect_s3_class(tab, "Table")
+  expect_equal(
+    # unserialize like .unserialize_arrow_r_metadata does (though we can't call
+    # it directly because it's not exported)

Review comment:
       why is that a problem? testthat evals in the package namespace so you can call unexported functions

##########
File path: r/tests/testthat/test-parquet-compatibility.R
##########
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# TODO: skip mostly? Or use this for backwards compat?
+
+pq_file <- test_path("parquets/data-arrow2.parquet")
+
+test_that("reading a known Parquet file to dataframe", {
+  df <- read_parquet(pq_file)
+  expect_data_frame(df, data.frame(col1 = 1:10))
+  expect_identical(dim(df), c(10L, 1L))
+
+  tab <- read_parquet(pq_file, as_data_frame = FALSE)
+  expect_s3_class(tab, "Table")
+  expect_equal(
+    # unserialize like .unserialize_arrow_r_metadata does (though we can't call
+    # it directly because it's not exported)
+    unserialize(charToRaw(tab$metadata$r)),
+    list(
+      attributes = list(class = "data.frame"),
+      columns = list(col1 = NULL)
+    )
+  )
+
+  # test the workaround
+  tab$metadata$r <- NULL

Review comment:
       This workaround is for reading files written by 2.0 in 1.0, right? IIUC that should be tested in the extra-tests




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