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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); ARROW-17643: [R] Latest duckdb release is causing test failure by paleolimbot · Pull Request #14065 · apache/arrow · GitHub
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
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ jobs:
ulimit -c unlimited
# Setting a non-default and non-probable Marquesas French Polynesia time
# it has both with a .45 offset and very very few people who live there.
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} ubuntu-r
archery docker run -e TZ=MART -e ARROW_R_FORCE_TESTS=${{ matrix.force-tests }} -e ARROW_EXTRA_ERROR_CONTEXT=ON ubuntu-r
- name: Dump install logs
run: cat r/check/arrow.Rcheck/00install.out
if: always()
Expand Down
3 changes: 3 additions & 0 deletions ci/scripts/r_test.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,6 +85,9 @@ fi
# Make sure we aren't writing to the home dir (CRAN _hates_ this but there is no official check)
BEFORE=$(ls -alh ~/)

# Install dev duckdb
${R_BIN} -e 'install.packages("remotes"); remotes::install_github("duckdb/duckdb/tools/rpkg#4712", build = FALSE)'

SCRIPT="as_cran <- !identical(tolower(Sys.getenv('NOT_CRAN')), 'true')
if (as_cran) {
args <- '--as-cran'
Expand Down
20 changes: 10 additions & 10 deletions r/src/array.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,22 +51,22 @@ const char* r6_class_name<arrow::Array>::get(const std::shared_ptr<arrow::Array>

void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) {
if (offset == NA_INTEGER) {
cpp11::stop("Slice 'offset' cannot be NA");
arrow::arrow_stop("Slice 'offset' cannot be NA");
}
if (offset < 0) {
cpp11::stop("Slice 'offset' cannot be negative");
arrow::arrow_stop("Slice 'offset' cannot be negative");
}
if (offset > len) {
cpp11::stop("Slice 'offset' greater than array length");
arrow::arrow_stop("Slice 'offset' greater than array length");
}
}

void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) {
if (length == NA_INTEGER) {
cpp11::stop("Slice 'length' cannot be NA");
arrow::arrow_stop("Slice 'length' cannot be NA");
}
if (length < 0) {
cpp11::stop("Slice 'length' cannot be negative");
arrow::arrow_stop("Slice 'length' cannot be negative");
}
if (length > available) {
cpp11::warning("Slice 'length' greater than available length");
Expand All@@ -90,10 +90,10 @@ std::shared_ptr<arrow::Array> Array__Slice2(const std::shared_ptr<arrow::Array>&

void arrow::r::validate_index(int i, int len) {
if (i == NA_INTEGER) {
cpp11::stop("'i' cannot be NA");
arrow::arrow_stop("'i' cannot be NA");
}
if (i < 0 || i >= len) {
cpp11::stop("subscript out of bounds");
arrow::arrow_stop("subscript out of bounds");
}
}

Expand DownExpand Up@@ -162,13 +162,13 @@ bool Array__RangeEquals(const std::shared_ptr<arrow::Array>& self,
const std::shared_ptr<arrow::Array>& other, R_xlen_t start_idx,
R_xlen_t end_idx, R_xlen_t other_start_idx) {
if (start_idx == NA_INTEGER) {
cpp11::stop("'start_idx' cannot be NA");
arrow::arrow_stop("'start_idx' cannot be NA");
}
if (end_idx == NA_INTEGER) {
cpp11::stop("'end_idx' cannot be NA");
arrow::arrow_stop("'end_idx' cannot be NA");
}
if (other_start_idx == NA_INTEGER) {
cpp11::stop("'other_start_idx' cannot be NA");
arrow::arrow_stop("'other_start_idx' cannot be NA");
}
return self->RangeEquals(*other, start_idx, end_idx, other_start_idx);
}
Expand Down
6 changes: 3 additions & 3 deletions r/src/array_to_vector.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -599,8 +599,8 @@ class Converter_Dictionary : public Converter {
// TODO: also add int64, uint32, uint64 downcasts, if possible
break;
default:
cpp11::stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
arrow::arrow_stop("Cannot convert Dictionary Array of type `%s` to R",
dict_type.ToString().c_str());
}

if (chunked_array->num_chunks() > 0) {
Expand DownExpand Up@@ -1352,7 +1352,7 @@ std::shared_ptr<Converter> Converter::Make(
break;
}

cpp11::stop("cannot handle Array of type <%s>", type->name().c_str());
arrow::arrow_stop("cannot handle Array of type <%s>", type->name().c_str());
}

std::shared_ptr<ChunkedArray> to_chunks(const std::shared_ptr<Array>& array) {
Expand Down
32 changes: 26 additions & 6 deletions r/src/arrow_cpp11.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,24 @@
#endif

namespace arrow {

class RException : public std::runtime_error {
public:
explicit RException(const char* msg) : std::runtime_error(msg) {}
};

__attribute__((noreturn)) static inline void arrow_stop(const char* fmt, ...) {
char message[8096];
memset(message, 0, sizeof(message));

va_list args;
va_start(args, fmt);
vsnprintf(message, sizeof(message), fmt, args);
va_end(args);

throw RException(message);
}

namespace r {

template <typename T>
Expand All@@ -64,14 +82,14 @@ struct Pointer {
// User passed a character representation of the pointer address
SEXP char0 = STRING_ELT(x, 0);
if (char0 == NA_STRING) {
cpp11::stop("Can't convert NA_character_ to pointer");
arrow::arrow_stop("Can't convert NA_character_ to pointer");
}

const char* input_chars = CHAR(char0);
char* endptr;
uint64_t ptr_value = strtoull(input_chars, &endptr, 0);
if (endptr != (input_chars + strlen(input_chars))) {
cpp11::stop("Can't parse '%s' as a 64-bit integer address", input_chars);
arrow::arrow_stop("Can't parse '%s' as a 64-bit integer address", input_chars);
}

ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(ptr_value));
Expand All@@ -90,7 +108,7 @@ struct Pointer {
// User passed a double(1) of the static-casted pointer address.
ptr_ = reinterpret_cast<T*>(static_cast<uintptr_t>(REAL(x)[0]));
} else {
cpp11::stop("Can't convert input object to pointer");
arrow::arrow_stop("Can't convert input object to pointer");
}
}

Expand DownExpand Up@@ -207,12 +225,14 @@ Pointer r6_to_pointer(SEXP self) {
if (!Rf_inherits(self, "ArrowObject")) {
std::string type_name = arrow::util::nameof<
cpp11::decay_t<typename std::remove_pointer<Pointer>::type>>();
cpp11::stop("Invalid R object for %s, must be an ArrowObject", type_name.c_str());
arrow::arrow_stop("Invalid R object for %s, must be an ArrowObject",
type_name.c_str());
}
void* p = R_ExternalPtrAddr(Rf_findVarInFrame(self, arrow::r::symbols::xp));
if (p == nullptr) {
SEXP klass = Rf_getAttrib(self, R_ClassSymbol);
cpp11::stop("Invalid <%s>, external pointer to null", CHAR(STRING_ELT(klass, 0)));
arrow::arrow_stop("Invalid <%s>, external pointer to null",
CHAR(STRING_ELT(klass, 0)));
}
return reinterpret_cast<Pointer>(p);
}
Expand DownExpand Up@@ -357,7 +377,7 @@ SEXP to_r6(const std::shared_ptr<T>& ptr, const char* r6_class_name) {
SEXP r6_class = Rf_install(r6_class_name);

if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) {
cpp11::stop("No arrow R6 class named '%s'", r6_class_name);
arrow::arrow_stop("No arrow R6 class named '%s'", r6_class_name);
}

// make call: <symbol>$new(<x>)
Expand Down
19 changes: 15 additions & 4 deletions r/src/arrow_types.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,22 +92,33 @@ class UnwindProtectDetail : public StatusDetail {
virtual std::string ToString() const { return "R code execution error"; }
};

static inline Status StatusUnwindProtect(SEXP token) {
return Status::Invalid("R code execution error")
static inline Status StatusUnwindProtect(SEXP token, std::string message) {
return Status::Invalid("R code execution error (", message, ")")
.WithDetail(std::make_shared<UnwindProtectDetail>(token));
}

class MoreUsefulUnwindException : public cpp11::unwind_exception {
public:
explicit MoreUsefulUnwindException(SEXP token, std::string message = "")
: cpp11::unwind_exception(token) {}

const char* what() const noexcept { return message_.c_str(); }

private:
std::string message_;
};

static inline void StopIfNotOk(const Status& status) {
if (!status.ok()) {
auto detail = status.detail();
const UnwindProtectDetail* unwind_detail =
dynamic_cast<const UnwindProtectDetail*>(detail.get());
if (unwind_detail) {
throw cpp11::unwind_exception(unwind_detail->token);
throw MoreUsefulUnwindException(unwind_detail->token);
} else {
// ARROW-13039: be careful not to interpret our error message as a %-format string
std::string s = status.ToString();
cpp11::stop("%s", s.c_str());
throw RException(s.c_str());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/buffer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
default:
break;
}
cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x)));
}

// [[arrow::export]]
Expand Down
2 changes: 1 addition & 1 deletion r/src/chunkedarray.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,7 +110,7 @@ std::shared_ptr<arrow::ChunkedArray> ChunkedArray__from_list(cpp11::list chunks,
std::shared_ptr<arrow::DataType> type;
if (type_inferred) {
if (n == 0) {
cpp11::stop("type must be specified for empty list");
arrow::arrow_stop("type must be specified for empty list");
}
type = arrow::r::InferArrowType(VECTOR_ELT(chunks, 0));
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/src/compute-exec.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -375,7 +375,7 @@ std::shared_ptr<compute::ExecNode> ExecNode_Join(
} else if (type == 7) {
join_type = compute::JoinType::FULL_OUTER;
} else {
cpp11::stop("todo");
arrow::arrow_stop("todo");
}

return MakeExecNodeOrStop(
Expand Down
16 changes: 8 additions & 8 deletions r/src/compute.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ arrow::Datum as_cpp<arrow::Datum>(SEXP x) {

// This assumes that R objects have already been converted to Arrow objects;
// that seems right but should we do the wrapping here too/instead?
cpp11::stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
arrow::arrow_stop("to_datum: Not implemented for type %s", Rf_type2char(TYPEOF(x)));
}
} // namespace cpp11

Expand All@@ -123,7 +123,7 @@ SEXP from_datum(arrow::Datum datum) {
break;
}

cpp11::stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
arrow::arrow_stop("from_datum: Not implemented for Datum %s", datum.ToString().c_str());
}

std::shared_ptr<arrow::compute::FunctionOptions> make_compute_options(
Expand DownExpand Up@@ -632,7 +632,7 @@ arrow::Result<arrow::TypeHolder> ResolveScalarUDFOutputType(

cpp11::sexp output_type_sexp = state->resolver_(input_types_sexp);
if (!Rf_inherits(output_type_sexp, "DataType")) {
cpp11::stop(
arrow::arrow_stop(
"Function specified as arrow_scalar_function() out_type argument must "
"return a DataType");
}
Expand DownExpand Up@@ -681,7 +681,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// Error for an Array result of the wrong type
if (!result->type()->Equals(array->type())) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Array with type '%s'",
result->type()->ToString().c_str(), array->type()->ToString().c_str());
Expand All@@ -693,7 +693,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,

// handle a Scalar result of the wrong type
if (!result->type()->Equals(scalar->type)) {
return cpp11::stop(
return arrow::arrow_stop(
"Expected return Array or Scalar with type '%s' from user-defined "
"function but got Scalar with type '%s'",
result->type()->ToString().c_str(), scalar->type->ToString().c_str());
Expand All@@ -703,7 +703,7 @@ arrow::Status CallRScalarUDF(arrow::compute::KernelContext* context,
arrow::MakeArrayFromScalar(*scalar, span.length, context->memory_pool()));
result->value = std::move(array->data());
} else {
cpp11::stop("arrow_scalar_function must return an Array or Scalar");
arrow::arrow_stop("arrow_scalar_function must return an Array or Scalar");
}
},
"execute scalar user-defined function");
Expand All@@ -716,7 +716,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
R_xlen_t n_kernels = in_type_r.size();

if (n_kernels == 0) {
cpp11::stop("Can't register user-defined function with zero kernels");
arrow::arrow_stop("Can't register user-defined function with zero kernels");
}

// Compute the Arity from the list of input kernels. We don't currently handle
Expand All@@ -726,7 +726,7 @@ void RegisterScalarUDF(std::string name, cpp11::list func_sexp) {
for (R_xlen_t i = 1; i < n_kernels; i++) {
auto in_types = cpp11::as_cpp<std::shared_ptr<arrow::Schema>>(in_type_r[i]);
if (in_types->num_fields() != n_args) {
cpp11::stop(
arrow::arrow_stop(
"Kernels for user-defined function must accept the same number of arguments");
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ std::vector<std::string> runtime_info() {
void set_timezone_database(cpp11::strings path) {
auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
if (path.size() != 1) {
cpp11::stop("Must provide a single path to the timezone database.");
arrow::arrow_stop("Must provide a single path to the timezone database.");
}

arrow::GlobalOptions options;
Expand Down
4 changes: 2 additions & 2 deletions r/src/csv.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -131,14 +131,14 @@ std::shared_ptr<arrow::csv::ConvertOptions> csv___ConvertOptions__initialize(
timestamp_parsers.push_back(
cpp11::as_cpp<std::shared_ptr<arrow::TimestampParser>>(x));
} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be a scalar string or a "
"<TimestampParser> object");
}
}

} else {
cpp11::stop(
arrow::arrow_stop(
"unsupported timestamp parser, must be character vector of strptime "
"specifications, or a list of <TimestampParser> objects");
}
Expand Down
2 changes: 1 addition & 1 deletion r/src/dataset.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -342,7 +342,7 @@ ds::SegmentEncoding GetSegmentEncoding(const std::string& segment_encoding) {
} else if (segment_encoding == "uri") {
return ds::SegmentEncoding::Uri;
}
cpp11::stop("invalid segment encoding: " + segment_encoding);
arrow::arrow_stop("invalid segment encoding: %s", segment_encoding.c_str());
return ds::SegmentEncoding::None;
}

Expand Down
Loading