You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2021/05/17 11:37:06 UTC
[arrow] branch maint-4.0.x updated (cbcdb33 -> eaac875)
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a change to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git.
discard cbcdb33 ARROW-12617: [Python] Align orc.write_table keyword order with parquet.write_table
discard 2b5b15d ARROW-12622: [Python] Fix segfault in read_csv when not on main thread
discard 0bebdbc ARROW-11926: [R] preparations for ucrt toolchains
discard 3ed7fab ARROW-12601: [R][Packaging] Fix pkg-config check in r/configure
discard 28c1fd6 ARROW-12520: [R] Minor docs updates
new 8004518 ARROW-12520: [R] Minor docs updates
new b1303cd ARROW-12601: [R][Packaging] Fix pkg-config check in r/configure
new c5ee38c ARROW-11926: [R] preparations for ucrt toolchains
new dbf16e3 ARROW-12622: [Python] Fix segfault in read_csv when not on main thread
new f80292d ARROW-12617: [Python] Align orc.write_table keyword order with parquet.write_table
new 63954cb ARROW-12568: [C++][Compute] Fix nullptr deference when array contains no nulls
new be5f704 ARROW-12571: [R][CI] Run nightly R with valgrind
new a891241 ARROW-12642: [R] LIBARROW_MINIMAL, LIBARROW_DOWNLOAD, NOT_CRAN env vars should not be case-sensitive
new 6a2915e ARROW-12663: [C++] Fix a cuda 11.2 compiler segfault
new af476c6 ARROW-12670: [C++] Fix extract_regex output after non-matching values
new 39dd06b ARROW-12746: [Go][Flight] append instead of overwriting outgoing metadata
new efdfb6d ARROW-12774 : [C++][Compute] replace_substring_regex() creates invalid arrays => crash
new eaac875 ARROW-12578: [JS] Remove Buffer in favor of TextEncoder API to support bundlers such as Rollup
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (cbcdb33)
\
N -- N -- N refs/heads/maint-4.0.x (eaac875)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../helper-parquet.R => ci/etc/valgrind-cran.supp | 27 ++++---
ci/scripts/{r_sanitize.sh => r_valgrind.sh} | 21 +++--
cpp/src/arrow/compute/kernels/hash_aggregate.cc | 8 +-
.../arrow/compute/kernels/hash_aggregate_test.cc | 23 ++++++
cpp/src/arrow/compute/kernels/scalar_boolean.cc | 90 ++++++++++++++++------
.../arrow/compute/kernels/scalar_boolean_test.cc | 18 +++++
.../arrow/compute/kernels/scalar_cast_nested.cc | 8 +-
cpp/src/arrow/compute/kernels/scalar_cast_test.cc | 14 ++++
cpp/src/arrow/compute/kernels/scalar_string.cc | 11 +--
.../arrow/compute/kernels/scalar_string_test.cc | 12 +++
cpp/src/arrow/util/variant.h | 11 ++-
dev/tasks/tasks.yml | 8 ++
docker-compose.yml | 26 +++++++
go/arrow/flight/client_auth.go | 4 +-
js/src/util/utf8.ts | 27 +------
r/configure | 3 +
r/inst/build_arrow_static.sh | 7 +-
r/tests/testthat/helper-skip.R | 19 +++++
r/tests/testthat/test-Array.R | 1 +
r/tests/testthat/test-arrow.R | 4 +
r/tests/testthat/test-compute-aggregate.R | 12 ++-
21 files changed, 264 insertions(+), 90 deletions(-)
copy r/tests/testthat/helper-parquet.R => ci/etc/valgrind-cran.supp (70%)
copy ci/scripts/{r_sanitize.sh => r_valgrind.sh} (51%)
[arrow] 02/13: ARROW-12601: [R][Packaging] Fix pkg-config check in
r/configure
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit b1303cd1056c2203d8387249aa2cdbe6e4ca3cd3
Author: Ian Cook <ia...@gmail.com>
AuthorDate: Thu Apr 29 17:32:33 2021 -0400
ARROW-12601: [R][Packaging] Fix pkg-config check in r/configure
Fixes false positives in a check that pkg-config is installed
Closes #10198 from ianmcook/ARROW-12601
Authored-by: Ian Cook <ia...@gmail.com>
Signed-off-by: Ian Cook <ia...@gmail.com>
---
r/configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/r/configure b/r/configure
index f6c1013..2da2b9f 100755
--- a/r/configure
+++ b/r/configure
@@ -77,7 +77,7 @@ elif [ "$INCLUDE_DIR" ] && [ "$LIB_DIR" ]; then
else
# Use pkg-config if available and allowed
pkg-config --version >/dev/null 2>&1
- if [ "$ARROW_USE_PKG_CONFIG" != "false" ] && [ $? -eq 0 ]; then
+ if [ $? -eq 0 ] && [ "$ARROW_USE_PKG_CONFIG" != "false" ]; then
PKGCONFIG_CFLAGS=`pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME}`
PKGCONFIG_LIBS=`pkg-config --libs-only-l --silence-errors ${PKG_CONFIG_NAME}`
PKGCONFIG_DIRS=`pkg-config --libs-only-L --silence-errors ${PKG_CONFIG_NAME}`
[arrow] 07/13: ARROW-12571: [R][CI] Run nightly R with valgrind
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit be5f70425478dae4e310014d4666ddd0e41691b9
Author: Jonathan Keane <jk...@gmail.com>
AuthorDate: Wed May 5 07:50:36 2021 -0500
ARROW-12571: [R][CI] Run nightly R with valgrind
Closes #10237 from jonkeane/ARROW-12571-valgrindCI-patch
Authored-by: Jonathan Keane <jk...@gmail.com>
Signed-off-by: Jonathan Keane <jk...@gmail.com>
---
ci/etc/valgrind-cran.supp | 34 +++++++++++++++++++++++
ci/scripts/r_valgrind.sh | 45 +++++++++++++++++++++++++++++++
dev/tasks/tasks.yml | 8 ++++++
docker-compose.yml | 26 ++++++++++++++++++
r/inst/build_arrow_static.sh | 4 +--
r/tests/testthat/helper-skip.R | 19 +++++++++++++
r/tests/testthat/test-Array.R | 1 +
r/tests/testthat/test-arrow.R | 4 +++
r/tests/testthat/test-compute-aggregate.R | 12 +++++++--
9 files changed, 149 insertions(+), 4 deletions(-)
diff --git a/ci/etc/valgrind-cran.supp b/ci/etc/valgrind-cran.supp
new file mode 100644
index 0000000..4d29220
--- /dev/null
+++ b/ci/etc/valgrind-cran.supp
@@ -0,0 +1,34 @@
+# 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.
+
+{
+ # `testthat::skip()`s cause a valgrind error that does not show up on CRAN.
+ <testthat_skip_error>
+ Memcheck:Cond
+ fun:gregexpr_Regexc
+ fun:do_regexpr
+ fun:bcEval
+ fun:Rf_eval
+ fun:R_execClosure
+ fun:Rf_applyClosure
+ fun:bcEval
+ fun:Rf_eval
+ fun:forcePromise
+ fun:FORCE_PROMISE
+ fun:getvar
+ fun:bcEval
+}
diff --git a/ci/scripts/r_valgrind.sh b/ci/scripts/r_valgrind.sh
new file mode 100755
index 0000000..43f8c26
--- /dev/null
+++ b/ci/scripts/r_valgrind.sh
@@ -0,0 +1,45 @@
+#!/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:=RDvalgrind}
+
+source_dir=${1}/r
+
+${R_BIN} CMD INSTALL ${source_dir}
+pushd ${source_dir}/tests
+
+export TEST_R_WITH_ARROW=TRUE
+# to generate suppression files run:
+# ${R_BIN} --vanilla -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes --gen-suppressions=all --log-file=memcheck.log" -f testtthat.supp
+${R_BIN} --vanilla -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes --suppressions=/${1}/ci/etc/valgrind-cran.supp" -f testthat.R |& tee testthat.out
+
+# valgrind --error-exitcode=1 should return an erroring exit code that we can catch,
+# but R eats that and returns 0, so we need to look at the output and make sure that
+# we have 0 errors instead.
+if [ $(grep -c "ERROR SUMMARY: 0 errors" testthat.out) != 1 ]; then
+ cat testthat.out
+ echo "Found Valgrind errors"
+ exit 1
+fi
+
+# We might also considering using the greps that LibthGBM uses:
+# https://github.com/microsoft/LightGBM/blob/fa6d356555f9ef888acf5f5e259dca958ca24f6d/.ci/test_r_package_valgrind.sh#L20-L85
+
+popd
\ No newline at end of file
diff --git a/dev/tasks/tasks.yml b/dev/tasks/tasks.yml
index 4bf0abf..9a6ec39 100644
--- a/dev/tasks/tasks.yml
+++ b/dev/tasks/tasks.yml
@@ -1396,6 +1396,14 @@ tasks:
FEDORA: 33
run: fedora-python
+ test-r-linux-valgrind:
+ ci: azure
+ template: docker-tests/azure.linux.yml
+ params:
+ env:
+ UBUNTU: 18.04
+ run: ubuntu-r-valgrind
+
test-r-linux-as-cran:
ci: github
template: r/github.linux.cran.yml
diff --git a/docker-compose.yml b/docker-compose.yml
index 4a3092e..1e4fca6 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -116,6 +116,7 @@ x-hierarchy:
- ubuntu-cpp-sanitizer
- ubuntu-cpp-thread-sanitizer
- ubuntu-r-sanitizer
+ - ubuntu-r-valgrind
- python-sdist
- r
# helper services
@@ -1050,6 +1051,31 @@ services:
/bin/bash -c "
/arrow/ci/scripts/r_sanitize.sh /arrow"
+ ubuntu-r-valgrind:
+ # Only 18.04 and amd64 supported
+ # Usage:
+ # docker-compose build ubuntu-r-valgrind
+ # docker-compose run ubuntu-r-valgrind
+ image: ${REPO}:amd64-ubuntu-18.04-r-valgrind
+ build:
+ context: .
+ dockerfile: ci/docker/linux-r.dockerfile
+ cache_from:
+ - ${REPO}:amd64-ubuntu-18.04-r-valgrind
+ args:
+ base: wch1/r-debug:latest
+ r_bin: RDvalgrind
+ environment:
+ <<: *ccache
+ # AVX512 not supported by Valgrind (similar to ARROW-9851) some runners support AVX512 and some do not
+ # so some build might pass without this setting, but we want to ensure that we stay to AVX2 regardless of runner.
+ EXTRA_CMAKE_FLAGS: "-DARROW_RUNTIME_SIMD_LEVEL=AVX2"
+ volumes: *ubuntu-volumes
+ command: >
+ /bin/bash -c "
+ /arrow/ci/scripts/r_valgrind.sh /arrow"
+
+
################################# Go ########################################
debian-go:
diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh
index e9c82a1..6fba5be 100755
--- a/r/inst/build_arrow_static.sh
+++ b/r/inst/build_arrow_static.sh
@@ -53,8 +53,8 @@ ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \
-DARROW_DATASET=${ARROW_DATASET:-ON} \
-DARROW_DEPENDENCY_SOURCE=BUNDLED \
-DARROW_FILESYSTEM=ON \
- -DARROW_JEMALLOC=${ARROW_JEMALLOC:-ON} \
- -DARROW_MIMALLOC=${ARROW_MIMALLOC:-$ARROW_DEFAULT_PARAM} \
+ -DARROW_JEMALLOC=${ARROW_JEMALLOC:-$ARROW_DEFAULT_PARAM} \
+ -DARROW_MIMALLOC=${ARROW_MIMALLOC:-ON} \
-DARROW_JSON=ON \
-DARROW_PARQUET=${ARROW_PARQUET:-ON} \
-DARROW_S3=${ARROW_S3:-$ARROW_DEFAULT_PARAM} \
diff --git a/r/tests/testthat/helper-skip.R b/r/tests/testthat/helper-skip.R
index 6fb97da..b1c7d66 100644
--- a/r/tests/testthat/helper-skip.R
+++ b/r/tests/testthat/helper-skip.R
@@ -22,6 +22,11 @@ build_features <- c(
)
skip_if_not_available <- function(feature) {
+ if (feature == "re2") {
+ # RE2 does not support valgrind (on purpose): https://github.com/google/re2/issues/177
+ skip_on_valgrind()
+ }
+
yes <- feature %in% names(build_features) && build_features[feature]
if (!yes) {
skip(paste("Arrow C++ not built with", feature))
@@ -29,6 +34,8 @@ skip_if_not_available <- function(feature) {
}
skip_if_no_pyarrow <- function() {
+ skip_on_valgrind()
+
skip_if_not_installed("reticulate")
if (!reticulate::py_module_available("pyarrow")) {
skip("pyarrow not available for testing")
@@ -49,6 +56,18 @@ skip_if_not_running_large_memory_tests <- function() {
)
}
+skip_on_valgrind <- function() {
+ # This does not actually skip on valgrind because we can't exactly detect it.
+ # Instead, it skips on CRAN when the OS is linux + and the R version is development
+ # (which is where valgrind is run as of this code)
+ linux_dev <- identical(tolower(Sys.info()[["sysname"]]), "linux") &&
+ grepl("devel", R.version.string)
+
+ if (linux_dev) {
+ skip_on_cran()
+ }
+}
+
process_is_running <- function(x) {
cmd <- sprintf("ps aux | grep '%s' | grep -v grep", x)
tryCatch(system(cmd, ignore.stdout = TRUE) == 0, error = function(e) FALSE)
diff --git a/r/tests/testthat/test-Array.R b/r/tests/testthat/test-Array.R
index b4fa829..86d4365 100644
--- a/r/tests/testthat/test-Array.R
+++ b/r/tests/testthat/test-Array.R
@@ -53,6 +53,7 @@ test_that("binary Array", {
expect_array_roundtrip(bin, fixed_size_binary(byte_width = 10))
# degenerate cases
+ skip_on_valgrind() # valgrind errors on these tests ARROW-12638
bin <- vctrs::new_vctr(
list(1:10),
class = "arrow_binary"
diff --git a/r/tests/testthat/test-arrow.R b/r/tests/testthat/test-arrow.R
index 2c901e1..2ab127e 100644
--- a/r/tests/testthat/test-arrow.R
+++ b/r/tests/testthat/test-arrow.R
@@ -62,6 +62,10 @@ test_that("check for an ArrowObject in functions use std::shared_ptr", {
})
test_that("MemoryPool calls gc() to free memory when allocation fails (ARROW-10080)", {
+ # There is a valgrind error on this test because there cannot be memory allocated
+ # which is exactly what this test is checking, but we quiet this
+ skip_on_valgrind()
+
env <- new.env()
trace(gc, print = FALSE, tracer = function() {
env$gc_was_called <- TRUE
diff --git a/r/tests/testthat/test-compute-aggregate.R b/r/tests/testthat/test-compute-aggregate.R
index 7701057..abd09e3 100644
--- a/r/tests/testthat/test-compute-aggregate.R
+++ b/r/tests/testthat/test-compute-aggregate.R
@@ -37,7 +37,11 @@ test_that("sum.Array", {
floats <- c(floats, NA)
na <- Array$create(floats)
- expect_identical(as.numeric(sum(na)), sum(floats))
+ if (!grepl("devel", R.version.string)) {
+ # Valgrind on R-devel confuses NaN and NA_real_
+ # https://r.789695.n4.nabble.com/Difference-in-NA-behavior-in-R-devel-running-under-valgrind-td4768731.html
+ expect_identical(as.numeric(sum(na)), sum(floats))
+ }
expect_r6_class(sum(na, na.rm = TRUE), "Scalar")
expect_identical(as.numeric(sum(na, na.rm = TRUE)), sum(floats, na.rm = TRUE))
@@ -78,7 +82,11 @@ test_that("mean.Array", {
floats <- c(floats, NA)
na <- Array$create(floats)
- expect_identical(as.vector(mean(na)), mean(floats))
+ if (!grepl("devel", R.version.string)) {
+ # Valgrind on R-devel confuses NaN and NA_real_
+ # https://r.789695.n4.nabble.com/Difference-in-NA-behavior-in-R-devel-running-under-valgrind-td4768731.html
+ expect_identical(as.vector(mean(na)), mean(floats))
+ }
expect_r6_class(mean(na, na.rm = TRUE), "Scalar")
expect_identical(as.vector(mean(na, na.rm = TRUE)), mean(floats, na.rm = TRUE))
[arrow] 10/13: ARROW-12670: [C++] Fix extract_regex output after
non-matching values
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit af476c6ebbe30855ad91439eb6ee6d77b3123ef6
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Tue May 11 12:16:54 2021 -0400
ARROW-12670: [C++] Fix extract_regex output after non-matching values
Closes #10287 from pitrou/ARROW-12670-extract-regex-nulls
Authored-by: Antoine Pitrou <an...@python.org>
Signed-off-by: Benjamin Kietzman <be...@gmail.com>
---
cpp/src/arrow/compute/kernels/scalar_string.cc | 9 ++-------
cpp/src/arrow/compute/kernels/scalar_string_test.cc | 4 ++++
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/scalar_string.cc b/cpp/src/arrow/compute/kernels/scalar_string.cc
index d547374..82ae6fa 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string.cc
@@ -1622,12 +1622,7 @@ struct ExtractRegex : public ExtractRegexBase {
checked_cast<BuilderType*>(struct_builder->field_builder(i)));
}
- auto visit_null = [&]() {
- for (int i = 0; i < group_count; i++) {
- RETURN_NOT_OK(field_builders[i]->AppendEmptyValue());
- }
- return struct_builder->AppendNull();
- };
+ auto visit_null = [&]() { return struct_builder->AppendNull(); };
auto visit_value = [&](util::string_view s) {
if (Match(s)) {
for (int i = 0; i < group_count; i++) {
@@ -1635,7 +1630,7 @@ struct ExtractRegex : public ExtractRegexBase {
}
return struct_builder->Append();
} else {
- return visit_null();
+ return struct_builder->AppendNull();
}
};
const ArrayData& input = *batch[0].array();
diff --git a/cpp/src/arrow/compute/kernels/scalar_string_test.cc b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
index 5774939..cb74b14 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
@@ -539,6 +539,10 @@ TYPED_TEST(TestStringKernels, ExtractRegex) {
"extract_regex", R"(["a1", "b2", "c3", null])", type,
R"([{"letter": "a", "digit": "1"}, {"letter": "b", "digit": "2"}, null, null])",
&options);
+ this->CheckUnary(
+ "extract_regex", R"(["a1", "c3", null, "b2"])", type,
+ R"([{"letter": "a", "digit": "1"}, null, null, {"letter": "b", "digit": "2"}])",
+ &options);
this->CheckUnary("extract_regex", R"(["a1", "b2"])", type,
R"([{"letter": "a", "digit": "1"}, {"letter": "b", "digit": "2"}])",
&options);
[arrow] 05/13: ARROW-12617: [Python] Align orc.write_table keyword
order with parquet.write_table
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit f80292d209dbd7a27276927de79a9f5dbc5a2287
Author: Joris Van den Bossche <jo...@gmail.com>
AuthorDate: Mon May 3 17:29:16 2021 +0200
ARROW-12617: [Python] Align orc.write_table keyword order with parquet.write_table
Closes #10223 from jorisvandenbossche/ARROW-12617-orc-write_table-signature
Authored-by: Joris Van den Bossche <jo...@gmail.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
python/pyarrow/_orc.pyx | 3 ++-
python/pyarrow/orc.py | 16 ++++++++++++----
python/pyarrow/tests/test_orc.py | 10 +++++++++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/python/pyarrow/_orc.pyx b/python/pyarrow/_orc.pyx
index 2640057..e56a62d 100644
--- a/python/pyarrow/_orc.pyx
+++ b/python/pyarrow/_orc.pyx
@@ -29,6 +29,7 @@ from pyarrow.lib cimport (check_status, _Weakrefable,
Schema, pyarrow_wrap_schema,
pyarrow_wrap_batch,
RecordBatch,
+ Table,
pyarrow_wrap_table,
pyarrow_unwrap_schema,
pyarrow_unwrap_table,
@@ -127,7 +128,7 @@ cdef class ORCWriter(_Weakrefable):
self.writer = move(GetResultValue[unique_ptr[ORCFileWriter]](
ORCFileWriter.Open(self.rd_handle.get())))
- def write(self, object table):
+ def write(self, Table table):
cdef:
shared_ptr[CTable] sp_table
sp_table = pyarrow_unwrap_table(table)
diff --git a/python/pyarrow/orc.py b/python/pyarrow/orc.py
index e1009bc..13af5a2 100644
--- a/python/pyarrow/orc.py
+++ b/python/pyarrow/orc.py
@@ -18,9 +18,10 @@
from itertools import count
from numbers import Integral
+import warnings
from pyarrow import types
-from pyarrow.lib import Schema
+from pyarrow.lib import Schema, Table
import pyarrow._orc as _orc
@@ -184,19 +185,26 @@ class ORCWriter:
self.writer.close()
-def write_table(where, table):
+def write_table(table, where):
"""
Write a table into an ORC file
Parameters
----------
+ table : pyarrow.lib.Table
+ The table to be written into the ORC file
where : str or pyarrow.io.NativeFile
Writable target. For passing Python file objects or byte buffers,
see pyarrow.io.PythonFileInterface, pyarrow.io.BufferOutputStream
or pyarrow.io.FixedSizeBufferWriter.
- table : pyarrow.lib.Table
- The table to be written into the ORC file
"""
+ if isinstance(where, Table):
+ warnings.warn(
+ "The order of the arguments has changed. Pass as "
+ "'write_table(table, where)' instead. The old order will raise "
+ "an error in the future.", FutureWarning, stacklevel=2
+ )
+ table, where = where, table
writer = ORCWriter(where)
writer.write(table)
writer.close()
diff --git a/python/pyarrow/tests/test_orc.py b/python/pyarrow/tests/test_orc.py
index 14edad8..e71c452 100644
--- a/python/pyarrow/tests/test_orc.py
+++ b/python/pyarrow/tests/test_orc.py
@@ -176,7 +176,15 @@ def test_orcfile_readwrite():
a = pa.array([1, None, 3, None])
b = pa.array([None, "Arrow", None, "ORC"])
table = pa.table({"int64": a, "utf8": b})
- orc.write_table(buffer_output_stream, table)
+ orc.write_table(table, buffer_output_stream)
+ buffer_reader = pa.BufferReader(buffer_output_stream.getvalue())
+ output_table = orc.ORCFile(buffer_reader).read()
+ assert table.equals(output_table)
+
+ # deprecated keyword order
+ buffer_output_stream = pa.BufferOutputStream()
+ with pytest.warns(FutureWarning):
+ orc.write_table(buffer_output_stream, table)
buffer_reader = pa.BufferReader(buffer_output_stream.getvalue())
output_table = orc.ORCFile(buffer_reader).read()
assert table.equals(output_table)
[arrow] 06/13: ARROW-12568: [C++][Compute] Fix nullptr deference
when array contains no nulls
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 63954cb2d87d8acffd16a768f871459a80a8deac
Author: Yibo Cai <yi...@arm.com>
AuthorDate: Mon May 3 17:37:12 2021 +0200
ARROW-12568: [C++][Compute] Fix nullptr deference when array contains no nulls
Closes #10184 from cyb70289/12568-cast-crash
Lead-authored-by: Yibo Cai <yi...@arm.com>
Co-authored-by: Antoine Pitrou <an...@python.org>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/compute/kernels/hash_aggregate.cc | 8 +-
.../arrow/compute/kernels/hash_aggregate_test.cc | 23 ++++++
cpp/src/arrow/compute/kernels/scalar_boolean.cc | 90 ++++++++++++++++------
.../arrow/compute/kernels/scalar_boolean_test.cc | 18 +++++
.../arrow/compute/kernels/scalar_cast_nested.cc | 8 +-
cpp/src/arrow/compute/kernels/scalar_cast_test.cc | 14 ++++
6 files changed, 131 insertions(+), 30 deletions(-)
diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate.cc b/cpp/src/arrow/compute/kernels/hash_aggregate.cc
index dccbe50..93a8293 100644
--- a/cpp/src/arrow/compute/kernels/hash_aggregate.cc
+++ b/cpp/src/arrow/compute/kernels/hash_aggregate.cc
@@ -483,9 +483,11 @@ struct GroupedCountImpl : public GroupedAggregator {
const auto& input = batch[0].array();
if (options_.count_mode == CountOptions::COUNT_NULL) {
- for (int64_t i = 0, input_i = input->offset; i < input->length; ++i, ++input_i) {
- auto g = group_ids[i];
- raw_counts[g] += !BitUtil::GetBit(input->buffers[0]->data(), input_i);
+ if (input->GetNullCount() != 0) {
+ for (int64_t i = 0, input_i = input->offset; i < input->length; ++i, ++input_i) {
+ auto g = group_ids[i];
+ raw_counts[g] += !BitUtil::GetBit(input->buffers[0]->data(), input_i);
+ }
}
return Status::OK();
}
diff --git a/cpp/src/arrow/compute/kernels/hash_aggregate_test.cc b/cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
index 7858d8b..507f171 100644
--- a/cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
+++ b/cpp/src/arrow/compute/kernels/hash_aggregate_test.cc
@@ -678,6 +678,29 @@ TEST(GroupBy, ConcreteCaseWithValidateGroupBy) {
}
}
+// Count nulls/non_nulls from record batch with no nulls
+TEST(GroupBy, CountNull) {
+ auto batch = RecordBatchFromJSON(
+ schema({field("argument", float64()), field("key", utf8())}), R"([
+ [1.0, "alfa"],
+ [2.0, "beta"],
+ [3.0, "gama"]
+ ])");
+
+ CountOptions count_non_null{CountOptions::COUNT_NON_NULL},
+ count_null{CountOptions::COUNT_NULL};
+
+ using internal::Aggregate;
+ for (auto agg : {
+ Aggregate{"hash_count", &count_non_null},
+ Aggregate{"hash_count", &count_null},
+ }) {
+ SCOPED_TRACE(agg.function);
+ ValidateGroupBy({agg}, {batch->GetColumnByName("argument")},
+ {batch->GetColumnByName("key")});
+ }
+}
+
TEST(GroupBy, RandomArraySum) {
for (int64_t length : {1 << 10, 1 << 12, 1 << 15}) {
for (auto null_probability : {0.0, 0.01, 0.5, 1.0}) {
diff --git a/cpp/src/arrow/compute/kernels/scalar_boolean.cc b/cpp/src/arrow/compute/kernels/scalar_boolean.cc
index 009b968..c6551eb 100644
--- a/cpp/src/arrow/compute/kernels/scalar_boolean.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_boolean.cc
@@ -163,19 +163,32 @@ struct KleeneAnd : Commutative<KleeneAnd> {
bool right_false = right.is_valid && !checked_cast<const BooleanScalar&>(right).value;
if (right_false) {
- return GetBitmap(*out, 0).SetBitsTo(true),
- GetBitmap(*out, 1).SetBitsTo(false); // all false case
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ GetBitmap(*out, 1).SetBitsTo(false); // all false case
+ return;
}
if (right_true) {
- return GetBitmap(*out, 0).CopyFrom(GetBitmap(left, 0)),
- GetBitmap(*out, 1).CopyFrom(GetBitmap(left, 1));
+ if (left.GetNullCount() == 0) {
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ } else {
+ GetBitmap(*out, 0).CopyFrom(GetBitmap(left, 0));
+ }
+ GetBitmap(*out, 1).CopyFrom(GetBitmap(left, 1));
+ return;
}
// scalar was null: out[i] is valid iff left[i] was false
- ::arrow::internal::BitmapAndNot(left.buffers[0]->data(), left.offset,
- left.buffers[1]->data(), left.offset, left.length,
- out->offset, out->buffers[0]->mutable_data());
+ if (left.GetNullCount() == 0) {
+ ::arrow::internal::InvertBitmap(left.buffers[1]->data(), left.offset, left.length,
+ out->buffers[0]->mutable_data(), out->offset);
+ } else {
+ ::arrow::internal::BitmapAndNot(left.buffers[0]->data(), left.offset,
+ left.buffers[1]->data(), left.offset, left.length,
+ out->offset, out->buffers[0]->mutable_data());
+ }
::arrow::internal::CopyBitmap(left.buffers[1]->data(), left.offset, left.length,
out->buffers[1]->mutable_data(), out->offset);
}
@@ -183,7 +196,8 @@ struct KleeneAnd : Commutative<KleeneAnd> {
static void Call(KernelContext* ctx, const ArrayData& left, const ArrayData& right,
ArrayData* out) {
if (left.GetNullCount() == 0 && right.GetNullCount() == 0) {
- GetBitmap(*out, 0).SetBitsTo(true);
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
return And::Call(ctx, left, right, out);
}
auto compute_word = [](uint64_t left_true, uint64_t left_false, uint64_t right_true,
@@ -246,19 +260,32 @@ struct KleeneOr : Commutative<KleeneOr> {
bool right_false = right.is_valid && !checked_cast<const BooleanScalar&>(right).value;
if (right_true) {
- return GetBitmap(*out, 0).SetBitsTo(true),
- GetBitmap(*out, 1).SetBitsTo(true); // all true case
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ GetBitmap(*out, 1).SetBitsTo(true); // all true case
+ return;
}
if (right_false) {
- return GetBitmap(*out, 0).CopyFrom(GetBitmap(left, 0)),
- GetBitmap(*out, 1).CopyFrom(GetBitmap(left, 1));
+ if (left.GetNullCount() == 0) {
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ } else {
+ GetBitmap(*out, 0).CopyFrom(GetBitmap(left, 0));
+ }
+ GetBitmap(*out, 1).CopyFrom(GetBitmap(left, 1));
+ return;
}
// scalar was null: out[i] is valid iff left[i] was true
- ::arrow::internal::BitmapAnd(left.buffers[0]->data(), left.offset,
- left.buffers[1]->data(), left.offset, left.length,
- out->offset, out->buffers[0]->mutable_data());
+ if (left.GetNullCount() == 0) {
+ ::arrow::internal::CopyBitmap(left.buffers[1]->data(), left.offset, left.length,
+ out->buffers[0]->mutable_data(), out->offset);
+ } else {
+ ::arrow::internal::BitmapAnd(left.buffers[0]->data(), left.offset,
+ left.buffers[1]->data(), left.offset, left.length,
+ out->offset, out->buffers[0]->mutable_data());
+ }
::arrow::internal::CopyBitmap(left.buffers[1]->data(), left.offset, left.length,
out->buffers[1]->mutable_data(), out->offset);
}
@@ -266,7 +293,8 @@ struct KleeneOr : Commutative<KleeneOr> {
static void Call(KernelContext* ctx, const ArrayData& left, const ArrayData& right,
ArrayData* out) {
if (left.GetNullCount() == 0 && right.GetNullCount() == 0) {
- GetBitmap(*out, 0).SetBitsTo(true);
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
return Or::Call(ctx, left, right, out);
}
@@ -350,19 +378,32 @@ struct KleeneAndNot {
bool left_false = left.is_valid && !checked_cast<const BooleanScalar&>(left).value;
if (left_false) {
- return GetBitmap(*out, 0).SetBitsTo(true),
- GetBitmap(*out, 1).SetBitsTo(false); // all false case
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ GetBitmap(*out, 1).SetBitsTo(false); // all false case
+ return;
}
if (left_true) {
- return GetBitmap(*out, 0).CopyFrom(GetBitmap(right, 0)),
- GetBitmap(*out, 1).CopyFromInverted(GetBitmap(right, 1));
+ if (right.GetNullCount() == 0) {
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
+ } else {
+ GetBitmap(*out, 0).CopyFrom(GetBitmap(right, 0));
+ }
+ GetBitmap(*out, 1).CopyFromInverted(GetBitmap(right, 1));
+ return;
}
// scalar was null: out[i] is valid iff right[i] was true
- ::arrow::internal::BitmapAnd(right.buffers[0]->data(), right.offset,
- right.buffers[1]->data(), right.offset, right.length,
- out->offset, out->buffers[0]->mutable_data());
+ if (right.GetNullCount() == 0) {
+ ::arrow::internal::CopyBitmap(right.buffers[1]->data(), right.offset, right.length,
+ out->buffers[0]->mutable_data(), out->offset);
+ } else {
+ ::arrow::internal::BitmapAnd(right.buffers[0]->data(), right.offset,
+ right.buffers[1]->data(), right.offset, right.length,
+ out->offset, out->buffers[0]->mutable_data());
+ }
::arrow::internal::InvertBitmap(right.buffers[1]->data(), right.offset, right.length,
out->buffers[1]->mutable_data(), out->offset);
}
@@ -375,7 +416,8 @@ struct KleeneAndNot {
static void Call(KernelContext* ctx, const ArrayData& left, const ArrayData& right,
ArrayData* out) {
if (left.GetNullCount() == 0 && right.GetNullCount() == 0) {
- GetBitmap(*out, 0).SetBitsTo(true);
+ out->null_count = 0;
+ out->buffers[0] = nullptr;
return AndNot::Call(ctx, left, right, out);
}
diff --git a/cpp/src/arrow/compute/kernels/scalar_boolean_test.cc b/cpp/src/arrow/compute/kernels/scalar_boolean_test.cc
index 7d3f68e..4c11eb6 100644
--- a/cpp/src/arrow/compute/kernels/scalar_boolean_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_boolean_test.cc
@@ -110,6 +110,12 @@ TEST(TestBooleanKernel, KleeneAnd) {
expected = ArrayFromJSON(boolean(), "[true, false, false, null, false]");
CheckScalarBinary("and_kleene", left, right, expected);
CheckBooleanScalarArrayBinary("and_kleene", left);
+
+ left = ArrayFromJSON(boolean(), " [true, true, false, true]");
+ right = ArrayFromJSON(boolean(), " [true, false, false, false]");
+ expected = ArrayFromJSON(boolean(), "[true, false, false, false]");
+ CheckScalarBinary("and_kleene", left, right, expected);
+ CheckBooleanScalarArrayBinary("and_kleene", left);
}
TEST(TestBooleanKernel, KleeneAndNot) {
@@ -121,6 +127,12 @@ TEST(TestBooleanKernel, KleeneAndNot) {
boolean(), "[false, true, null, false, false, false, false, null, null]");
CheckScalarBinary("and_not_kleene", left, right, expected);
CheckBooleanScalarArrayBinary("and_not_kleene", left);
+
+ left = ArrayFromJSON(boolean(), " [true, true, false, false]");
+ right = ArrayFromJSON(boolean(), " [true, false, true, false]");
+ expected = ArrayFromJSON(boolean(), "[false, true, false, false]");
+ CheckScalarBinary("and_not_kleene", left, right, expected);
+ CheckBooleanScalarArrayBinary("and_not_kleene", left);
}
TEST(TestBooleanKernel, KleeneOr) {
@@ -135,6 +147,12 @@ TEST(TestBooleanKernel, KleeneOr) {
expected = ArrayFromJSON(boolean(), "[true, true, false, true, null]");
CheckScalarBinary("or_kleene", left, right, expected);
CheckBooleanScalarArrayBinary("or_kleene", left);
+
+ left = ArrayFromJSON(boolean(), " [true, true, false, false]");
+ right = ArrayFromJSON(boolean(), " [true, false, false, true]");
+ expected = ArrayFromJSON(boolean(), "[true, true, false, true]");
+ CheckScalarBinary("or_kleene", left, right, expected);
+ CheckBooleanScalarArrayBinary("or_kleene", left);
}
} // namespace compute
diff --git a/cpp/src/arrow/compute/kernels/scalar_cast_nested.cc b/cpp/src/arrow/compute/kernels/scalar_cast_nested.cc
index 1d81be4..777d811 100644
--- a/cpp/src/arrow/compute/kernels/scalar_cast_nested.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_cast_nested.cc
@@ -66,9 +66,11 @@ void CastListExec(KernelContext* ctx, const ExecBatch& batch, Datum* out) {
Datum values = in_array.child_data[0];
if (in_array.offset != 0) {
- KERNEL_ASSIGN_OR_RAISE(out_array->buffers[0], ctx,
- CopyBitmap(ctx->memory_pool(), in_array.buffers[0]->data(),
- in_array.offset, in_array.length));
+ if (in_array.buffers[0]) {
+ KERNEL_ASSIGN_OR_RAISE(out_array->buffers[0], ctx,
+ CopyBitmap(ctx->memory_pool(), in_array.buffers[0]->data(),
+ in_array.offset, in_array.length));
+ }
KERNEL_ASSIGN_OR_RAISE(out_array->buffers[1], ctx,
ctx->Allocate(sizeof(offset_type) * (in_array.length + 1)));
diff --git a/cpp/src/arrow/compute/kernels/scalar_cast_test.cc b/cpp/src/arrow/compute/kernels/scalar_cast_test.cc
index 6efecbb..e9618fa 100644
--- a/cpp/src/arrow/compute/kernels/scalar_cast_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_cast_test.cc
@@ -1702,6 +1702,20 @@ TEST(Cast, ListToList) {
CheckCast(MakeArray(list_float32), MakeArray(list_int32));
CheckCast(MakeArray(list_int64), MakeArray(list_int32));
}
+
+ // No nulls (ARROW-12568)
+ for (auto make_list : std::vector<make_list_t*>{&list, &large_list}) {
+ auto list_int32 = ArrayFromJSON(make_list(int32()),
+ "[[0], [1], [2, 3, 4], [5, 6], [], [7], [8, 9]]")
+ ->data();
+ auto list_int64 = list_int32->Copy();
+ list_int64->type = make_list(int64());
+ list_int64->child_data[0] = Cast(list_int32->child_data[0], int64())->array();
+ ASSERT_OK(MakeArray(list_int64)->ValidateFull());
+
+ CheckCast(MakeArray(list_int32), MakeArray(list_int64));
+ CheckCast(MakeArray(list_int64), MakeArray(list_int32));
+ }
}
TEST(Cast, ListToListOptionsPassthru) {
[arrow] 09/13: ARROW-12663: [C++] Fix a cuda 11.2 compiler segfault
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 6a2915e0f69e5d59d343a68aab22f8bb008b8faa
Author: GALI PREM SAGAR <sa...@gmail.com>
AuthorDate: Mon May 10 17:17:32 2021 +0200
ARROW-12663: [C++] Fix a cuda 11.2 compiler segfault
With the nvcc 11.2 compiler we have a segfault when we have a copy and move assignment operator :
```
using Impl::operator=;
```
before a move-assignment operator:
```
Variant& operator=(Variant&& other) noexcept {
this->destroy();
other.move_to(this);
return *this;
}
```
A minimal repro :
With a segfault : https://godbolt.org/z/h9eYv6zas
Without a segfault : https://godbolt.org/z/oWhK5qPd8
In this PR, as a workaround, we have essentially re-ordered the move-assignment of `Variant` before `using Impl::operator=;`.
Closes #10257 from galipremsagar/patch-2
Authored-by: GALI PREM SAGAR <sa...@gmail.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/util/variant.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/cpp/src/arrow/util/variant.h b/cpp/src/arrow/util/variant.h
index 89f39ab..962254a 100644
--- a/cpp/src/arrow/util/variant.h
+++ b/cpp/src/arrow/util/variant.h
@@ -262,18 +262,17 @@ class Variant : detail::VariantImpl<Variant<T...>, T...>,
Variant(const Variant& other) = default;
Variant& operator=(const Variant& other) = default;
-
- using Impl::Impl;
- using Impl::operator=;
-
- Variant(Variant&& other) noexcept { other.move_to(this); }
-
Variant& operator=(Variant&& other) noexcept {
this->destroy();
other.move_to(this);
return *this;
}
+ using Impl::Impl;
+ using Impl::operator=;
+
+ Variant(Variant&& other) noexcept { other.move_to(this); }
+
~Variant() {
static_assert(offsetof(Variant, data_) == 0, "(void*)&Variant::data_ == (void*)this");
this->destroy();
[arrow] 12/13: ARROW-12774 : [C++][Compute]
replace_substring_regex() creates invalid arrays => crash
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit efdfb6dd45f221ab1124ed1b648c186c82301867
Author: niranda perera <ni...@gmail.com>
AuthorDate: Sat May 15 14:29:38 2021 +0800
ARROW-12774 : [C++][Compute] replace_substring_regex() creates invalid arrays => crash
fixing ARROW-12774
Closes #10320 from nirandaperera/ARROW-12774
Authored-by: niranda perera <ni...@gmail.com>
Signed-off-by: Yibo Cai <yi...@arm.com>
---
cpp/src/arrow/compute/kernels/scalar_string.cc | 2 +-
cpp/src/arrow/compute/kernels/scalar_string_test.cc | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/cpp/src/arrow/compute/kernels/scalar_string.cc b/cpp/src/arrow/compute/kernels/scalar_string.cc
index 82ae6fa..84a30c4 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string.cc
@@ -1329,7 +1329,7 @@ struct ReplaceSubString {
if (batch[0].kind() == Datum::ARRAY) {
// We already know how many strings we have, so we can use Reserve/UnsafeAppend
- KERNEL_RETURN_IF_ERROR(ctx, offset_builder.Reserve(batch[0].array()->length));
+ KERNEL_RETURN_IF_ERROR(ctx, offset_builder.Reserve(batch[0].array()->length + 1));
offset_builder.UnsafeAppend(0); // offsets start at 0
const ArrayData& input = *batch[0].array();
diff --git a/cpp/src/arrow/compute/kernels/scalar_string_test.cc b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
index cb74b14..a59634b 100644
--- a/cpp/src/arrow/compute/kernels/scalar_string_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_string_test.cc
@@ -499,6 +499,14 @@ TYPED_TEST(TestStringKernels, ReplaceSubstringRegex) {
ReplaceSubstringOptions options_regex2{"(a.a)", "aba\\1"};
this->CheckUnary("replace_substring_regex", R"(["aaaaaa"])", this->type(),
R"(["abaaaaabaaaa"])", &options_regex2);
+
+ // ARROW-12774
+ ReplaceSubstringOptions options_regex3{"X", "Y"};
+ this->CheckUnary("replace_substring_regex",
+ R"(["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"])",
+ this->type(),
+ R"(["A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"])",
+ &options_regex3);
}
TYPED_TEST(TestStringKernels, ReplaceSubstringRegexLimited) {
[arrow] 04/13: ARROW-12622: [Python] Fix segfault in read_csv when
not on main thread
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit dbf16e3de7fa4f03c61a9b4d9b2743fe77ad91c0
Author: David Li <li...@gmail.com>
AuthorDate: Mon May 3 16:53:16 2021 +0200
ARROW-12622: [Python] Fix segfault in read_csv when not on main thread
An uninitialized StopToken caused segfaults if you ever called read_csv with cancellation disabled or when not on the main thread (e.g. if used in a Flight server). If we have a 4.0.1 I think this qualifies as a regression.
Closes #10227 from lidavidm/arrow-12622
Authored-by: David Li <li...@gmail.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
python/pyarrow/error.pxi | 2 +-
python/pyarrow/tests/test_csv.py | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/python/pyarrow/error.pxi b/python/pyarrow/error.pxi
index f9e45f2..2866848 100644
--- a/python/pyarrow/error.pxi
+++ b/python/pyarrow/error.pxi
@@ -188,8 +188,8 @@ cdef class SignalStopHandler:
if signal.getsignal(sig) not in (signal.SIG_DFL,
signal.SIG_IGN, None)]
+ self._stop_token = StopToken()
if not self._signals.empty():
- self._stop_token = StopToken()
self._stop_token.init(GetResultValue(
SetSignalStopSource()).token())
self._enabled = True
diff --git a/python/pyarrow/tests/test_csv.py b/python/pyarrow/tests/test_csv.py
index 395f948..34ab556 100644
--- a/python/pyarrow/tests/test_csv.py
+++ b/python/pyarrow/tests/test_csv.py
@@ -942,6 +942,14 @@ class BaseTestCSVRead:
assert isinstance(e, pa.ArrowCancelled)
assert e.signum == signal.SIGINT
+ def test_cancellation_disabled(self):
+ # ARROW-12622: reader would segfault when the cancelling signal
+ # handler was not enabled (e.g. if disabled, or if not on the
+ # main thread)
+ t = threading.Thread(target=lambda: self.read_bytes(b"f64\n0.1"))
+ t.start()
+ t.join()
+
class TestSerialCSVRead(BaseTestCSVRead, unittest.TestCase):
[arrow] 13/13: ARROW-12578: [JS] Remove Buffer in favor of
TextEncoder API to support bundlers such as Rollup
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit eaac875f4bb7571d99f99248eb7d8081e12c4492
Author: Dominik Moritz <do...@gmail.com>
AuthorDate: Sun May 16 06:37:48 2021 +0900
ARROW-12578: [JS] Remove Buffer in favor of TextEncoder API to support bundlers such as Rollup
Bundlers such as Rollup do not recognize the `_Buffer` import, which breaks their builds. This change resolves this issue by removing Buffer in favor of `TextEncoder`. Note that change incurs a performance penalty on Node as `Buffer` is often faster.
Co-authored-by: Adam Lippai <ad...@rigo.sk>
Co-authored-by: Paul Taylor <pa...@me.com>
Closes #10332 from domoritz/remove-buffer-js
Authored-by: Dominik Moritz <do...@gmail.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
js/src/util/utf8.ts | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/js/src/util/utf8.ts b/js/src/util/utf8.ts
index 4e04a8e..1eee931 100644
--- a/js/src/util/utf8.ts
+++ b/js/src/util/utf8.ts
@@ -15,34 +15,15 @@
// specific language governing permissions and limitations
// under the License.
-import { toUint8Array } from './buffer';
import {
TextDecoder as TextDecoderPolyfill,
TextEncoder as TextEncoderPolyfill,
} from 'text-encoding-utf-8';
-/** @ignore @suppress {missingRequire} */
-const _Buffer = eval("typeof Buffer === 'function' ? Buffer : null");
+const decoder = new (typeof TextDecoder !== 'undefined' ? TextDecoder : TextDecoderPolyfill)('utf-8');
/** @ignore */
-const useNativeEncoders = typeof TextDecoder === 'function' && typeof TextEncoder === 'function';
+export const decodeUtf8 = (buffer?: ArrayBuffer | ArrayBufferView) => decoder.decode(buffer);
+const encoder = new (typeof TextEncoder !== 'undefined' ? TextEncoder : TextEncoderPolyfill)();
/** @ignore */
-export const decodeUtf8 = ((TextDecoder) => {
- if (useNativeEncoders || !_Buffer) {
- const decoder = new TextDecoder('utf-8');
- return (buffer?: ArrayBuffer | ArrayBufferView) => decoder.decode(buffer);
- }
- return (input: ArrayBufferLike | ArrayBufferView) => {
- const { buffer, byteOffset, length } = toUint8Array(input);
- return _Buffer.from(buffer, byteOffset, length).toString();
- };
-})(typeof TextDecoder !== 'undefined' ? TextDecoder : TextDecoderPolyfill);
-
-/** @ignore */
-export const encodeUtf8 = ((TextEncoder) => {
- if (useNativeEncoders || !_Buffer) {
- const encoder = new TextEncoder();
- return (value?: string) => encoder.encode(value);
- }
- return (input = '') => toUint8Array(_Buffer.from(input, 'utf8'));
-})(typeof TextEncoder !== 'undefined' ? TextEncoder : TextEncoderPolyfill);
+export const encodeUtf8 = (value?: string) => encoder.encode(value);
[arrow] 08/13: ARROW-12642: [R] LIBARROW_MINIMAL, LIBARROW_DOWNLOAD,
NOT_CRAN env vars should not be case-sensitive
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit a8912410b1d29487ed9899f6b58ac3564c36ca98
Author: Ian Cook <ia...@gmail.com>
AuthorDate: Wed May 5 11:38:06 2021 -0500
ARROW-12642: [R] LIBARROW_MINIMAL, LIBARROW_DOWNLOAD, NOT_CRAN env vars should not be case-sensitive
This makes the environment variables `LIBARROW_MINIMAL`, `LIBARROW_DOWNLOAD`, and `NOT_CRAN` case-insensitive
Closes #10252 from ianmcook/ARROW-12642
Authored-by: Ian Cook <ia...@gmail.com>
Signed-off-by: Jonathan Keane <jk...@gmail.com>
---
r/configure | 3 +++
r/inst/build_arrow_static.sh | 3 +++
2 files changed, 6 insertions(+)
diff --git a/r/configure b/r/configure
index 2da2b9f..aa7e7a8 100755
--- a/r/configure
+++ b/r/configure
@@ -38,6 +38,9 @@ ARROW_R_DEV=`echo $ARROW_R_DEV | tr '[:upper:]' '[:lower:]'`
FORCE_AUTOBREW=`echo $FORCE_AUTOBREW | tr '[:upper:]' '[:lower:]'`
FORCE_BUNDLED_BUILD=`echo $FORCE_BUNDLED_BUILD | tr '[:upper:]' '[:lower:]'`
ARROW_USE_PKG_CONFIG=`echo $ARROW_USE_PKG_CONFIG | tr '[:upper:]' '[:lower:]'`
+LIBARROW_MINIMAL=`echo $LIBARROW_MINIMAL | tr '[:upper:]' '[:lower:]'`
+LIBARROW_DOWNLOAD=`echo $LIBARROW_DOWNLOAD | tr '[:upper:]' '[:lower:]'`
+NOT_CRAN=`echo $NOT_CRAN | tr '[:upper:]' '[:lower:]'`
VERSION=`grep '^Version' DESCRIPTION | sed s/Version:\ //`
UNAME=`uname -s`
diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh
index 6fba5be..5ae615d 100755
--- a/r/inst/build_arrow_static.sh
+++ b/r/inst/build_arrow_static.sh
@@ -36,6 +36,9 @@ set -x
SOURCE_DIR="$(cd "${SOURCE_DIR}" && pwd)"
DEST_DIR="$(mkdir -p "${DEST_DIR}" && cd "${DEST_DIR}" && pwd)"
+# Make some env vars case-insensitive
+LIBARROW_MINIMAL=`echo $LIBARROW_MINIMAL | tr '[:upper:]' '[:lower:]'`
+
if [ "$LIBARROW_MINIMAL" = "false" ]; then
ARROW_DEFAULT_PARAM="ON"
else
[arrow] 11/13: ARROW-12746: [Go][Flight] append instead of
overwriting outgoing metadata
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 39dd06b5b9da9c293fee5bee06b28e6ff6bae0cd
Author: Matthew Topol <mt...@factset.com>
AuthorDate: Thu May 13 09:05:17 2021 -0700
ARROW-12746: [Go][Flight] append instead of overwriting outgoing metadata
Closes #10297 from zeroshade/flight-client-metadata
Authored-by: Matthew Topol <mt...@factset.com>
Signed-off-by: Micah Kornfield <em...@gmail.com>
---
go/arrow/flight/client_auth.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/go/arrow/flight/client_auth.go b/go/arrow/flight/client_auth.go
index 5f7c151..1c1e38e 100644
--- a/go/arrow/flight/client_auth.go
+++ b/go/arrow/flight/client_auth.go
@@ -65,7 +65,7 @@ func createClientAuthUnaryInterceptor(auth ClientAuthHandler) grpc.UnaryClientIn
return status.Errorf(codes.Unauthenticated, "error retrieving token: %s", err)
}
- return invoker(metadata.NewOutgoingContext(ctx, metadata.Pairs(grpcAuthHeader, tok)), method, req, reply, cc, opts...)
+ return invoker(metadata.AppendToOutgoingContext(ctx, grpcAuthHeader, tok), method, req, reply, cc, opts...)
}
}
@@ -86,6 +86,6 @@ func createClientAuthStreamInterceptor(auth ClientAuthHandler) grpc.StreamClient
return nil, status.Errorf(codes.Unauthenticated, "error retrieving token: %s", err)
}
- return streamer(metadata.NewOutgoingContext(ctx, metadata.Pairs(grpcAuthHeader, tok)), desc, cc, method, opts...)
+ return streamer(metadata.AppendToOutgoingContext(ctx, grpcAuthHeader, tok), desc, cc, method, opts...)
}
}
[arrow] 03/13: ARROW-11926: [R] preparations for ucrt toolchains
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit c5ee38c0bad4ed7c4e6f2b0351a7d486b28ca65d
Author: Jeroen Ooms <je...@gmail.com>
AuthorDate: Fri Apr 30 15:09:28 2021 -0500
ARROW-11926: [R] preparations for ucrt toolchains
Minimal changes to link to ucrt builds specifically once supported (and will be safely redundant until then).
Closes #10217 from jeroen/winucrt
Lead-authored-by: Jeroen Ooms <je...@gmail.com>
Co-authored-by: Neal Richardson <ne...@gmail.com>
Signed-off-by: Jonathan Keane <jk...@gmail.com>
---
r/configure.win | 2 +-
r/src/Makevars.ucrt | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/r/configure.win b/r/configure.win
index d645834..f31bf8f 100644
--- a/r/configure.win
+++ b/r/configure.win
@@ -50,7 +50,7 @@ AWS_LIBS="-laws-cpp-sdk-config -laws-cpp-sdk-transfer -laws-cpp-sdk-identity-man
# NOTE: If you make changes to the libraries below, you should also change
# ci/scripts/r_windows_build.sh and ci/scripts/PKGBUILD
PKG_CFLAGS="-I${RWINLIB}/include -DARROW_STATIC -DPARQUET_STATIC -DARROW_DS_STATIC -DARROW_R_WITH_ARROW -DARROW_R_WITH_PARQUET -DARROW_R_WITH_DATASET"
-PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '"-L${RWINLIB}/lib"'$(R_ARCH) '"-lparquet -larrow_dataset -larrow -larrow_bundled_dependencies -lutf8proc -lthrift -lsnappy -lz -lzstd -llz4 ${MIMALLOC_LIBS} ${OPENSSL_LIBS}"
+PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '"-L${RWINLIB}/lib"'$(R_ARCH)$(CRT) '"-lparquet -larrow_dataset -larrow -larrow_bundled_dependencies -lutf8proc -lthrift -lsnappy -lz -lzstd -llz4 ${MIMALLOC_LIBS} ${OPENSSL_LIBS}"
# S3 and re2 support only for Rtools40 (i.e. R >= 4.0)
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e 'R.version$major >= 4' | grep TRUE >/dev/null 2>&1
diff --git a/r/src/Makevars.ucrt b/r/src/Makevars.ucrt
new file mode 100644
index 0000000..52488eb
--- /dev/null
+++ b/r/src/Makevars.ucrt
@@ -0,0 +1,19 @@
+# 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.
+
+CRT=-ucrt
+include Makevars.win
[arrow] 01/13: ARROW-12520: [R] Minor docs updates
Posted by ks...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kszucs pushed a commit to branch maint-4.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git
commit 8004518adbd8381e721200d0ba432e1c467a6d16
Author: Jonathan Keane <jk...@gmail.com>
AuthorDate: Mon Apr 26 12:23:47 2021 -0700
ARROW-12520: [R] Minor docs updates
Closes #10143 from jonkeane/ARROW-12520
Authored-by: Jonathan Keane <jk...@gmail.com>
Signed-off-by: Neal Richardson <ne...@gmail.com>
---
r/vignettes/arrow.Rmd | 2 +-
r/vignettes/developing.Rmd | 25 +++++++++++++------------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/r/vignettes/arrow.Rmd b/r/vignettes/arrow.Rmd
index 21cbbe4..4c5da50 100644
--- a/r/vignettes/arrow.Rmd
+++ b/r/vignettes/arrow.Rmd
@@ -104,7 +104,7 @@ corresponds to a class of the same name in the Arrow C++ library. The `arrow`
package provides a variety of `R6` and S3 methods for interacting with instances
of these classes.
-For convenience, the `arrow package also defines several synthetic classes that
+For convenience, the `arrow` package also defines several synthetic classes that
do not exist in the C++ library, including:
* `ArrowDatum`: inherited by `Scalar`, `Array`, and `ChunkedArray`
diff --git a/r/vignettes/developing.Rmd b/r/vignettes/developing.Rmd
index 38027a9..efb2c80 100644
--- a/r/vignettes/developing.Rmd
+++ b/r/vignettes/developing.Rmd
@@ -116,7 +116,7 @@ export ARROW_HOME=$(pwd)/dist
mkdir $ARROW_HOME
```
-_Special instructions on Linux:_ You will need to set `LD_LIBRARY_PATH` to the `lib` directory that will is under where we set `$ARROW_HOME`, before launching R and using Arrow. One way to do this is to add it to your profile (we use `~/.bash_profile` here, but you might need to put this in a different file depending on your setup, e.g. if you use a shell other than `bash`). On macOS we do not need to do this because the macOS shared library paths are hardcoded to their locations during [...]
+_Special instructions on Linux:_ You will need to set `LD_LIBRARY_PATH` to the `lib` directory that is under where we set `$ARROW_HOME`, before launching R and using Arrow. One way to do this is to add it to your profile (we use `~/.bash_profile` here, but you might need to put this in a different file depending on your setup, e.g. if you use a shell other than `bash`). On macOS we do not need to do this because the macOS shared library paths are hardcoded to their locations during build time.
```{bash, save=run & ubuntu & !sys_install}
export LD_LIBRARY_PATH=$ARROW_HOME/lib:$LD_LIBRARY_PATH
@@ -140,14 +140,14 @@ cmake \
-DARROW_COMPUTE=ON \
-DARROW_CSV=ON \
-DARROW_DATASET=ON \
+ -DARROW_EXTRA_ERROR_CONTEXT=ON \
-DARROW_FILESYSTEM=ON \
+ -DARROW_INSTALL_NAME_RPATH=OFF \
-DARROW_JEMALLOC=ON \
-DARROW_JSON=ON \
-DARROW_PARQUET=ON \
-DARROW_WITH_SNAPPY=ON \
-DARROW_WITH_ZLIB=ON \
- -DARROW_INSTALL_NAME_RPATH=OFF \
- -DARROW_EXTRA_ERROR_CONTEXT=ON \
..
```
@@ -172,14 +172,14 @@ cmake \
-DARROW_COMPUTE=ON \
-DARROW_CSV=ON \
-DARROW_DATASET=ON \
+ -DARROW_EXTRA_ERROR_CONTEXT=ON \
-DARROW_FILESYSTEM=ON \
+ -DARROW_INSTALL_NAME_RPATH=OFF \
-DARROW_JEMALLOC=ON \
-DARROW_JSON=ON \
-DARROW_PARQUET=ON \
-DARROW_WITH_SNAPPY=ON \
-DARROW_WITH_ZLIB=ON \
- -DARROW_INSTALL_NAME_RPATH=OFF \
- -DARROW_EXTRA_ERROR_CONTEXT=ON \
..
```
@@ -191,6 +191,7 @@ To enable optional features including: S3 support, an alternative memory allocat
``` shell
-DARROW_MIMALLOC=ON \
+ -DARROW_S3=ON \
-DARROW_WITH_BROTLI=ON \
-DARROW_WITH_BZ2=ON \
-DARROW_WITH_LZ4=ON \
@@ -252,7 +253,7 @@ export ARROW_R_CXXFLAGS=-fno-omit-frame-pointer
With the setups described here, you should not need to rebuild the Arrow library or even the C++ source in the R package as you iterated and work on the R package. The only time those should need to be rebuilt is if you have changed the C++ in the R package (and even then, `R CMD INSTALL .` should only need to recompile the files that have changed) _or_ if the Arrow library C++ has changed and there is a mismatch between the Arrow Library and the R package. If you find yourself rebuildin [...]
<details>
-<summary>For a full build: a `cmake` command with all of the R-relevant optional dependencies turned on</summary>
+<summary>For a full build: a `cmake` command with all of the R-relevant optional dependencies turned on. Development with other languages might require different flags as well. For example, to develop Python, you would need to also add `-DARROW_PYTHON=ON` (though all of the other flags used for Python are already included here).</summary>
<p>
``` shell
@@ -262,26 +263,26 @@ cmake \
-DARROW_COMPUTE=ON \
-DARROW_CSV=ON \
-DARROW_DATASET=ON \
+ -DARROW_EXTRA_ERROR_CONTEXT=ON \
-DARROW_FILESYSTEM=ON \
+ -DARROW_INSTALL_NAME_RPATH=OFF \
-DARROW_JEMALLOC=ON \
-DARROW_JSON=ON \
- -DARROW_PARQUET=ON \
- -DARROW_WITH_SNAPPY=ON \
- -DARROW_WITH_ZLIB=ON \
- -DARROW_INSTALL_NAME_RPATH=OFF \
- -DARROW_EXTRA_ERROR_CONTEXT=ON \
-DARROW_MIMALLOC=ON \
+ -DARROW_PARQUET=ON \
+ -DARROW_S3=ON \
-DARROW_WITH_BROTLI=ON \
-DARROW_WITH_BZ2=ON \
-DARROW_WITH_LZ4=ON \
-DARROW_WITH_SNAPPY=ON \
+ -DARROW_WITH_ZLIB=ON \
-DARROW_WITH_ZSTD=ON \
..
```
</p>
</details>
-## Troublshooting
+## Troubleshooting
Note that after any change to the C++ library, you must reinstall it and
run `make clean` or `git clean -fdx .` to remove any cached object code