Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ci/scripts/r_test_old_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# 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.

set -ex

: ${R_BIN:=R}

source_dir=${1}/r

pushd ${source_dir}

printenv

export TEST_R_WITH_ARROW=TRUE

${R_BIN} -e "as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
remotes::install_version('arrow', '$OLD_ARROW_VERSION', quiet = FALSE, verbose = TRUE)
library(arrow)
testthat::test_file('tests/testthat/test-parquet-compatibility.R')"

popd
1 change: 1 addition & 0 deletions dev/tasks/r/azure.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
docker-compose pull --ignore-pull-failures r
docker-compose build r
displayName: Docker build
Expand Down
10 changes: 10 additions & 0 deletions dev/tasks/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,16 @@ tasks:
not_cran: "TRUE"
devtoolset_version: 8

test-r-rstudio-r-arrow-1.0.1-compatibility:
ci: azure
template: r/azure.linux.yml
params:
r_org: rstudio
r_image: r-base
r_tag: 3.6-bionic
old_arrow_version: "1.0.1"
run: r-forward-compatibility

test-r-rstudio-r-base-3.6-opensuse15:
ci: azure
template: r/azure.linux.yml
Expand Down
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,31 @@ services:
command: >
/bin/bash -c "/arrow/ci/scripts/r_test.sh /arrow"

r-forward-compatibility:
# This lets you test forward compatilbity from old arrow versions (given in OLD_ARROW_VERSION)
#
# Usage:
# R_ORG=rstudio R_IMAGE=r-base R_TAG=3.6-bionic OLD_ARROW_VERSION=1.0.1 docker-compose build r-forward-compatibility
# R_ORG=rstudio R_IMAGE=r-base R_TAG=3.6-bionic OLD_ARROW_VERSION=1.0.1 docker-compose run r-forward-compatibility
image: ${REPO}:r-${R_ORG}-${R_IMAGE}-${R_TAG}
build:
context: .
dockerfile: ci/docker/linux-r.dockerfile
cache_from:
- ${REPO}:r-${R_ORG}-${R_IMAGE}-${R_TAG}
args:
base: ${R_ORG}/${R_IMAGE}:${R_TAG}
r_dev: ${ARROW_R_DEV}
shm_size: *shm-size
environment:
ARROW_R_DEV: ${ARROW_R_DEV}
ARROW_USE_PKG_CONFIG: "false"
OLD_ARROW_VERSION: ${OLD_ARROW_VERSION}
volumes:
- .:/arrow:delegated
command: >
/bin/bash -c "/arrow/ci/scripts/r_test_old_version.sh /arrow"

ubuntu-r-sanitizer:
# Only 18.04 and amd64 supported
# Usage:
Expand Down
Binary file added r/tests/testthat/parquets/data-arrow2.parquet
Binary file not shown.
45 changes: 45 additions & 0 deletions r/tests/testthat/test-parquet-compatibility.R
Original file line number Diff line number Diff line change
@@ -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
df <- as.data.frame(tab)

expect_data_frame(df, data.frame(col1 = 1:10))
expect_identical(dim(df), c(10L, 1L))
})